use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps in project netvirt by opendaylight.
the class NeutronvpnNatManager method handleExternalNetworkForRouter.
public void handleExternalNetworkForRouter(Router original, Router update) {
Uuid routerId = update.getUuid();
Uuid origExtNetId = null;
Uuid updExtNetId = null;
List<ExternalFixedIps> origExtFixedIps;
LOG.trace("handleExternalNetwork for router {}", routerId);
int extNetChanged = externalNetworkChanged(original, update);
if (extNetChanged != EXTERNAL_NO_CHANGE) {
if (extNetChanged == EXTERNAL_ADDED) {
updExtNetId = update.getExternalGatewayInfo().getExternalNetworkId();
LOG.trace("External Network {} addition detected for router {}", updExtNetId.getValue(), routerId.getValue());
addExternalNetworkToRouter(update);
return;
}
if (extNetChanged == EXTERNAL_REMOVED) {
origExtNetId = original.getExternalGatewayInfo().getExternalNetworkId();
origExtFixedIps = original.getExternalGatewayInfo().getExternalFixedIps();
LOG.trace("External Network removal detected for router {}", routerId.getValue());
removeExternalNetworkFromRouter(origExtNetId, update, origExtFixedIps);
// gateway mac unset handled as part of gateway clear deleting top-level routers node
return;
}
origExtNetId = original.getExternalGatewayInfo().getExternalNetworkId();
origExtFixedIps = original.getExternalGatewayInfo().getExternalFixedIps();
updExtNetId = update.getExternalGatewayInfo().getExternalNetworkId();
LOG.trace("External Network changed from {} to {} for router {}", origExtNetId.getValue(), updExtNetId.getValue(), routerId.getValue());
removeExternalNetworkFromRouter(origExtNetId, update, origExtFixedIps);
addExternalNetworkToRouter(update);
return;
}
if (snatSettingChanged(original, update)) {
LOG.trace("SNAT settings on gateway changed for router {}", routerId.getValue());
handleSnatSettingChangeForRouter(update);
}
if (externalFixedIpsChanged(original, update)) {
LOG.trace("External Fixed IPs changed for router {}", routerId.getValue());
handleExternalFixedIpsForRouter(update);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps in project netvirt by opendaylight.
the class NeutronvpnNatManager method addExternalRouter.
public void addExternalRouter(Router update) {
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
Uuid gatewayPortId = update.getGatewayPortId();
// Create and add Routers object for this Router to the ExtRouters list
// Create a Routers object
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
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;
}
Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
LOG.trace("Creating/Updating a new Routers node: {}", routerId.getValue());
RoutersBuilder builder = null;
if (optionalRouters.isPresent()) {
builder = new RoutersBuilder(optionalRouters.get());
} else {
builder = new RoutersBuilder().setKey(new RoutersKey(routerId.getValue()));
}
builder.setRouterName(routerId.getValue());
builder.setNetworkId(extNetId);
builder.setEnableSnat(update.getExternalGatewayInfo().isEnableSnat());
ArrayList<ExternalIps> externalIps = new ArrayList<>();
for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().getExternalFixedIps()) {
addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
}
builder.setExternalIps(externalIps);
if (gatewayPortId != null) {
LOG.trace("Setting/Updating gateway Mac for router {}", routerId.getValue());
Port port = neutronvpnUtils.getNeutronPort(gatewayPortId);
if (port != null && port.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_GATEWAY_INF)) {
builder.setExtGwMacAddress(port.getMacAddress().getValue());
}
}
List<Uuid> subList = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
builder.setSubnetIds(subList);
Routers routers = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Creating extrouters {}", routers);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, builder.build());
LOG.trace("Wrote successfully Routers to CONFIG Datastore");
} catch (ReadFailedException | TransactionCommitFailedException ex) {
LOG.error("Creation of extrouters failed for router {} failed", routerId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps in project netvirt by opendaylight.
the class NeutronvpnNatManager method updateExternalSubnetsForRouter.
private void updateExternalSubnetsForRouter(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
LOG.debug("Updating external subnets for router {} for external network ID {}", routerId, externalNetworkId);
Set<Uuid> subnetsUuidsSet = getExternalSubnetsUuidsSetForFixedIps(externalFixedIps);
for (Uuid subnetId : subnetsUuidsSet) {
addRouterIdToExternalSubnet(externalNetworkId, subnetId, routerId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps 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.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps 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);
}
Aggregations