use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronvpnManager method removeExternalVpnInterfaces.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void removeExternalVpnInterfaces(Uuid extNetId) {
Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
LOG.error("No external ports attached for external network {}", extNetId.getValue());
return;
}
try {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
for (String elanInterface : extElanInterfaces) {
InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(elanInterface);
LOG.info("Removing vpn interface {}", elanInterface);
wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
}
wrtConfigTxn.submit();
} catch (Exception ex) {
LOG.error("Removal of vpninterfaces {} failed", extElanInterfaces, ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworksFromVpn.
/**
* Parses and disassociates networks list from given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networks List list of network Ids (Uuid), which will be disassociated.
* @return list of formatted strings with detailed error messages.
*/
@Nonnull
protected List<String> dissociateNetworksFromVpn(@Nonnull Uuid vpnId, @Nonnull List<Uuid> networks) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
if (networks.isEmpty()) {
LOG.error("dissociateNetworksFromVpn: Failed as networks list is empty");
failedNwList.add(String.format("Failed to disassociate networks from VPN %s as networks list is empty", vpnId.getValue()));
return failedNwList;
}
for (Uuid nw : networks) {
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("dissociateNetworksFromVpn: Network {} not found in ConfigDS");
failedNwList.add(String.format("Failed to disassociate network %s as is not found in ConfigDS", nw.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId == null) {
LOG.error("dissociateNetworksFromVpn: Network {} is not associated to any VPN", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not associated to any VPN", nw.getValue()));
continue;
}
if (!vpnId.equals(networkVpnId)) {
LOG.error("dissociateNetworksFromVpn: Network {} is associated to another VPN {} instead of given {}", nw.getValue(), networkVpnId.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as it is associated to another " + "vpn %s instead of given %s", nw.getValue(), networkVpnId.getValue(), vpnId.getValue()));
continue;
}
if (neutronvpnUtils.getIsExternal(network)) {
if (disassociateExtNetworkFromVpn(vpnId, network)) {
passedNwList.add(nw);
continue;
} else {
LOG.error("dissociateNetworksFromVpn: Failed to withdraw Provider Network {} from VPN {}", nw.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to withdraw Provider Network %s from VPN %s", nw.getValue(), vpnId.getValue()));
continue;
}
}
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
for (Uuid subnet : networkSubnets) {
Subnetmap sm = neutronvpnUtils.getSubnetmap(subnet);
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sm, vpnId)) {
IpVersionChoice ipVersionsToRemove = IpVersionChoice.UNDEFINED;
IpVersionChoice ipVersion = neutronvpnUtils.getIpVersionFromString(sm.getSubnetIp());
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersionsToRemove.addVersion(ipVersion), false);
}
LOG.debug("dissociateNetworksFromVpn: Withdraw subnet {} from VPN {}", subnet.getValue(), vpnId.getValue());
removeSubnetFromVpn(vpnId, subnet, null);
passedNwList.add(nw);
}
}
LOG.info("dissociateNetworksFromVpn: Withdraw networks list {} from VPN {}", networks.toString(), vpnId.getValue());
clearFromVpnMaps(vpnId, null, new ArrayList<Uuid>(passedNwList));
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronExternalSubnetHandler method handleExternalSubnetRemoved.
public void handleExternalSubnetRemoved(Network network, Uuid subnetId) {
Uuid networkId = network.getUuid();
if (NeutronvpnUtils.getIsExternal(network) && NeutronvpnUtils.isFlatOrVlanNetwork(network)) {
LOG.info("Removed subnet {} part of external network {} will remove NAT external subnet", subnetId.getValue(), networkId.getValue());
nvpnManager.removeVpnInstanceForSubnet(subnetId);
nvpnNatManager.removeExternalSubnet(subnetId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network 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.neutron.networks.rev150712.networks.attributes.networks.Network in project netvirt by opendaylight.
the class NeutronNetworkChangeListener method createElanInstance.
private ElanInstance createElanInstance(Network input) {
String elanInstanceName = input.getUuid().getValue();
InstanceIdentifier<ElanInstance> id = createElanInstanceIdentifier(elanInstanceName);
Optional<ElanInstance> existingElanInstance = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (existingElanInstance.isPresent()) {
return existingElanInstance.get();
}
Class<? extends SegmentTypeBase> segmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(input);
String segmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(input);
String physicalNetworkName = NeutronvpnUtils.getPhysicalNetworkName(input);
long elanTag = elanService.retrieveNewElanTag(elanInstanceName);
ElanInstance elanInstance = createElanInstanceBuilder(elanInstanceName, segmentType, segmentationId, physicalNetworkName, input).setElanTag(elanTag).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, elanInstance);
LOG.debug("ELANInstance {} created with elan tag {} and segmentation ID {}", elanInstanceName, elanTag, segmentationId);
return elanInstance;
}
Aggregations