use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronvpnManager method removeVpnFromVpnInterface.
protected void removeVpnFromVpnInterface(Uuid vpnId, Port port, WriteTransaction writeConfigTxn, Subnetmap sm) {
if (vpnId == null || port == null) {
return;
}
String infName = port.getUuid().getValue();
InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
try {
Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
if (optionalVpnInterface.isPresent()) {
List<VpnInstanceNames> listVpn = optionalVpnInterface.get().getVpnInstanceNames();
if (listVpn != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnId.getValue(), listVpn)) {
VpnHelper.removeVpnInterfaceVpnInstanceNamesFromList(vpnId.getValue(), listVpn);
}
VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get()).setVpnInstanceNames(listVpn);
Adjacencies adjs = vpnIfBuilder.getAugmentation(Adjacencies.class);
LOG.debug("Updating vpn interface {}", infName);
List<Adjacency> adjacencyList = adjs != null ? adjs.getAdjacency() : new ArrayList<>();
Iterator<Adjacency> adjacencyIter = adjacencyList.iterator();
while (adjacencyIter.hasNext()) {
Adjacency adjacency = adjacencyIter.next();
if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
continue;
}
String mipToQuery = adjacency.getIpAddress().split("/")[0];
InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(vpnId.getValue(), mipToQuery);
Optional<LearntVpnVipToPort> optionalVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (optionalVpnVipToPort.isPresent()) {
LOG.trace("Removing adjacencies from vpninterface {} upon dissociation of router {}", infName, vpnId);
if (listVpn == null || listVpn.isEmpty()) {
adjacencyIter.remove();
}
neutronvpnUtils.removeLearntVpnVipToPort(vpnId.getValue(), mipToQuery);
LOG.trace("Entry for fixedIP {} for port {} on VPN {} removed from VpnPortFixedIPToPortData", mipToQuery, infName, vpnId.getValue());
}
}
List<FixedIps> ips = port.getFixedIps();
for (FixedIps ip : ips) {
String ipValue = String.valueOf(ip.getIpAddress().getValue());
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, writeConfigTxn);
}
if (listVpn == null || listVpn.isEmpty()) {
if (sm != null && sm.getRouterId() != null) {
removeFromNeutronRouterInterfacesMap(sm.getRouterId(), port.getUuid().getValue());
}
deleteVpnInterface(port.getUuid().getValue(), null, /* vpn-id */
writeConfigTxn);
} else {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder.build());
}
} else {
LOG.info("removeVpnFromVpnInterface: VPN Interface {} not found", infName);
}
} catch (ReadFailedException ex) {
LOG.error("Update of vpninterface {} failed", infName, ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnForSubnet.
private Subnetmap updateVpnForSubnet(Uuid oldVpnId, Uuid newVpnId, Uuid subnet, boolean isBeingAssociated) {
LOG.debug("Moving subnet {} from oldVpn {} to newVpn {} ", subnet.getValue(), oldVpnId.getValue(), newVpnId.getValue());
Uuid networkUuid = neutronvpnUtils.getSubnetmap(subnet).getNetworkId();
Network network = neutronvpnUtils.getNeutronNetwork(networkUuid);
boolean netIsExternal = NeutronvpnUtils.getIsExternal(network);
Uuid vpnExtUuid = netIsExternal ? null : neutronvpnUtils.getInternetvpnUuidBoundToSubnetRouter(subnet);
Subnetmap sn = updateSubnetNode(subnet, null, newVpnId, vpnExtUuid);
if (sn == null) {
LOG.error("Updating subnet {} with newVpn {} failed", subnet.getValue(), newVpnId.getValue());
return sn;
}
// CAUTION: Please DONOT make the router interface VPN Movement as an asynchronous commit again !
try {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()), isBeingAssociated, true, wrtConfigTxn);
wrtConfigTxn.submit().checkedGet();
} catch (TransactionCommitFailedException e) {
LOG.error("Failed to update router interface {} in subnet {} from oldVpnId {} to newVpnId {}, returning", sn.getRouterInterfacePortId().getValue(), subnet.getValue(), oldVpnId, newVpnId);
return sn;
}
// Check for ports on this subnet and update association of
// corresponding vpn-interfaces to external vpn
List<Uuid> portList = sn.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<>();
updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, wrtConfigTxn);
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
return sn;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronvpnManager method createL3InternalVpn.
public void createL3InternalVpn(Uuid vpn, String name, Uuid tenant, List<String> rd, List<String> irt, List<String> ert, Uuid router, List<Uuid> networks) {
IpVersionChoice ipVersChoices = neutronvpnUtils.getIpVersionChoicesFromRouterUuid(router);
// Update VPN Instance node
updateVpnInstanceNode(vpn, rd, irt, ert, VpnInstance.Type.L3, 0, /*l3vni*/
ipVersChoices);
// Update local vpn-subnet DS
updateVpnMaps(vpn, name, router, tenant, networks);
if (router != null) {
Uuid existingVpn = neutronvpnUtils.getVpnForRouter(router, true);
if (existingVpn != null) {
// use case when a cluster is rebooted and router add DCN is received, triggering #createL3InternalVpn
// if before reboot, router was already associated to VPN, should not proceed associating router to
// internal VPN. Adding to RouterInterfacesMap is also not needed since it's a config DS and will be
// preserved upon reboot.
// For a non-reboot case #associateRouterToInternalVPN already takes care of adding to
// RouterInterfacesMap via #createVPNInterface call.
LOG.info("Associating router to Internal VPN skipped for VPN {} due to router {} already associated " + "to external VPN {}", vpn.getValue(), router.getValue(), existingVpn.getValue());
return;
}
associateRouterToInternalVpn(vpn, router);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronBgpvpnChangeListener method update.
@Override
protected void update(InstanceIdentifier<Bgpvpn> identifier, Bgpvpn original, Bgpvpn update) {
LOG.trace("Update Bgpvpn : key: {}, value={}", identifier, update);
Uuid vpnId = update.getUuid();
if (isBgpvpnTypeL3(update.getType())) {
try {
handleVpnInstanceUpdate(original.getUuid().getValue(), original.getRouteDistinguishers(), update.getRouteDistinguishers());
} catch (UnsupportedOperationException e) {
LOG.error("Error while processing Update Bgpvpn.", e);
return;
}
List<Uuid> oldNetworks = original.getNetworks();
List<Uuid> newNetworks = update.getNetworks();
handleNetworksUpdate(vpnId, oldNetworks, newNetworks);
List<Uuid> oldRouters = original.getRouters();
List<Uuid> newRouters = update.getRouters();
handleRoutersUpdate(vpnId, oldRouters, newRouters);
} else {
LOG.warn("BGPVPN type for VPN {} is not L3", vpnId.getValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronFloatingToFixedIpMappingChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Floatingip> identifier, Floatingip input) {
LOG.trace("Neutron Floating IP deleted : key: {}, value={}", identifier, input);
IpAddress fixedIp = input.getFixedIpAddress();
if (fixedIp != null) {
// update FloatingIpPortInfo to set isFloatingIpDeleted as true to enable deletion of FloatingIpPortInfo
// map once it is used for processing in the NAT removal path
updateFloatingIpPortInfo(input.getUuid(), input.getPortId());
clearFromFloatingIpInfo(input.getRouterId().getValue(), input.getPortId().getValue(), fixedIp.getIpv4Address().getValue());
} else {
// delete FloatingIpPortInfo mapping since floating IP is deleted and no fixed IP is associated to it
removeFromFloatingIpPortInfo(input.getUuid());
}
}
Aggregations