Search in sources :

Example 11 with Mac

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.

the class ElanBridgeManager method buildBridgeOtherConfigs.

private List<BridgeOtherConfigs> buildBridgeOtherConfigs(Node ovsdbNode, String bridgeName, String mac) {
    // First attempt to extract the bridge augmentation from operational...
    Node bridgeNode = southboundUtils.getBridgeNode(ovsdbNode, bridgeName);
    OvsdbBridgeAugmentation bridgeAug = null;
    if (bridgeNode != null) {
        bridgeAug = southboundUtils.extractBridgeAugmentation(bridgeNode);
    }
    // ...if present, it means this bridge already exists and we need to take
    // care not to change the datapath id. We do this by explicitly setting
    // other_config:datapath-id to the value reported in the augmentation.
    List<BridgeOtherConfigs> otherConfigs;
    if (bridgeAug != null) {
        DatapathId dpId = bridgeAug.getDatapathId();
        if (dpId != null) {
            otherConfigs = bridgeAug.getBridgeOtherConfigs();
            if (otherConfigs == null) {
                otherConfigs = Lists.newArrayList();
            }
            if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DATAPATH_ID))) {
                String dpIdVal = dpId.getValue().replace(":", "");
                otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DATAPATH_ID).setBridgeOtherConfigValue(dpIdVal).build());
            }
        } else {
            otherConfigs = Lists.newArrayList();
        }
    } else {
        otherConfigs = Lists.newArrayList();
        if (mac != null) {
            otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_HWADDR).setBridgeOtherConfigValue(mac).build());
        }
    }
    if (otherConfigs.stream().noneMatch(otherConfig -> otherConfig.getBridgeOtherConfigKey().equals(OTHER_CONFIG_DISABLE_IN_BAND))) {
        otherConfigs.add(new BridgeOtherConfigsBuilder().setBridgeOtherConfigKey(OTHER_CONFIG_DISABLE_IN_BAND).setBridgeOtherConfigValue("true").build());
    }
    return otherConfigs;
}
Also used : OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) BridgeOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigs) DatapathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId) BridgeOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeOtherConfigsBuilder)

Example 12 with Mac

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.

the class ElanDpnInterfaceClusteredListener method add.

@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
    final String elanName = getElanName(identifier);
    jobCoordinator.enqueueJob(elanName + ":l2gw", () -> {
        elanInstanceDpnsCache.add(getElanName(identifier), dpnInterfaces);
        if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
            ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
            if (elanInstance != null) {
                elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpnInterfaces.getDpId(), elanInstance, dpnInterfaces.getInterfaces().get(0));
                // updating remote mcast mac on l2gw devices
                elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
            }
        }
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 13 with Mac

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.

the class ElanInterfaceManager method createElanInterfaceTablesList.

private void createElanInterfaceTablesList(String interfaceName, WriteTransaction tx) {
    InstanceIdentifier<ElanInterfaceMac> elanInterfaceMacTables = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
    Optional<ElanInterfaceMac> interfaceMacTables = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanInterfaceMacTables);
    // Static-Mac Entries..
    if (!interfaceMacTables.isPresent()) {
        ElanInterfaceMac elanInterfaceMacTable = new ElanInterfaceMacBuilder().setElanInterface(interfaceName).setKey(new ElanInterfaceMacKey(interfaceName)).build();
        tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName), elanInterfaceMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
    }
}
Also used : ElanInterfaceMacKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMacKey) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) ElanInterfaceMacBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMacBuilder)

Example 14 with Mac

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.

the class ElanInterfaceManager method update.

/*
    * Possible Scenarios for update
    *   a. if orig={1,2,3,4}   and updated=null or updated={}
        then all {1,2,3,4} should be removed

        b. if orig=null or orig={}  and  updated ={1,2,3,4}
        then all {1,2,3,4} should be added

        c. if orig = {1,2,3,4} updated={2,3,4}
        then 1 should be removed

        d. basically if orig = { 1,2,3,4} and updated is {1,2,3,4,5}
        then we should just add 5

        e. if orig = {1,2,3,4} updated={2,3,4,5}
        then 1 should be removed , 5 should be added
    * */
@Override
protected void update(InstanceIdentifier<ElanInterface> identifier, ElanInterface original, ElanInterface update) {
    // updating the static-Mac Entries for the existing elanInterface
    String elanName = update.getElanInstanceName();
    String interfaceName = update.getName();
    List<StaticMacEntries> originalStaticMacEntries = original.getStaticMacEntries();
    List<StaticMacEntries> updatedStaticMacEntries = update.getStaticMacEntries();
    List<StaticMacEntries> deletedEntries = ElanUtils.diffOf(originalStaticMacEntries, updatedStaticMacEntries);
    List<StaticMacEntries> updatedEntries = ElanUtils.diffOf(updatedStaticMacEntries, originalStaticMacEntries);
    deletedEntries.forEach((deletedEntry) -> removeInterfaceStaticMacEntries(elanName, interfaceName, deletedEntry.getMacAddress()));
    /*if updatedStaticMacEntries is NOT NULL, which means as part of update call these entries were added.
        * Hence add the macentries for the same.*/
    for (StaticMacEntries staticMacEntry : updatedEntries) {
        InstanceIdentifier<MacEntry> macEntryIdentifier = getMacEntryOperationalDataPath(elanName, staticMacEntry.getMacAddress());
        Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macEntryIdentifier);
        WriteTransaction tx = broker.newWriteOnlyTransaction();
        if (existingMacEntry.isPresent()) {
            elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
        } else {
            elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanName, interfaceName, staticMacEntry, tx);
        }
        ElanUtils.waitForTransactionToComplete(tx);
    }
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries)

Example 15 with Mac

use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.

the class ElanServiceProvider method createEtreeInstance.

@Override
public boolean createEtreeInstance(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.warn("Etree Instance is already present in the Operational DS {}", existingElanInstance);
            return true;
        } else {
            EtreeInstance etreeInstance = new EtreeInstanceBuilder().build();
            ElanInstance updateElanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setMacTimeout(macTimeout).setKey(new ElanInstanceKey(elanInstanceName)).addAugmentation(EtreeInstance.class, etreeInstance).build();
            MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), updateElanInstance);
            LOG.debug("Updating the Etree Instance {} with MAC TIME-OUT {} and Description {} ", updateElanInstance, macTimeout, description);
        }
    } else {
        EtreeInstance etreeInstance = new EtreeInstanceBuilder().build();
        ElanInstance elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName).setMacTimeout(macTimeout).setDescription(description).setKey(new ElanInstanceKey(elanInstanceName)).addAugmentation(EtreeInstance.class, etreeInstance).build();
        MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstance);
        LOG.debug("Creating the new Etree Instance {}", elanInstance);
    }
    return isSuccess;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) EtreeInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Aggregations

ArrayList (java.util.ArrayList)57 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)50 BigInteger (java.math.BigInteger)36 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)21 Test (org.junit.Test)20 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)19 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)18 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)18 Collections (java.util.Collections)17 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)17 List (java.util.List)16 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 ExecutionException (java.util.concurrent.ExecutionException)15 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)15 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)15 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)15 Inject (javax.inject.Inject)14