Search in sources :

Example 6 with ElanInterfaces

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

the class ElanServiceProvider method flushMACTable.

@Override
public void flushMACTable(String elanInstanceName) {
    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    if (elanInfo == null) {
        return;
    }
    List<String> elanInterfaces = elanInfo.getElanInterfaces();
    if (elanInterfaces == null || elanInterfaces.isEmpty()) {
        return;
    }
    for (String elanInterface : elanInterfaces) {
        ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
        if (elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
            List<MacEntry> macEntries = elanInterfaceMac.getMacEntry();
            for (MacEntry macEntry : macEntries) {
                deleteStaticMacAddress(elanInterface, macEntry.getMacAddress().getValue());
            }
        }
    }
}
Also used : Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)

Example 7 with ElanInterfaces

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

the class EtreeInterfaceGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get EtreeInterface command for the corresponding Etree Instance {}", etreeName);
    if (etreeName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(etreeName);
        if (elanInstance == null || elanInstance.getAugmentation(EtreeInstance.class) == null) {
            session.getConsole().println("Etree instance doesn't exist or isn't configured as etree: " + etreeName);
            return null;
        }
        List<String> elanInterfaces = elanProvider.getElanInterfaces(etreeName);
        if (elanInterfaces == null) {
            session.getConsole().println("No Etree Interfaces present for ELan Instance:" + etreeName);
            return null;
        }
        session.getConsole().println(getEtreeInterfaceHeaderOutput());
        displayInterfaces(elanInstance, elanInterfaces);
    } else {
        List<ElanInstance> elanInstances = elanProvider.getElanInstances();
        if (!elanInstances.isEmpty()) {
            session.getConsole().println(getEtreeInterfaceHeaderOutput());
            for (ElanInstance elanInstance : elanInstances) {
                List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
                displayInterfaces(elanInstance, elanInterfaces);
                session.getConsole().println("\n");
            }
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 8 with ElanInterfaces

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

the class ElanInterfaceGet method doExecute.

@Override
protected Object doExecute() {
    LOG.debug("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
    if (elanName != null) {
        ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
        List<String> elanInterfaces = elanProvider.getElanInterfaces(elanName);
        if (elanInterfaces == null) {
            session.getConsole().println("No Elan Interfaces present for ELan Instance:" + elanName);
            return null;
        }
        session.getConsole().println(getElanInterfaceHeaderOutput());
        displayInterfaces(elanInstance, elanInterfaces);
    } else {
        List<ElanInstance> elanInstances = elanProvider.getElanInstances();
        if (!elanInstances.isEmpty()) {
            session.getConsole().println(getElanInterfaceHeaderOutput());
            for (ElanInstance elanInstance : elanInstances) {
                List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
                displayInterfaces(elanInstance, elanInterfaces);
                session.getConsole().println("\n");
            }
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 9 with ElanInterfaces

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

the class ElanUtils method updateOperationalDataStore.

/**
 * Updates the Elan information in the Operational DS. It also updates the
 * ElanInstance in the Config DS by setting the adquired elanTag.
 *
 * @param idManager
 *            the id manager
 * @param elanInstanceAdded
 *            the elan instance added
 * @param elanInterfaces
 *            the elan interfaces
 * @param tx
 *            transaction
 *
 * @return the updated ELAN instance.
 */
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, WriteTransaction tx) {
    String elanInstanceName = elanInstanceAdded.getElanInstanceName();
    Long elanTag = elanInstanceAdded.getElanTag();
    if (elanTag == null || elanTag == 0L) {
        elanTag = retrieveNewElanTag(idManager, elanInstanceName);
    }
    Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).setKey(new ElanKey(elanInstanceName)).build();
    // Add the ElanState in the elan-state operational data-store
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanInstanceOperationalDataPath(elanInstanceName), elanInfo, WriteTransaction.CREATE_MISSING_PARENTS);
    // Add the ElanMacTable in the elan-mac-table operational data-store
    MacTable elanMacTable = new MacTableBuilder().setKey(new MacTableKey(elanInstanceName)).build();
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
    ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).setKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
    long etreeLeafTag = -1;
    if (isEtreeInstance(elanInstanceAdded)) {
        etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
        EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
        elanTagNameBuilder.addAugmentation(EtreeLeafTagName.class, etreeLeafTagName);
        addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, tx);
    }
    ElanTagName elanTagName = elanTagNameBuilder.build();
    // Add the ElanTag to ElanName in the elan-tag-name Operational
    // data-store
    tx.put(LogicalDatastoreType.OPERATIONAL, getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
    // Updates the ElanInstance Config DS by setting the just acquired
    // elanTag
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Long.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).setKey(elanInstanceAdded.getKey()).setElanTag(elanTag);
    if (isEtreeInstance(elanInstanceAdded)) {
        EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
        elanInstanceBuilder.addAugmentation(EtreeInstance.class, etreeInstance);
    }
    ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
    tx.merge(LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag, WriteTransaction.CREATE_MISSING_PARENTS);
    return elanInstanceWithTag;
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey) MacTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableBuilder) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable) EtreeLeafTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName) ElanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder) ElanTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameBuilder) MacTableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey) ElanTagNameKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) EtreeInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder) EtreeLeafTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagNameBuilder) EtreeLeafTag(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTag)

Example 10 with ElanInterfaces

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

the class ElanServiceProvider method getElanMacTable.

@Override
public Collection<MacEntry> getElanMacTable(String elanInstanceName) {
    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    List<MacEntry> macAddress = new ArrayList<>();
    if (elanInfo == null) {
        return macAddress;
    }
    List<String> elanInterfaces = elanInfo.getElanInterfaces();
    if (elanInterfaces != null && elanInterfaces.size() > 0) {
        for (String elanInterface : elanInterfaces) {
            ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
            if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
                macAddress.addAll(elanInterfaceMac.getMacEntry());
            }
        }
    }
    return macAddress;
}
Also used : Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) ArrayList(java.util.ArrayList) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)

Aggregations

Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)7 ArrayList (java.util.ArrayList)6 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)3 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)3 BigInteger (java.math.BigInteger)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)2 EtreeInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance)2 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)2 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)2 ElanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder)2 ElanKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey)2 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)2 Optional (com.google.common.base.Optional)1 Collections (java.util.Collections)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1