use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnInternetForSubnet.
protected void updateVpnInternetForSubnet(Subnetmap sm, Uuid vpn, boolean isBeingAssociated) {
LOG.debug("updateVpnInternetForSubnet: {} subnet {} with BGPVPN Internet {} ", isBeingAssociated ? "associating" : "dissociating", sm.getSubnetIp(), vpn.getValue());
Uuid internalVpnId = sm.getVpnId();
if (internalVpnId == null) {
LOG.error("updateVpnInternetForSubnet: can not find Internal or BGPVPN Id for subnet {}, bailing out", sm.getId().getValue());
return;
}
if (isBeingAssociated) {
updateSubnetNode(sm.getId(), null, sm.getVpnId(), vpn);
} else {
updateSubnetNode(sm.getId(), null, sm.getVpnId(), null);
}
jobCoordinator.enqueueJob("VPN-" + vpn.getValue(), () -> singletonList(managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(wrtConfigTxn -> {
if (isBeingAssociated) {
updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), true, true, wrtConfigTxn);
} else {
removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(sm.getRouterInterfacePortId()), wrtConfigTxn, sm);
}
})));
// Check for ports on this subnet and update association of
// corresponding vpn-interfaces to internet vpn
List<Uuid> portList = sm.getPortList();
if (portList != null) {
for (Uuid port : portList) {
LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (isBeingAssociated) {
updateVpnInterface(vpn, null, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, wrtConfigTxn);
} else {
removeVpnFromVpnInterface(vpn, neutronvpnUtils.getNeutronPort(port), wrtConfigTxn, sm);
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.
the class NeutronvpnManager method removeSubnetFromVpn.
protected void removeSubnetFromVpn(final Uuid vpnId, Uuid subnet, Uuid internetVpnId) {
Preconditions.checkArgument(vpnId != null || internetVpnId != null, "removeSubnetFromVpn: at least one VPN must be not null");
LOG.debug("Removing subnet {} from vpn {}/{}", subnet.getValue(), vpnId, internetVpnId);
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnet);
if (sn == null) {
LOG.error("removeSubnetFromVpn: Subnetmap for subnet {} not found", subnet.getValue());
return;
}
VpnMap vpnMap = null;
VpnInstance vpnInstance = null;
if (vpnId != null) {
vpnMap = neutronvpnUtils.getVpnMap(vpnId);
if (vpnMap == null) {
LOG.error("No vpnMap for vpnId {}, cannot remove subnet {} from VPN", vpnId.getValue(), subnet.getValue());
return;
}
vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
}
if (internetVpnId == null) {
internetVpnId = sn.getInternetVpnId();
}
if (internetVpnId != null) {
vpnMap = neutronvpnUtils.getVpnMap(internetVpnId);
if (vpnMap == null) {
LOG.error("No vpnMap for vpnId {}, cannot remove subnet {}" + " from Internet VPN", internetVpnId.getValue(), subnet.getValue());
return;
}
}
if (vpnInstance != null && isVpnOfTypeL2(vpnInstance)) {
neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.DELETE);
}
boolean subnetVpnAssociation = false;
if (vpnId != null && sn.getVpnId() != null && sn.getVpnId().getValue().equals(vpnId.getValue())) {
subnetVpnAssociation = true;
} else if (internetVpnId != null && sn.getInternetVpnId() != null && sn.getInternetVpnId().getValue().matches(internetVpnId.getValue())) {
subnetVpnAssociation = true;
}
if (subnetVpnAssociation == false) {
LOG.error("Removing subnet : Subnetmap is not in VPN {}/{}, owns {} and {}", vpnId, internetVpnId, sn.getVpnId(), sn.getInternetVpnId());
return;
}
// Check if there are ports on this subnet; remove corresponding vpn-interfaces
List<Uuid> portList = sn.getPortList();
final Uuid internetId = internetVpnId;
if (portList != null) {
for (final Uuid portId : portList) {
LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp(), portId.getValue());
final Port port = neutronvpnUtils.getNeutronPort(portId);
jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (port != null) {
withdrawPortIpFromVpnIface(vpnId, internetId, port, sn, wrtConfigTxn);
} else {
LOG.warn("Cannot proceed with withdrawPortIpFromVpnIface for port {} in subnet {} since " + "port is absent in Neutron config DS", portId.getValue(), subnet.getValue());
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
// update subnet-vpn association
removeFromSubnetNode(subnet, null, null, vpnId, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.
the class NeutronNetworkChangeListener method add.
@Override
protected void add(InstanceIdentifier<Network> identifier, Network input) {
LOG.trace("Adding Network : key: {}, value={}", identifier, input);
String networkId = input.getUuid().getValue();
if (!NeutronvpnUtils.isNetworkTypeSupported(input)) {
LOG.error("Neutronvpn doesn't support the provider type for given network {}", networkId);
return;
}
Class<? extends NetworkTypeBase> networkType = input.getAugmentation(NetworkProviderExtension.class).getNetworkType();
if (NeutronvpnUtils.isVlanOrVxlanNetwork(networkType) && NeutronUtils.getSegmentationIdFromNeutronNetwork(input, networkType) == null) {
LOG.error("Segmentation ID is null for configured provider network {} of type {}. Abandoning any further " + "processing for the network", input.getUuid().getValue(), networkType);
return;
}
neutronvpnUtils.addToNetworkCache(input);
// Create ELAN instance for this network
ElanInstance elanInstance = createElanInstance(input);
if (NeutronvpnUtils.getIsExternal(input)) {
// Create ELAN interface and IETF interfaces for the physical network
elanService.createExternalElanNetwork(elanInstance);
ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
if (providerNwType == null) {
LOG.error("Unable to get Network Provider Type for network {}", networkId);
return;
}
LOG.trace("External Network Provider Type for network {} is {}", networkId, providerNwType.getName());
nvpnNatManager.addExternalNetwork(input);
if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
nvpnManager.createL3InternalVpn(input.getUuid(), null, null, null, null, null, null, null);
nvpnManager.createExternalVpnInterfaces(input.getUuid());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleNeutronPortDeleted.
private void handleNeutronPortDeleted(final Port port) {
final String portName = port.getUuid().getValue();
final Uuid portId = port.getUuid();
final List<FixedIps> portIpsList = port.getFixedIps();
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (!(NeutronUtils.isPortVnicTypeNormal(port) || isPortTypeSwitchdev(port))) {
for (FixedIps ip : portIpsList) {
// remove direct port from subnetMaps config DS
nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
}
LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
return futures;
}
Uuid vpnId = null;
Set<Uuid> routerIds = new HashSet<>();
Uuid internetVpnId = null;
for (FixedIps ip : portIpsList) {
Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
if (subnetMap == null) {
continue;
}
if (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
vpnId = subnetMap.getVpnId();
}
if (subnetMap.getRouterId() != null) {
routerIds.add(subnetMap.getRouterId());
}
internetVpnId = subnetMap.getInternetVpnId();
}
if (vpnId != null || internetVpnId != null) {
// remove vpn-interface for this neutron port
LOG.debug("removing VPN Interface for port {}", portName);
if (!routerIds.isEmpty()) {
for (Uuid routerId : routerIds) {
nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
}
}
nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
wrtConfigTxn);
}
// Remove of-port interface for this neutron port
// ELAN interface is also implicitly deleted as part of this operation
LOG.debug("Of-port-interface removal for port {}", portName);
deleteOfPortInterface(port, wrtConfigTxn);
// dissociate fixedIP from floatingIP if associated
nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
futures.add(wrtConfigTxn.submit());
return futures;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces 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