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 addRouterIdToExternalSubnet.
public void addRouterIdToExternalSubnet(Uuid networkId, Uuid subnetId, Uuid routerId) {
Optional<Subnets> optionalExternalSubnets = neutronvpnUtils.getOptionalExternalSubnets(subnetId);
if (optionalExternalSubnets.isPresent()) {
Subnets subnets = optionalExternalSubnets.get();
List<Uuid> routerIds;
if (subnets.getRouterIds() != null) {
routerIds = subnets.getRouterIds();
} else {
routerIds = new ArrayList<>();
}
if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(networkId) && !routerIds.contains(routerId)) {
LOG.debug("Will add routerID {} for external subnet {}.", routerId, subnetId);
routerIds.add(routerId);
updateExternalSubnet(networkId, subnetId, routerIds);
}
}
}
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 createSubnets.
private Subnets createSubnets(Uuid subnetId, Uuid networkId, List<Uuid> routerIds) {
SubnetsBuilder subnetsBuilder = new SubnetsBuilder();
subnetsBuilder.setKey(new SubnetsKey(subnetId));
subnetsBuilder.setId(subnetId);
subnetsBuilder.setVpnId(subnetId);
subnetsBuilder.setExternalNetworkId(networkId);
if (routerIds != null) {
subnetsBuilder.setRouterIds(routerIds);
}
return subnetsBuilder.build();
}
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 updateExternalSubnet.
public void updateExternalSubnet(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("Updating external subnet {}", newExternalSubnets);
SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetsIdentifier, newExternalSubnets);
} catch (TransactionCommitFailedException ex) {
LOG.error("Update 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 NeutronExternalSubnetHandler method handleExternalSubnetAdded.
public void handleExternalSubnetAdded(Network network, Uuid subnetId, List<Uuid> routerIds) {
Uuid networkId = network.getUuid();
if (NeutronvpnUtils.getIsExternal(network) && NeutronvpnUtils.isFlatOrVlanNetwork(network)) {
LOG.info("Added external subnet {} part of external network {} will create NAT external subnet", subnetId.getValue(), networkId.getValue());
nvpnNatManager.updateOrAddExternalSubnet(networkId, subnetId, routerIds);
nvpnManager.updateSubnetNode(subnetId, null, /* routerId */
subnetId, null);
nvpnManager.createVpnInstanceForSubnet(subnetId);
}
}
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 handleNeutronPortCreated.
private void handleNeutronPortCreated(final Port port) {
final String portName = port.getUuid().getValue();
final Uuid portId = port.getUuid();
final List<FixedIps> portIpAddrsList = port.getFixedIps();
if (NeutronConstants.IS_ODL_DHCP_PORT.test(port)) {
return;
}
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
// add direct port to subnetMaps config DS
if (!(NeutronUtils.isPortVnicTypeNormal(port) || (isPortTypeSwitchdev(port) && isSupportedVnicTypeByHost(port, NeutronConstants.VNIC_TYPE_DIRECT)))) {
for (FixedIps ip : portIpAddrsList) {
nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), null, portId);
}
LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "OF Port interfaces are not created", portName);
return Collections.emptyList();
}
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.info("Of-port-interface creation for port {}", portName);
// Create of-port interface for this neutron port
String portInterfaceName = createOfPortInterface(port, tx);
LOG.debug("Creating ELAN Interface for port {}", portName);
createElanInterface(port, portInterfaceName, tx);
Set<Uuid> vpnIdList = new HashSet<>();
Set<Uuid> routerIds = new HashSet<>();
for (FixedIps ip : portIpAddrsList) {
Subnetmap subnetMap = nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), portId, null);
if (subnetMap != null && subnetMap.getInternetVpnId() != null) {
if (!vpnIdList.contains(subnetMap.getInternetVpnId())) {
vpnIdList.add(subnetMap.getInternetVpnId());
}
}
if (subnetMap != null && 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
Uuid vpnId = subnetMap.getVpnId();
if (vpnId != null) {
vpnIdList.add(vpnId);
}
}
if (subnetMap != null && subnetMap.getRouterId() != null) {
routerIds.add(subnetMap.getRouterId());
}
}
if (!vpnIdList.isEmpty()) {
// create new vpn-interface for neutron port
LOG.debug("handleNeutronPortCreated: Adding VPN Interface for port {} from network {}", portName, port.getNetworkId().toString());
nvpnManager.createVpnInterface(vpnIdList, port, tx);
if (!routerIds.isEmpty()) {
for (Uuid routerId : routerIds) {
nvpnManager.addToNeutronRouterInterfacesMap(routerId, port.getUuid().getValue());
}
}
}
}));
});
}
Aggregations