use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnManager method associateRouterToVpn.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
updateVpnMaps(vpnId, null, routerId, null, null);
LOG.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
List<Uuid> routerSubnets = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
for (Uuid subnetId : routerSubnets) {
Subnetmap sn = updateVpnForSubnet(routerId, vpnId, subnetId, true);
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToAdd(sn, vpnId)) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp()), true);
}
}
try {
checkAndPublishRouterAssociatedtoVpnNotification(routerId, vpnId);
LOG.debug("notification upon association of router {} to VPN {} published", routerId.getValue(), vpnId.getValue());
} catch (Exception e) {
LOG.error("publishing of notification upon association of router {} to VPN {} failed : ", routerId.getValue(), vpnId.getValue(), e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnManager method checkAndPublishRouterAssociatedtoVpnNotification.
private void checkAndPublishRouterAssociatedtoVpnNotification(Uuid routerId, Uuid vpnId) throws InterruptedException {
RouterAssociatedToVpn routerAssociatedToVpn = new RouterAssociatedToVpnBuilder().setRouterId(routerId).setVpnId(vpnId).build();
LOG.info("publishing notification upon association of router to VPN");
notificationPublishService.putNotification(routerAssociatedToVpn);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnManager method handleNeutronRouterDeleted.
protected void handleNeutronRouterDeleted(Uuid routerId, List<Uuid> routerSubnetIds) {
// check if the router is associated to some VPN
Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
Uuid internetVpnId = neutronvpnUtils.getInternetvpnUuidBoundToRouterId(routerId);
if (vpnId != null) {
// remove existing external vpn interfaces
for (Uuid subnetId : routerSubnetIds) {
removeSubnetFromVpn(vpnId, subnetId, internetVpnId);
}
clearFromVpnMaps(vpnId, routerId, null);
} else {
// remove existing internal vpn interfaces
for (Uuid subnetId : routerSubnetIds) {
removeSubnetFromVpn(routerId, subnetId, internetVpnId);
}
}
// delete entire vpnMaps node for internal VPN
deleteVpnMapsNode(routerId);
// delete vpn-instance for internal VPN
deleteVpnInstance(routerId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnManager method createPortIpAdjacencies.
protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, WriteTransaction wrtConfigTxn, Subnetmap sn, VpnInterface vpnIface) {
List<Adjacency> adjList = new ArrayList<>();
if (vpnIface != null) {
adjList = vpnIface.getAugmentation(Adjacencies.class).getAdjacency();
}
String infName = port.getUuid().getValue();
LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
for (FixedIps ip : port.getFixedIps()) {
String ipValue = String.valueOf(ip.getIpAddress().getValue());
String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
if (sn != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, sn.getSubnetIp(), false)) {
continue;
}
Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
Subnetmap snTemp = sn != null ? sn : neutronvpnUtils.getSubnetmap(ip.getSubnetId());
Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(sn.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (routerId != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
if (rtr != null && rtr.getRoutes() != null) {
List<Routes> routeList = rtr.getRoutes();
// create extraroute Adjacence for each ipValue,
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
}
return new AdjacenciesBuilder().setAdjacency(adjList).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnManager method removeFromNeutronRouterInterfacesMap.
protected void removeFromNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
synchronized (routerId.getValue().intern()) {
InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
try {
Optional<RouterInterfaces> optRouterInterfaces = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
RouterInterfaces routerInterfaces = optRouterInterfaces.get();
List<Interfaces> interfaces = routerInterfaces.getInterfaces();
if (interfaces != null && interfaces.remove(routerInterface)) {
if (interfaces.isEmpty()) {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
} else {
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)));
}
}
}
} catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Error reading the router interfaces for {}", routerInterfacesId, e);
}
}
}
Aggregations