Search in sources :

Example 1 with ElanInstanceBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder 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)

Example 2 with ElanInstanceBuilder

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

the class AclLiveStatisticsRpcServiceTest method newElan.

// FIXME copied from AclServiceTestBase
protected void newElan(String elanName, long elanId) throws TransactionCommitFailedException {
    ElanInstance elan = new ElanInstanceBuilder().setElanInstanceName(elanName).setElanTag(5000L).build();
    singleTransactionDataBroker.syncWrite(CONFIGURATION, AclServiceUtils.getElanInstanceConfigurationDataPath(elanName), elan);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Example 3 with ElanInstanceBuilder

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

the class EvpnTestHelper method updateEvpnNameInElan.

public void updateEvpnNameInElan(String elanInstanceName, String evpnName) throws ReadFailedException, TransactionCommitFailedException {
    InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
    ElanInstance elanInstance = singleTxdataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, elanIid);
    EvpnAugmentationBuilder evpnAugmentationBuilder = new EvpnAugmentationBuilder();
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstance);
    evpnAugmentationBuilder.setEvpnName(evpnName);
    LOG.debug("Writing Elan-EvpnAugmentation evpnName {} with key {}", evpnName, elanInstanceName);
    elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
    singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build());
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) EvpnAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentationBuilder) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Example 4 with ElanInstanceBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder 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 5 with ElanInstanceBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder 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

ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)10 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)8 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)4 EvpnAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentationBuilder)3 EtreeInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance)2 EtreeInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 EtreeLeafTag (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTag)1 EtreeLeafTagName (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName)1 EtreeLeafTagNameBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagNameBuilder)1 EvpnAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation)1 MacTable (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable)1 MacTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableBuilder)1 MacTableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey)1 ElanSegments (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments)1 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)1 ElanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder)1 ElanKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey)1 ElanTagName (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName)1