use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks 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.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class NeutronvpnNatManager method addExternalNetwork.
public void addExternalNetwork(Network net) {
Uuid extNetId = net.getUuid();
// Create and add Networks object for this External Network to the ExternalNetworks list
InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
try {
LOG.trace(" Creating/Updating a new Networks node {}", extNetId.getValue());
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
if (optionalNets.isPresent()) {
LOG.error("External Network {} already detected to be present", extNetId.getValue());
return;
}
ProviderTypes provType = NeutronvpnUtils.getProviderNetworkType(net);
if (provType == null) {
LOG.error("Unable to get Network Provider Type for network {}", extNetId);
return;
}
NetworksBuilder builder = null;
builder = new NetworksBuilder().setKey(new NetworksKey(extNetId)).setId(extNetId);
builder.setVpnid(neutronvpnUtils.getVpnForNetwork(extNetId));
builder.setRouterIds(new ArrayList<>());
builder.setProviderNetworkType(provType);
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Creating externalnetworks {}", networkss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
LOG.trace("Wrote externalnetwork successfully to CONFIG Datastore");
} catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Creation of External Network {} failed", extNetId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class NeutronvpnUtils method getRouterIdfromVpnInstance.
public String getRouterIdfromVpnInstance(String vpnName) {
// returns only router, attached to IPv4 networks
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class, new VpnMapKey(new Uuid(vpnName))).build();
Optional<VpnMap> optionalVpnMap = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
if (!optionalVpnMap.isPresent()) {
LOG.error("getRouterIdfromVpnInstance : Router not found for vpn : {}", vpnName);
return null;
}
Uuid routerId = optionalVpnMap.get().getRouterId();
if (routerId != null) {
return routerId.getValue();
}
LOG.info("getRouterIdfromVpnInstance : Router not found for vpn : {}", vpnName);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class NeutronRouterChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Router> identifier, Router input) {
LOG.trace("Removing router : key: {}, value={}", identifier, input);
Uuid routerId = input.getUuid();
/*External Router and networks is handled before deleting the internal VPN, as there is dependency
on vpn operational data to release Lport tag in case of L3VPN over VxLAN*/
if (input.getExternalGatewayInfo() != null) {
Uuid extNetId = input.getExternalGatewayInfo().getExternalNetworkId();
List<ExternalFixedIps> externalFixedIps = input.getExternalGatewayInfo().getExternalFixedIps();
nvpnNatManager.removeExternalNetworkFromRouter(extNetId, input, externalFixedIps);
}
// NOTE: Pass an empty routerSubnetIds list, as router interfaces
// will be removed from VPN by invocations from NeutronPortChangeListener
List<Uuid> routerSubnetIds = new ArrayList<>();
nvpnManager.handleNeutronRouterDeleted(routerId, routerSubnetIds);
neutronvpnUtils.removeFromRouterCache(input);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class TunnelStateChangeListener method updateTunnelToUnderlayNetworkOperDs.
private void updateTunnelToUnderlayNetworkOperDs(StateTunnelList tunnelState, boolean isAdded) {
BigInteger srcDpId = getTepDpnId(tunnelState.getSrcInfo());
BigInteger dstDpId = getTepDpnId(tunnelState.getDstInfo());
String tunnelInterfaceName = tunnelState.getTunnelInterfaceName();
if (BigInteger.ZERO.equals(srcDpId) || BigInteger.ZERO.equals(dstDpId)) {
LOG.warn("No valid DPN found for tunnel {}", tunnelInterfaceName);
return;
}
IpAddress tunnelIp = getTunnelIp(tunnelState);
if (tunnelIp == null) {
LOG.warn("No tunnel ip found for tunnel {} DPN {}", tunnelInterfaceName, srcDpId);
return;
}
String underlayNetwork = policyServiceUtil.getTunnelUnderlayNetwork(srcDpId, tunnelIp);
if (underlayNetwork == null) {
LOG.debug("No underlay networks defined for tunnel {} DPN {}", tunnelInterfaceName, srcDpId);
return;
}
LOG.info("Handle tunnel state update for interface {} on DPN {} underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
policyServiceUtil.updateTunnelInterfaceForUnderlayNetwork(underlayNetwork, srcDpId, dstDpId, tunnelInterfaceName, isAdded);
}
Aggregations