use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.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);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.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());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.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;
}
Aggregations