Search in sources :

Example 1 with EvpnAugmentationBuilder

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

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

the class EvpnTestHelper method deleteEvpnNameInElan.

public void deleteEvpnNameInElan(String elanInstanceName) 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(null);
    LOG.debug("deleting evpn name from Elan-EvpnAugmentation {} ", 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 3 with EvpnAugmentationBuilder

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

the class NeutronEvpnUtils method updateElanWithVpnInfo.

public void updateElanWithVpnInfo(String elanInstanceName, VpnInstance vpnInstance, Operation operation) {
    String vpnName = vpnInstance.getVpnInstanceName();
    InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
    ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
    Optional<ElanInstance> elanInstanceOptional = Optional.absent();
    try {
        elanInstanceOptional = transaction.read(LogicalDatastoreType.CONFIGURATION, elanIid).checkedGet();
    } catch (ReadFailedException e) {
        LOG.error("updateElanWithVpnInfo throws ReadFailedException e {}", e);
    }
    if (!elanInstanceOptional.isPresent()) {
        return;
    }
    EvpnAugmentationBuilder evpnAugmentationBuilder = new EvpnAugmentationBuilder();
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceOptional.get());
    if (elanInstanceBuilder.getAugmentation(EvpnAugmentation.class) != null) {
        evpnAugmentationBuilder = new EvpnAugmentationBuilder(elanInstanceBuilder.getAugmentation(EvpnAugmentation.class));
    }
    if (operation == Operation.ADD) {
        evpnAugmentationBuilder.setEvpnName(vpnName);
        LOG.debug("Writing Elan-EvpnAugmentation with key {}", elanInstanceName);
    } else {
        evpnAugmentationBuilder.setEvpnName(null);
        LOG.debug("Deleting Elan-EvpnAugmentation with key {}", elanInstanceName);
    }
    elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
    transaction.put(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
    transaction.submit();
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) 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) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) EvpnAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation)

Aggregations

EvpnAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentationBuilder)3 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)3 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)3 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 EvpnAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation)1