use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnNatManager method handleSnatSettingChangeForRouter.
private void handleSnatSettingChangeForRouter(Router update) {
Uuid routerId = update.getUuid();
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
try {
Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
LOG.trace("Updating Internal subnets for Routers node: {}", routerId.getValue());
RoutersBuilder builder = null;
if (optionalRouters.isPresent()) {
builder = new RoutersBuilder(optionalRouters.get());
} else {
LOG.trace("No Routers element found for router name {}", routerId.getValue());
return;
}
builder.setEnableSnat(update.getExternalGatewayInfo().isEnableSnat());
Routers routerss = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Updating extrouters for snat change {}", routerss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
LOG.trace("Updated successfully Routers to CONFIG Datastore");
} catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Updation of snat for extrouters failed for router {}", routerId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnNatManager method addExternalNetworkToRouter.
private void addExternalNetworkToRouter(Router update) {
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
List<ExternalFixedIps> externalFixedIps = update.getExternalGatewayInfo().getExternalFixedIps();
try {
Network input = neutronvpnUtils.getNeutronNetwork(extNetId);
ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
if (providerNwType == null) {
LOG.error("Unable to get Network Provider Type for network {}", input.getUuid().getValue());
return;
}
// Add this router to the ExtRouters list
addExternalRouter(update);
// Update External Subnets for this router
updateExternalSubnetsForRouter(routerId, extNetId, externalFixedIps);
// 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();
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
if (!optionalNets.isPresent()) {
LOG.error("External Network {} not present in the NVPN datamodel", extNetId.getValue());
return;
}
NetworksBuilder builder = new NetworksBuilder(optionalNets.get());
List<Uuid> rtrList = builder.getRouterIds();
if (rtrList == null) {
rtrList = new ArrayList<>();
}
rtrList.add(routerId);
builder.setRouterIds(rtrList);
if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
builder.setVpnid(extNetId);
}
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Updating externalnetworks {}", networkss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
LOG.trace("Updated externalnetworks successfully to CONFIG Datastore");
// get vpn external form this network external to setup vpnInternet for ipv6
Uuid vpnExternal = neutronvpnUtils.getVpnForNetwork(extNetId);
if (vpnExternal == null) {
LOG.debug("addExternalNetworkToRouter : no vpnExternal for Network {}", extNetId);
}
LOG.debug("addExternalNetworkToRouter : the vpnExternal {}", vpnExternal);
// get subnetmap associate to the router, any subnetmap "external" could be existing
List<Subnetmap> snList = neutronvpnUtils.getNeutronRouterSubnetMaps(routerId);
LOG.debug("addExternalNetworkToRouter : the vpnExternal {} subnetmap to be set with vpnInternet {}", vpnExternal, snList);
for (Subnetmap sn : snList) {
if (sn.getInternetVpnId() == null) {
continue;
}
IpVersionChoice ipVers = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
if (ipVers == IpVersionChoice.IPV6) {
LOG.debug("addExternalNetworkToRouter : setup vpnInternet IPv6 for vpnExternal {} subnetmap {}", vpnExternal, sn);
nvpnManager.updateVpnInternetForSubnet(sn, vpnExternal, true);
}
}
} catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Creation of externalnetworks failed for {}", extNetId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnNatManager method handleSubnetsForExternalRouter.
public void handleSubnetsForExternalRouter(Uuid routerId) {
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
try {
Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
LOG.trace("Updating Internal subnets for Routers node: {}", routerId.getValue());
RoutersBuilder builder = null;
if (optionalRouters.isPresent()) {
builder = new RoutersBuilder(optionalRouters.get());
} else {
LOG.debug("No Routers element found for router {}", routerId.getValue());
return;
}
List<Uuid> subList = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
builder.setSubnetIds(subList);
Routers routerss = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Updating extrouters {}", routerss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
LOG.trace("Updated successfully Routers to CONFIG Datastore");
} catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Updation of internal subnets for extrouters failed for router {}", routerId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnUtils method getNeutronRouter.
protected Router getNeutronRouter(Uuid routerId) {
Router router = routerMap.get(routerId);
if (router != null) {
return router;
}
InstanceIdentifier<Router> inst = InstanceIdentifier.create(Neutron.class).child(Routers.class).child(Router.class, new RouterKey(routerId));
Optional<Router> rtr = read(LogicalDatastoreType.CONFIGURATION, inst);
if (rtr.isPresent()) {
router = rtr.get();
}
return router;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.
the class NeutronvpnUtils method getVpnForRouter.
// @param external vpn - true if external vpn being fetched, false for internal vpn
protected Uuid getVpnForRouter(Uuid routerId, Boolean externalVpn) {
if (routerId == null) {
return null;
}
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = read(LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
for (VpnMap vpnMap : allMaps) {
if (routerId.equals(vpnMap.getRouterId())) {
if (externalVpn) {
if (!routerId.equals(vpnMap.getVpnId())) {
return vpnMap.getVpnId();
}
} else {
if (routerId.equals(vpnMap.getVpnId())) {
return vpnMap.getVpnId();
}
}
}
}
}
LOG.debug("getVpnForRouter: Failed for router {} as no VPN present in VPNMaps DS", routerId.getValue());
return null;
}
Aggregations