Search in sources :

Example 86 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class LocalUcastMacListener method removed.

public void removed(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macRemoved) {
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macRemoved.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    LOG.trace("LocalUcastMacs {} removed from {}", macAddress, hwvtepNodeId);
    ResourceBatchingManager.getInstance().delete(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier);
    String elanName = getElanName(macRemoved);
    jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice == null) {
            LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
            return null;
        }
        elanL2GwDevice.removeUcastLocalMac(macRemoved);
        ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
        elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
        elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstance, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 87 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanServiceProvider method updateExternalElanNetworks.

@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
    if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
        return;
    }
    List<ElanInstance> elanInstances = getElanInstances();
    if (elanInstances == null || elanInstances.isEmpty()) {
        LOG.trace("No ELAN instances found");
        return;
    }
    LOG.debug("updateExternalElanNetworks, orig bridge {} . updated bridge {}", origNode, updatedNode);
    Map<String, String> origProviderMappping = getMapFromOtherConfig(origNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
    Map<String, String> updatedProviderMappping = getMapFromOtherConfig(updatedNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
    boolean hasDatapathIdOnOrigNode = bridgeMgr.hasDatapathID(origNode);
    boolean hasDatapathIdOnUpdatedNode = bridgeMgr.hasDatapathID(updatedNode);
    BigInteger origDpnID = bridgeMgr.getDatapathId(origNode);
    for (ElanInstance elanInstance : elanInstances) {
        String physicalNetworkName = elanInstance.getPhysicalNetworkName();
        boolean createExternalElanNw = true;
        if (physicalNetworkName != null) {
            String origPortName = origProviderMappping.get(physicalNetworkName);
            String updatedPortName = updatedProviderMappping.get(physicalNetworkName);
            /**
             * for internal vlan network, vlan provider interface creation should be
             * triggered only if there is existing vlan provider intf indicating presence
             * of VM ports on the DPN
             */
            if (hasDatapathIdOnOrigNode && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
                String externalIntf = getExternalElanInterface(elanInstance.getElanInstanceName(), origDpnID);
                if (externalIntf == null) {
                    createExternalElanNw = false;
                }
            }
            if (hasPortNameRemoved(origPortName, updatedPortName)) {
                deleteExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(origNode, physicalNetworkName));
            }
            if (createExternalElanNw && (hasPortNameUpdated(origPortName, updatedPortName) || hasDatapathIdAdded(hasDatapathIdOnOrigNode, hasDatapathIdOnUpdatedNode))) {
                createExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(updatedNode, physicalNetworkName));
            }
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) BigInteger(java.math.BigInteger)

Example 88 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanServiceProvider method createIetfInterfaces.

/**
 * Create ietf-interfaces based on the ELAN segment type.<br>
 * For segment type flat - create transparent interface pointing to the
 * patch-port attached to the physnet port.<br>
 * For segment type vlan - create trunk interface pointing to the patch-port
 * attached to the physnet port + trunk-member interface pointing to the
 * trunk interface.
 *
 * @param elanInstance
 *            ELAN instance
 * @param parentRef
 *            parent interface name
 * @return the name of the interface to be added to the ELAN instance i.e.
 *         trunk-member name for vlan network and transparent for flat
 *         network or null otherwise
 */
private String createIetfInterfaces(ElanInstance elanInstance, String parentRef) {
    String interfaceName = null;
    try {
        String trunkName = getTrunkInterfaceName(parentRef);
        // trunk interface may have been created by other vlan network
        Interface trunkInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(trunkName);
        if (trunkInterface == null) {
            interfaceManager.createVLANInterface(trunkName, parentRef, null, null, IfL2vlan.L2vlanMode.Trunk, true);
        }
        if (ElanUtils.isFlat(elanInstance)) {
            interfaceName = trunkName;
        } else if (ElanUtils.isVlan(elanInstance)) {
            Long segmentationId = elanInstance.getSegmentationId();
            interfaceName = parentRef + IfmConstants.OF_URI_SEPARATOR + segmentationId;
            interfaceManager.createVLANInterface(interfaceName, trunkName, segmentationId.intValue(), null, IfL2vlan.L2vlanMode.TrunkMember, true);
        }
    } catch (InterfaceAlreadyExistsException e) {
        LOG.trace("Interface {} was already created", interfaceName);
    }
    return interfaceName;
}
Also used : InterfaceAlreadyExistsException(org.opendaylight.genius.interfacemanager.exceptions.InterfaceAlreadyExistsException) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 89 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanServiceProvider method deleteExternalElanNetwork.

protected void deleteExternalElanNetwork(ElanInstance elanInstance, BigInteger dpnId) {
    String providerIntfName = bridgeMgr.getProviderInterfaceName(dpnId, elanInstance.getPhysicalNetworkName());
    String intfName = providerIntfName + IfmConstants.OF_URI_SEPARATOR + elanInstance.getSegmentationId();
    Interface memberIntf = interfaceManager.getInterfaceInfoFromConfigDataStore(intfName);
    if (memberIntf != null) {
        deleteElanInterface(intfName);
        deleteIetfInterface(intfName);
        LOG.debug("delete vlan prv intf {} in elan {}, dpID {}", intfName, elanInstance.getElanInstanceName(), dpnId);
    } else {
        LOG.debug("vlan prv intf {} not found in interfacemgr config DS", intfName);
    }
}
Also used : Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 90 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanServiceProvider method createElanInstance.

@Override
public boolean createElanInstance(String elanInstanceName, long macTimeout, String description) {
    Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
    boolean isSuccess = true;
    if (existingElanInstance.isPresent()) {
        if (compareWithExistingElanInstance(existingElanInstance.get(), macTimeout, description)) {
            LOG.debug("Elan Instance is already present in the Operational DS {}", existingElanInstance);
            return true;
        } else {
            ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setMacTimeout(macTimeout).setKey(new ElanInstanceKey(elanInstanceName)).build();
            MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
            LOG.debug("Updating the Elan Instance {} with MAC TIME-OUT {} and Description {}", updateElanInstance, macTimeout, description);
        }
    } else {
        ElanInstance elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setMacTimeout(macTimeout).setDescription(description).setKey(new ElanInstanceKey(elanInstanceName)).build();
        MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
        LOG.debug("Creating the new Elan Instance {}", elanInstance);
    }
    return isSuccess;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)52 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)31 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)14 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)13 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)13 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)12 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)9 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8