Search in sources :

Example 96 with Identifier

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());
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 97 with Identifier

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);
    }
}
Also used : Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Example 98 with Identifier

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);
}
Also used : Network(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network)

Example 99 with Identifier

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);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)

Example 100 with Identifier

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());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) DpnToInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterfaceBuilder)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 ArrayList (java.util.ArrayList)57 BigInteger (java.math.BigInteger)55 Test (org.junit.Test)52 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)35 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)30 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)29 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)25 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)16 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)14 List (java.util.List)13 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)13 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)12 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)11 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)10 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)10