use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronNetworkChangeListener method update.
@Override
protected void update(InstanceIdentifier<Network> identifier, Network original, Network update) {
LOG.trace("Updating Network : key: {}, original value={}, update value={}", identifier, original, update);
neutronvpnUtils.addToNetworkCache(update);
String elanInstanceName = original.getUuid().getValue();
Class<? extends SegmentTypeBase> origSegmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(original);
String origSegmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(original);
String origPhysicalNetwork = NeutronvpnUtils.getPhysicalNetworkName(original);
Class<? extends SegmentTypeBase> updateSegmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(update);
String updateSegmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(update);
String updatePhysicalNetwork = NeutronvpnUtils.getPhysicalNetworkName(update);
Boolean origExternal = NeutronvpnUtils.getIsExternal(original);
Boolean updateExternal = NeutronvpnUtils.getIsExternal(update);
Boolean origIsFlatOrVlanNetwork = NeutronvpnUtils.isFlatOrVlanNetwork(original);
Boolean updateIsFlatOrVlanNetwork = NeutronvpnUtils.isFlatOrVlanNetwork(update);
if (!Objects.equals(origSegmentType, updateSegmentType) || !Objects.equals(origSegmentationId, updateSegmentationId) || !Objects.equals(origPhysicalNetwork, updatePhysicalNetwork) || !Objects.equals(origExternal, updateExternal)) {
if (origExternal && origIsFlatOrVlanNetwork && (!updateExternal || !updateIsFlatOrVlanNetwork)) {
nvpnManager.removeExternalVpnInterfaces(original.getUuid());
nvpnManager.removeVpn(original.getUuid());
nvpnNatManager.removeExternalNetwork(original);
}
ElanInstance elanInstance = elanService.getElanInstance(elanInstanceName);
if (elanInstance != null) {
elanService.deleteExternalElanNetwork(elanInstance);
elanInstance = updateElanInstance(elanInstanceName, updateSegmentType, updateSegmentationId, updatePhysicalNetwork, update);
if (updateExternal) {
elanService.updateExternalElanNetwork(elanInstance);
}
}
if (updateExternal && updateIsFlatOrVlanNetwork && !origExternal) {
nvpnNatManager.addExternalNetwork(update);
nvpnManager.createL3InternalVpn(update.getUuid(), null, null, null, null, null, null, null);
nvpnManager.createExternalVpnInterfaces(update.getUuid());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleRouterInterfaceRemoved.
private void handleRouterInterfaceRemoved(Port routerPort) {
if (routerPort.getDeviceId() != null) {
Uuid routerId = new Uuid(routerPort.getDeviceId());
Uuid infNetworkId = routerPort.getNetworkId();
elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
if (vpnId == null) {
vpnId = routerId;
}
List<FixedIps> portIps = routerPort.getFixedIps();
boolean vpnInstanceInternetIpVersionRemoved = false;
Uuid vpnInstanceInternetUuid = null;
for (FixedIps portIP : portIps) {
// Internet VPN : flush InternetVPN first
Uuid subnetId = portIP.getSubnetId();
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
if (sn != null && sn.getInternetVpnId() != null) {
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
vpnInstanceInternetIpVersionRemoved = true;
vpnInstanceInternetUuid = sn.getInternetVpnId();
}
nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
}
}
/* Remove ping responder for router interfaces
* A router interface reference in a VPN will have to be removed before the host interface references
* for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
* is not the last entry to be removed for that subnet in the VPN.
* If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
* interface references in the vpn will already have been cleared, which will cause failures in
* cleanup of router interface flows*/
nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
null);
// update RouterInterfaces map
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
boolean vpnInstanceIpVersionRemoved = false;
IpVersionChoice vpnInstanceIpVersionToRemove = IpVersionChoice.UNDEFINED;
for (FixedIps portIP : portIps) {
Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
// router Port have either IPv4 or IPv6, never both
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
vpnInstanceIpVersionRemoved = true;
vpnInstanceIpVersionToRemove = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
}
String ipValue = String.valueOf(portIP.getIpAddress().getValue());
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, wrtConfigTxn);
// NOTE: Please donot change the order of calls to removeSubnetFromVpn and
// and updateSubnetNodeWithFixedIP
nvpnManager.removeSubnetFromVpn(vpnId, portIP.getSubnetId(), sn != null ? sn.getInternetVpnId() : null);
nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
}
nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
deleteElanInterface(routerPort.getUuid().getValue(), wrtConfigTxn);
deleteOfPortInterface(routerPort, wrtConfigTxn);
wrtConfigTxn.submit();
nvpnNatManager.handleSubnetsForExternalRouter(routerId);
if (vpnInstanceIpVersionRemoved) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), vpnInstanceIpVersionToRemove, false);
}
if (vpnInstanceInternetIpVersionRemoved) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
neutronvpnUtils.updateVpnInstanceWithFallback(vpnInstanceInternetUuid.getValue(), false);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class NeutronRouterChangeListener method update.
@Override
protected void update(InstanceIdentifier<Router> identifier, Router original, Router update) {
LOG.trace("Updating Router : key: {}, original value={}, update value={}", identifier, original, update);
neutronvpnUtils.addToRouterCache(update);
Uuid routerId = update.getUuid();
neutronvpnUtils.addToRouterCache(update);
Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
// internal vpn always present in case external vpn not found
if (vpnId == null) {
vpnId = routerId;
}
List<Routes> oldRoutes = original.getRoutes() != null ? original.getRoutes() : new ArrayList<>();
List<Routes> newRoutes = update.getRoutes() != null ? update.getRoutes() : new ArrayList<>();
if (!oldRoutes.equals(newRoutes)) {
newRoutes.removeIf(oldRoutes::remove);
handleChangedRoutes(vpnId, newRoutes, NwConstants.ADD_FLOW);
if (!oldRoutes.isEmpty()) {
handleChangedRoutes(vpnId, oldRoutes, NwConstants.DEL_FLOW);
}
}
nvpnNatManager.handleExternalNetworkForRouter(original, update);
gwMacResolver.sendArpRequestsToExtGateways(update);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class QosNeutronNetworkChangeListener method update.
@Override
protected void update(InstanceIdentifier<Network> instanceIdentifier, Network original, Network update) {
QosNetworkExtension updateQos = update.getAugmentation(QosNetworkExtension.class);
QosNetworkExtension originalQos = original.getAugmentation(QosNetworkExtension.class);
if (originalQos == null && updateQos != null) {
// qosservice policy add
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
if (qosNeutronUtils.hasBandwidthLimitRule(update)) {
qosAlertManager.addToQosAlertCache(update);
}
} else if (originalQos != null && updateQos != null && !originalQos.getQosPolicyId().equals(updateQos.getQosPolicyId())) {
// qosservice policy update
qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
if (qosNeutronUtils.hasBandwidthLimitRule(original) && !qosNeutronUtils.hasBandwidthLimitRule(update)) {
qosAlertManager.removeFromQosAlertCache(original);
} else if (!qosNeutronUtils.hasBandwidthLimitRule(original) && qosNeutronUtils.hasBandwidthLimitRule(update)) {
qosAlertManager.addToQosAlertCache(update);
}
} else if (originalQos != null && updateQos == null) {
// qosservice policy delete
if (qosNeutronUtils.hasBandwidthLimitRule(original)) {
qosAlertManager.removeFromQosAlertCache(original);
}
qosNeutronUtils.handleNeutronNetworkQosRemove(original, originalQos.getQosPolicyId());
qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class QosNeutronUtils method handleNeutronPortQosUpdate.
public void handleNeutronPortQosUpdate(Port port, Uuid qosUuidNew, Uuid qosUuidOld) {
LOG.trace("Handling Port QoS update: port: {} qosservice: {}", port.getUuid(), qosUuidNew);
QosPolicy qosPolicyNew = qosPolicyMap.get(qosUuidNew);
QosPolicy qosPolicyOld = qosPolicyMap.get(qosUuidOld);
jobCoordinator.enqueueJob("QosPort-" + port.getUuid().getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
// handle Bandwidth Limit Rules update
if (qosPolicyNew != null && qosPolicyNew.getBandwidthLimitRules() != null && !qosPolicyNew.getBandwidthLimitRules().isEmpty()) {
setPortBandwidthLimits(port, qosPolicyNew.getBandwidthLimitRules().get(0), wrtConfigTxn);
} else {
if (qosPolicyOld != null && qosPolicyOld.getBandwidthLimitRules() != null && !qosPolicyOld.getBandwidthLimitRules().isEmpty()) {
BandwidthLimitRulesBuilder bwLimitBuilder = new BandwidthLimitRulesBuilder();
setPortBandwidthLimits(port, bwLimitBuilder.setMaxBurstKbps(BigInteger.ZERO).setMaxKbps(BigInteger.ZERO).build(), wrtConfigTxn);
}
}
// handle DSCP Mark Rules update
if (qosPolicyNew != null && qosPolicyNew.getDscpmarkingRules() != null && !qosPolicyNew.getDscpmarkingRules().isEmpty()) {
setPortDscpMarking(port, qosPolicyNew.getDscpmarkingRules().get(0));
} else {
if (qosPolicyOld != null && qosPolicyOld.getDscpmarkingRules() != null && !qosPolicyOld.getDscpmarkingRules().isEmpty()) {
unsetPortDscpMark(port);
}
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
Aggregations