Search in sources :

Example 46 with Subnets

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project netvirt by opendaylight.

the class NeutronvpnManager method associateRouterToInternalVpn.

protected void associateRouterToInternalVpn(Uuid vpnId, Uuid routerId) {
    List<Uuid> routerSubnets = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
    Uuid internetVpnId = neutronvpnUtils.getInternetvpnUuidBoundToRouterId(routerId);
    LOG.debug("Adding subnets to internal vpn {}", vpnId.getValue());
    for (Uuid subnet : routerSubnets) {
        IpVersionChoice version = NeutronvpnUtils.getIpVersionFromSubnet(neutronvpnUtils.getSubnetmap(subnet));
        if (version.isIpVersionChosen(IpVersionChoice.IPV4)) {
            addSubnetToVpn(vpnId, subnet, null);
        } else {
            addSubnetToVpn(vpnId, subnet, internetVpnId);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 47 with Subnets

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets 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 48 with Subnets

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project netvirt by opendaylight.

the class NeutronvpnNatManager method updateExternalSubnetsForRouter.

private void updateExternalSubnetsForRouter(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
    LOG.debug("Updating external subnets for router {} for external network ID {}", routerId, externalNetworkId);
    Set<Uuid> subnetsUuidsSet = getExternalSubnetsUuidsSetForFixedIps(externalFixedIps);
    for (Uuid subnetId : subnetsUuidsSet) {
        addRouterIdToExternalSubnet(externalNetworkId, subnetId, routerId);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 49 with Subnets

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeExternalNetworkFromRouter.

public void removeExternalNetworkFromRouter(Uuid origExtNetId, Router update, List<ExternalFixedIps> origExtFixedIps) {
    Uuid routerId = update.getUuid();
    // Remove the router to the ExtRouters list
    removeExternalRouter(update);
    // Remove router entry from floating-ip-info list
    removeRouterFromFloatingIpInfo(update, dataBroker);
    // Remove the router from External Subnets
    removeRouterFromExternalSubnets(routerId, origExtNetId, origExtFixedIps);
    // Remove the router from the ExternalNetworks list
    InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(origExtNetId)).build();
    Optional<Networks> optionalNets = null;
    try {
        optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
    } catch (ReadFailedException ex) {
        LOG.error("removeExternalNetworkFromRouter: Failed to remove provider network {} from router {}", origExtNetId.getValue(), routerId.getValue(), ex);
        return;
    }
    if (!optionalNets.isPresent()) {
        LOG.error("removeExternalNetworkFromRouter: Provider Network {} not present in the NVPN datamodel", origExtNetId.getValue());
        return;
    }
    Networks nets = optionalNets.get();
    try {
        NetworksBuilder builder = new NetworksBuilder(nets);
        List<Uuid> rtrList = builder.getRouterIds();
        if (rtrList != null) {
            rtrList.remove(routerId);
            builder.setRouterIds(rtrList);
            Networks networkss = builder.build();
            SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
            LOG.trace("removeExternalNetworkFromRouter: Remove router {} from External Networks node {}", routerId, origExtNetId.getValue());
        }
    } catch (TransactionCommitFailedException ex) {
        LOG.error("removeExternalNetworkFromRouter: Failed to remove provider network {} from router {}", origExtNetId.getValue(), routerId.getValue(), ex);
    }
    // Remove the vpnInternetId fromSubnetmap
    Network net = neutronvpnUtils.getNeutronNetwork(nets.getId());
    List<Uuid> submapIds = neutronvpnUtils.getPrivateSubnetsToExport(net);
    for (Uuid snId : submapIds) {
        Subnetmap subnetMap = neutronvpnUtils.getSubnetmap(snId);
        if ((subnetMap == null) || (subnetMap.getInternetVpnId() == null)) {
            LOG.error("removeExternalNetworkFromRouter: Can not find Subnetmap for SubnetId {} in ConfigDS", snId.getValue());
            continue;
        }
        LOG.trace("removeExternalNetworkFromRouter: Remove Internet VPN Id {} from SubnetMap {}", subnetMap.getInternetVpnId(), subnetMap.getId());
        IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetMap.getSubnetIp());
        if (ipVers == IpVersionChoice.IPV6) {
            nvpnManager.updateVpnInternetForSubnet(subnetMap, subnetMap.getInternetVpnId(), false);
            LOG.debug("removeExternalNetworkFromRouter: Withdraw IPv6 routes from VPN {}", subnetMap.getInternetVpnId());
        }
    }
}
Also used : Networks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks) ExternalNetworks(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks) NetworksKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) NetworksBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksBuilder) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 50 with Subnets

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets in project netvirt by opendaylight.

the class NeutronvpnUtils method getSubnetsforVpn.

protected List<Uuid> getSubnetsforVpn(Uuid vpnid) {
    List<Uuid> subnets = new ArrayList<>();
    // read subnetmaps
    InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build();
    Optional<Subnetmaps> subnetmaps = read(LogicalDatastoreType.CONFIGURATION, subnetmapsid);
    if (subnetmaps.isPresent() && subnetmaps.get().getSubnetmap() != null) {
        List<Subnetmap> subnetMapList = subnetmaps.get().getSubnetmap();
        for (Subnetmap candidateSubnetMap : subnetMapList) {
            if (candidateSubnetMap.getVpnId() != null && candidateSubnetMap.getVpnId().equals(vpnid)) {
                subnets.add(candidateSubnetMap.getId());
            }
        }
    }
    return subnets;
}
Also used : Subnetmaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)30 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)23 ArrayList (java.util.ArrayList)22 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)18 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)17 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)16 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)15 BigInteger (java.math.BigInteger)14 List (java.util.List)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)10 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)10 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)9 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)8 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 HashMap (java.util.HashMap)7 ExecutionException (java.util.concurrent.ExecutionException)7 Map (java.util.Map)6