Search in sources :

Example 11 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleNeutronPortCreated.

private void handleNeutronPortCreated(final Port port) {
    final String portName = port.getUuid().getValue();
    final Uuid portId = port.getUuid();
    final String networkId = port.getNetworkId().getValue();
    final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
    if (NeutronConstants.IS_ODL_DHCP_PORT.test(port)) {
        return;
    }
    if (!NeutronUtils.isPortVnicTypeNormal(port) && (!isPortTypeSwitchdev(port) || !isSupportedVnicTypeByHost(port, NeutronConstants.VNIC_TYPE_DIRECT))) {
        for (FixedIps ip : keyFixedIpsMap.values()) {
            nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), null, portId);
        }
        LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "OF Port interfaces are not created", portName);
        return;
    }
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        // add direct port to subnetMaps config DS
        // TODO: for direct port as well, operations should be carried out per subnet based on port IP
        ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
            LOG.info("Of-port-interface creation for port {}", portName);
            // Create of-port interface for this neutron port
            String portInterfaceName = createOfPortInterface(port, tx);
            LOG.debug("Creating ELAN Interface for port {}", portName);
            createElanInterface(port, portInterfaceName, tx);
            Set<Uuid> vpnIdList = new HashSet<>();
            Set<Uuid> routerIds = new HashSet<>();
            for (FixedIps ip : keyFixedIpsMap.values()) {
                Subnetmap subnetMap = nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), portId, null);
                if (subnetMap != null && subnetMap.getInternetVpnId() != null) {
                    if (!vpnIdList.contains(subnetMap.getInternetVpnId())) {
                        vpnIdList.add(subnetMap.getInternetVpnId());
                    }
                }
                if (subnetMap != null && 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
                    Uuid vpnId = subnetMap.getVpnId();
                    if (vpnId != null) {
                        vpnIdList.add(vpnId);
                    }
                }
                if (subnetMap != null && subnetMap.getRouterId() != null) {
                    routerIds.add(subnetMap.getRouterId());
                }
            }
            if (!vpnIdList.isEmpty()) {
                // create new vpn-interface for neutron port
                LOG.debug("handleNeutronPortCreated: Adding VPN Interface for port {} from network {}", portName, networkId);
                nvpnManager.createVpnInterface(vpnIdList, port, tx);
                for (Uuid routerId : routerIds) {
                    nvpnManager.addToNeutronRouterInterfacesMap(routerId, port.getUuid().getValue());
                }
            }
        });
        LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortCreated: Failed for port {} with networkId {}", portName, networkId);
        return Collections.singletonList(future);
    });
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) FixedIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey) 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)

Example 12 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.

the class NeutronExternalSubnetHandler method handleExternalSubnetAdded.

public void handleExternalSubnetAdded(Network network, Uuid subnetId, @Nullable List<Uuid> routerIds) {
    Uuid networkId = network.getUuid();
    if (NeutronvpnUtils.getIsExternal(network) && NeutronvpnUtils.isFlatOrVlanNetwork(network)) {
        LOG.info("Added external subnet {} part of external network {} will create NAT external subnet", subnetId.getValue(), networkId.getValue());
        nvpnNatManager.updateOrAddExternalSubnet(networkId, subnetId, routerIds);
        nvpnManager.updateSubnetNode(subnetId, null, /* routerId */
        subnetId, null);
        nvpnManager.createVpnInstanceForSubnet(subnetId);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 13 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.

the class NeutronvpnNatManager method addRouterIdToExternalSubnet.

public void addRouterIdToExternalSubnet(Uuid networkId, Uuid subnetId, Uuid routerId) {
    Optional<Subnets> optionalExternalSubnets = neutronvpnUtils.getOptionalExternalSubnets(subnetId);
    if (optionalExternalSubnets.isPresent()) {
        Subnets subnets = optionalExternalSubnets.get();
        List<Uuid> routerIds;
        if (subnets.getRouterIds() != null && !subnets.getRouterIds().isEmpty()) {
            routerIds = new ArrayList<>(subnets.getRouterIds());
        } else {
            routerIds = new ArrayList<>();
        }
        if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(networkId) && !routerIds.contains(routerId)) {
            LOG.debug("Will add routerID {} for external subnet {}.", routerId, subnetId);
            routerIds.add(routerId);
            updateExternalSubnet(networkId, subnetId, routerIds);
        }
    }
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 14 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.

the class NeutronvpnNatManager method updateExternalSubnet.

public void updateExternalSubnet(Uuid networkId, Uuid subnetId, @Nullable 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("Updating external subnet {}", newExternalSubnets);
        SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetsIdentifier, newExternalSubnets);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("Update 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.mdsal.common.api.TransactionCommitFailedException) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)

Example 15 with RouterIds

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.

the class NeutronvpnNatManager method createSubnets.

private static Subnets createSubnets(Uuid subnetId, Uuid networkId, @Nullable List<Uuid> routerIds) {
    SubnetsBuilder subnetsBuilder = new SubnetsBuilder();
    subnetsBuilder.withKey(new SubnetsKey(subnetId));
    subnetsBuilder.setId(subnetId);
    subnetsBuilder.setVpnId(subnetId);
    subnetsBuilder.setExternalNetworkId(networkId);
    if (routerIds != null) {
        subnetsBuilder.setRouterIds(routerIds);
    }
    return subnetsBuilder.build();
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsBuilder)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 ArrayList (java.util.ArrayList)9 VpnMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMap)9 ExecutionException (java.util.concurrent.ExecutionException)8 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds)8 RouterIds (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIds)6 RouterIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsBuilder)6 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.router.id.name.RouterIdsKey)6 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)5 ExternalSubnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets)5 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.SubnetsKey)4 VpnMaps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.VpnMaps)4 VpnMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.VpnMapKey)4 RouterIdsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIdsKey)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 BigInteger (java.math.BigInteger)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets)3 Router (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router)3