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);
}
}
}
}
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;
}
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);
}
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);
}
}
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;
});
}
Aggregations