use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier 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.linkstate.rev171207.Identifier in project netvirt by opendaylight.
the class NeutronPortChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Port> identifier, Port input) {
LOG.trace("Removing Port : key: {}, value={}", identifier, input);
Network network = neutronvpnUtils.getNeutronNetwork(input.getNetworkId());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
String portName = input.getUuid().getValue();
LOG.warn("neutron vpn received a port remove() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.removeFromPortCache(input);
NeutronUtils.deletePortStatus(input.getUuid().getValue(), dataBroker);
if (!Strings.isNullOrEmpty(input.getDeviceOwner()) && !Strings.isNullOrEmpty(input.getDeviceId())) {
if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceRemoved(input);
/* nothing else to do here */
return;
} else if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner()) || NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(input.getDeviceOwner())) {
elanService.removeKnownL3DmacAddress(input.getMacAddress().getValue(), input.getNetworkId().getValue());
}
}
if (input.getFixedIps() != null) {
handleNeutronPortDeleted(input);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project netvirt by opendaylight.
the class NeutronPortChangeListener method add.
@Override
protected void add(InstanceIdentifier<Port> identifier, Port input) {
String portName = input.getUuid().getValue();
LOG.trace("Adding Port : key: {}, value={}", identifier, input);
Network network = neutronvpnUtils.getNeutronNetwork(input.getNetworkId());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a port add() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.addToPortCache(input);
String portStatus = NeutronUtils.PORT_STATUS_DOWN;
if (!Strings.isNullOrEmpty(input.getDeviceOwner()) && !Strings.isNullOrEmpty(input.getDeviceId())) {
if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceAdded(input);
NeutronUtils.createPortStatus(input.getUuid().getValue(), NeutronUtils.PORT_STATUS_ACTIVE, dataBroker);
return;
}
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner())) {
handleRouterGatewayUpdated(input);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
} else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(input.getDeviceOwner())) {
handleFloatingIpPortUpdated(null, input);
portStatus = NeutronUtils.PORT_STATUS_ACTIVE;
}
}
// in order to validate the supported vnic types from the hostconfig
if (input.getFixedIps() != null && !input.getFixedIps().isEmpty() && !(isPortTypeSwitchdev(input) && !isPortBound(input))) {
handleNeutronPortCreated(input);
}
NeutronUtils.createPortStatus(input.getUuid().getValue(), portStatus, dataBroker);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier 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.linkstate.rev171207.Identifier in project netvirt by opendaylight.
the class PolicyServiceUtil method updateTunnelInterfacesForUnderlayNetwork.
public void updateTunnelInterfacesForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, List<TunnelInterface> tunnelInterfaces, boolean isAdded) {
coordinator.enqueueJob(underlayNetwork, () -> {
InstanceIdentifier<DpnToInterface> identifier = getUnderlayNetworkDpnIdentifier(underlayNetwork, srcDpId);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (isAdded) {
DpnToInterface dpnToInterface = new DpnToInterfaceBuilder().setDpId(srcDpId).setTunnelInterface(tunnelInterfaces).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, dpnToInterface, true);
LOG.info("Add tunnel interfaces {} on DPN {} to underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
} else {
tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
LOG.info("Remove tunnel interfaces {} from DPN {} on underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
}
return Collections.singletonList(tx.submit());
});
}
Aggregations