Search in sources :

Example 11 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds in project netvirt by opendaylight.

the class VpnInterfaceManager method processExternalVpnInterface.

private void processExternalVpnInterface(String interfaceName, String vpnName, long vpnId, BigInteger dpId, int lportTag, WriteTransaction writeInvTxn, int addOrRemove) {
    Uuid extNetworkId;
    try {
        // vpn instance of ext-net interface is the network-id
        extNetworkId = new Uuid(vpnName);
    } catch (IllegalArgumentException e) {
        LOG.error("processExternalVpnInterface: VPN instance {} is not Uuid. Processing external vpn interface {}" + " on dpn {} failed", vpnName, interfaceName, dpId);
        return;
    }
    List<Uuid> routerIds = VpnUtil.getExternalNetworkRouterIds(dataBroker, extNetworkId);
    if (routerIds == null || routerIds.isEmpty()) {
        LOG.info("processExternalVpnInterface: No router is associated with {}." + " Bailing out of processing external vpn interface {} on dpn {} for vpn {}", extNetworkId.getValue(), interfaceName, dpId, vpnName);
        return;
    }
    LOG.info("processExternalVpnInterface: Router-ids {} associated with exernal vpn-interface {} on dpn {}" + " for vpn {}", routerIds, interfaceName, dpId, vpnName);
    for (Uuid routerId : routerIds) {
        String routerName = routerId.getValue();
        BigInteger primarySwitch = VpnUtil.getPrimarySwitchForRouter(dataBroker, routerName);
        if (Objects.equals(primarySwitch, dpId)) {
            Routers router = VpnUtil.getExternalRouter(dataBroker, routerName);
            if (router != null) {
                if (addOrRemove == NwConstants.ADD_FLOW) {
                    vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), router.getExtGwMacAddress(), dpId, interfaceName, lportTag, writeInvTxn);
                } else {
                    vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), dpId, interfaceName, lportTag);
                }
            } else {
                LOG.error("processExternalVpnInterface: No external-router found for router-id {}. Bailing out of" + " processing external vpn-interface {} on dpn {} for vpn {}", routerName, interfaceName, dpId, vpnName);
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) BigInteger(java.math.BigInteger)

Example 12 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds in project netvirt by opendaylight.

the class ArpNotificationHandler method getSubnetId.

private String getSubnetId(String vpnName, String ip) {
    // Check if this IP belongs to a router_interface
    VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ip);
    if (vpnPortipToPort != null && vpnPortipToPort.isSubnetIp()) {
        List<Adjacency> adjacecnyList = VpnUtil.getAdjacenciesForVpnInterfaceFromConfig(dataBroker, vpnPortipToPort.getPortName());
        for (Adjacency adjacency : adjacecnyList) {
            if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                return adjacency.getSubnetId().getValue();
            }
        }
    }
    // Check if this IP belongs to a router_gateway
    List<Uuid> routerIds = VpnUtil.getExternalNetworkRouterIds(dataBroker, new Uuid(vpnName));
    for (Uuid routerId : routerIds) {
        Uuid subnetId = VpnUtil.getSubnetFromExternalRouterByIp(dataBroker, routerId, ip);
        if (subnetId != null) {
            return subnetId.getValue();
        }
    }
    return null;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnPortipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)

Example 13 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds in project netvirt by opendaylight.

the class NatUtil method createRouterIdsConfigDS.

static void createRouterIdsConfigDS(DataBroker dataBroker, long routerId, String routerName) {
    if (routerId == NatConstants.INVALID_ID) {
        LOG.error("createRouterIdsConfigDS : invalid routerId for routerName {}", routerName);
        return;
    }
    RouterIds rtrs = new RouterIdsBuilder().setKey(new RouterIdsKey(routerId)).setRouterId(routerId).setRouterName(routerName).build();
    MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, buildRouterIdentifier(routerId), rtrs);
}
Also used : RouterIds(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds) RouterIdsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey) RouterIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder)

Example 14 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds in project netvirt by opendaylight.

the class NeutronvpnNatManager method addExternalSubnet.

public void addExternalSubnet(Uuid networkId, Uuid subnetId, List<Uuid> routerIds) {
    InstanceIdentifier<Subnets> subnetsIdentifier = InstanceIdentifier.builder(ExternalSubnets.class).child(Subnets.class, new SubnetsKey(subnetId)).build();
    try {
        Subnets newExternalSubnets = createSubnets(subnetId, networkId, routerIds);
        LOG.debug("Creating external subnet {}", newExternalSubnets);
        SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetsIdentifier, newExternalSubnets);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("Creation of External Subnets {} failed", subnetId, ex);
    }
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets)

Example 15 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortDeleted.

private void handleNeutronPortDeleted(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final List<FixedIps> portIpsList = port.getFixedIps();
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (!(NeutronUtils.isPortVnicTypeNormal(port) || isPortTypeSwitchdev(port))) {
            for (FixedIps ip : portIpsList) {
                // remove direct port from subnetMaps config DS
                nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
            }
            LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
            return futures;
        }
        Uuid vpnId = null;
        Set<Uuid> routerIds = new HashSet<>();
        Uuid internetVpnId = null;
        for (FixedIps ip : portIpsList) {
            Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
            if (subnetMap == null) {
                continue;
            }
            if (subnetMap.getVpnId() != null) {
                // can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
                // obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
                vpnId = subnetMap.getVpnId();
            }
            if (subnetMap.getRouterId() != null) {
                routerIds.add(subnetMap.getRouterId());
            }
            internetVpnId = subnetMap.getInternetVpnId();
        }
        if (vpnId != null || internetVpnId != null) {
            // remove vpn-interface for this neutron port
            LOG.debug("removing VPN Interface for port {}", portName);
            if (!routerIds.isEmpty()) {
                for (Uuid routerId : routerIds) {
                    nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
                }
            }
            nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
            wrtConfigTxn);
        }
        // Remove of-port interface for this neutron port
        // ELAN interface is also implicitly deleted as part of this operation
        LOG.debug("Of-port-interface removal for port {}", portName);
        deleteOfPortInterface(port, wrtConfigTxn);
        // dissociate fixedIP from floatingIP if associated
        nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
        futures.add(wrtConfigTxn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 BigInteger (java.math.BigInteger)4 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)4 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey)3 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds)3 RouterIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder)3 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)2 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)2 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)2 Optional (com.google.common.base.Optional)1 Strings (com.google.common.base.Strings)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1