use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpn.instance.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.neutronvpn.rev150602.vpn.instance.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.neutronvpn.rev150602.vpn.instance.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.neutronvpn.rev150602.vpn.instance.RouterIds in project netvirt by opendaylight.
the class VpnInterfaceManager method processExternalVpnInterface.
private void processExternalVpnInterface(String interfaceName, String vpnName, Uint64 dpId, int lportTag, 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(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();
Uint64 primarySwitch = vpnUtil.getPrimarySwitchForRouter(routerName);
if (Objects.equals(primarySwitch, dpId)) {
Routers router = vpnUtil.getExternalRouter(routerName);
if (router != null) {
if (addOrRemove == NwConstants.ADD_FLOW) {
vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(new ArrayList<>(router.nonnullExternalIps().values())), router.getExtGwMacAddress(), dpId, interfaceName, lportTag);
} else {
vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(new ArrayList<>(router.nonnullExternalIps().values())), 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.neutronvpn.rev150602.vpn.instance.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 Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
if (!NeutronUtils.isPortVnicTypeNormal(port) && !isPortTypeSwitchdev(port)) {
for (FixedIps ip : keyFixedIpsMap.values()) {
// remove direct port from subnetMaps config DS
// TODO: for direct port as well, operations should be carried out per subnet based on port IP
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;
}
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
Uuid vpnId = null;
Set<Uuid> routerIds = new HashSet<>();
Uuid internetVpnId = null;
for (FixedIps ip : keyFixedIpsMap.values()) {
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 (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(port.getDeviceOwner()) || NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(port.getDeviceOwner())) {
String ipAddress = ip.getIpAddress().stringValue();
if (vpnId != null) {
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipAddress, confTx);
}
if (internetVpnId != null) {
neutronvpnUtils.removeVpnPortFixedIpToPort(internetVpnId.getValue(), ipAddress, confTx);
}
}
}
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 */
confTx);
}
// 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, confTx);
// dissociate fixedIP from floatingIP if associated
nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
});
LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortDeleted: Failed to update interface {} with networkId", portName, port.getNetworkId().getValue());
return Collections.singletonList(future);
});
}
Aggregations