use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.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 String networkId = port.getNetworkId().getValue();
final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
if (NeutronConstants.IS_ODL_DHCP_PORT.test(port)) {
return;
}
if (!NeutronUtils.isPortVnicTypeNormal(port) && (!isPortTypeSwitchdev(port) || !isSupportedVnicTypeByHost(port, NeutronConstants.VNIC_TYPE_DIRECT))) {
for (FixedIps ip : keyFixedIpsMap.values()) {
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;
}
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
// add direct port to subnetMaps config DS
// TODO: for direct port as well, operations should be carried out per subnet based on port IP
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, 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 : keyFixedIpsMap.values()) {
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, networkId);
nvpnManager.createVpnInterface(vpnIdList, port, tx);
for (Uuid routerId : routerIds) {
nvpnManager.addToNeutronRouterInterfacesMap(routerId, port.getUuid().getValue());
}
}
});
LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortCreated: Failed for port {} with networkId {}", portName, networkId);
return Collections.singletonList(future);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.
the class NeutronExternalSubnetHandler method handleExternalSubnetAdded.
public void handleExternalSubnetAdded(Network network, Uuid subnetId, @Nullable 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.neutronvpn.rev150602.vpnmaps.vpnmap.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 && !subnets.getRouterIds().isEmpty()) {
routerIds = new ArrayList<>(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.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.
the class NeutronvpnNatManager method updateExternalSubnet.
public void updateExternalSubnet(Uuid networkId, Uuid subnetId, @Nullable 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.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds in project netvirt by opendaylight.
the class NeutronvpnNatManager method createSubnets.
private static Subnets createSubnets(Uuid subnetId, Uuid networkId, @Nullable List<Uuid> routerIds) {
SubnetsBuilder subnetsBuilder = new SubnetsBuilder();
subnetsBuilder.withKey(new SubnetsKey(subnetId));
subnetsBuilder.setId(subnetId);
subnetsBuilder.setVpnId(subnetId);
subnetsBuilder.setExternalNetworkId(networkId);
if (routerIds != null) {
subnetsBuilder.setRouterIds(routerIds);
}
return subnetsBuilder.build();
}
Aggregations