use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap in project netvirt by opendaylight.
the class NeutronvpnUtils method getNeutronRouterSubnetMaps.
/**
*This method return the list of Subnetmap associated to the router or a empty list if any.
* @param routerId the Uuid of router for which subnetmap is find out
* @return a list of Subnetmap associated to the router. it could be empty if any
*/
protected List<Subnetmap> getNeutronRouterSubnetMaps(Uuid routerId) {
List<Subnetmap> subnetIdList = new ArrayList<>();
Optional<Subnetmaps> subnetMaps = read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Subnetmaps.class).build());
if (subnetMaps.isPresent() && subnetMaps.get().getSubnetmap() != null) {
for (Subnetmap subnetmap : subnetMaps.get().getSubnetmap()) {
if (routerId.equals(subnetmap.getRouterId())) {
subnetIdList.add(subnetmap);
}
}
}
return subnetIdList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap in project netvirt by opendaylight.
the class NeutronvpnUtils method getInternetvpnUuidBoundToSubnetRouter.
/**
* This method get Uuid of internet vpn if existing one bound to the same router of the subnetUuid arg.
* Explanation: If the subnet (of arg subnetUuid) have a router bound and this router have an
* externalVpn (vpn on externalProvider network) then <b>its Uuid</b> will be returned.
* @param subnetUuid Uuid of subnet where you are finding a link to an external network
* @return Uuid of externalVpn or null if it is not found
*/
public Uuid getInternetvpnUuidBoundToSubnetRouter(@Nonnull Uuid subnetUuid) {
Subnetmap subnetmap = getSubnetmap(subnetUuid);
Uuid routerUuid = subnetmap.getRouterId();
LOG.debug("getInternetvpnUuidBoundToSubnetRouter for subnetUuid {}", subnetUuid.getValue());
if (routerUuid == null) {
return null;
}
Uuid externalNetworkUuid = getExternalNetworkUuidAttachedFromRouterUuid(routerUuid);
return externalNetworkUuid != null ? getVpnForNetwork(externalNetworkUuid) : null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap in project netvirt by opendaylight.
the class NeutronvpnUtils method getSubnetsforVpn.
protected List<Uuid> getSubnetsforVpn(Uuid vpnid) {
List<Uuid> subnets = new ArrayList<>();
// read subnetmaps
InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build();
Optional<Subnetmaps> subnetmaps = read(LogicalDatastoreType.CONFIGURATION, subnetmapsid);
if (subnetmaps.isPresent() && subnetmaps.get().getSubnetmap() != null) {
List<Subnetmap> subnetMapList = subnetmaps.get().getSubnetmap();
for (Subnetmap candidateSubnetMap : subnetMapList) {
if (candidateSubnetMap.getVpnId() != null && candidateSubnetMap.getVpnId().equals(vpnid)) {
subnets.add(candidateSubnetMap.getId());
}
}
}
return subnets;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap in project netvirt by opendaylight.
the class NeutronvpnUtils method shouldVpnHandleIpVersionChangeToRemove.
public boolean shouldVpnHandleIpVersionChangeToRemove(Subnetmap sm, Uuid vpnId) {
if (sm == null) {
return false;
}
InstanceIdentifier<Subnetmaps> subnetMapsId = InstanceIdentifier.builder(Subnetmaps.class).build();
Optional<Subnetmaps> allSubnetMaps = read(LogicalDatastoreType.CONFIGURATION, subnetMapsId);
// calculate and store in list IpVersion for each subnetMap, belonging to current VpnInstance
List<IpVersionChoice> snIpVersions = new ArrayList<>();
for (Subnetmap snMap : allSubnetMaps.get().getSubnetmap()) {
if (snMap.getId().equals(sm.getId())) {
continue;
}
if (snMap.getVpnId() != null && snMap.getVpnId().equals(vpnId)) {
snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
}
if (snMap.getInternetVpnId() != null && snMap.getInternetVpnId().equals(vpnId)) {
snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
}
}
IpVersionChoice ipVersion = getIpVersionFromString(sm.getSubnetIp());
if (!snIpVersions.contains(ipVersion)) {
return true;
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap 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;
});
}
Aggregations