Search in sources :

Example 1 with EvpnAugmentation

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

the class EvpnUtils method advertiseEvpnRT2Routes.

@SuppressWarnings("checkstyle:IllegalCatch")
public void advertiseEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
    if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
        return;
    }
    String evpnName = evpnAugmentation.getEvpnName();
    List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
    if (macEntries == null || macEntries.isEmpty()) {
        LOG.trace("advertiseEvpnRT2Routes no elan mac entries found for {}", elanName);
        return;
    }
    String rd = vpnManager.getVpnRd(broker, evpnName);
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    macEntries.stream().filter(isIpv4PrefixAvailable).forEach(macEntry -> {
        InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
        if (interfaceInfo == null) {
            LOG.debug("advertiseEvpnRT2Routes, interfaceInfo is null for interface {}", macEntry.getInterface());
            return;
        }
        advertisePrefix(elanInfo, rd, macEntry.getMacAddress().getValue(), macEntry.getIpPrefix().getIpv4Address().getValue(), interfaceInfo.getInterfaceName(), interfaceInfo.getDpId());
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 2 with EvpnAugmentation

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

the class EvpnUtils method withdrawEvpnRT2Routes.

public void withdrawEvpnRT2Routes(EvpnAugmentation evpnAugmentation, String elanName) {
    if (evpnAugmentation == null || evpnAugmentation.getEvpnName() == null) {
        LOG.trace("withdrawEvpnRT2Routes, evpnAugmentation is null");
        return;
    }
    String evpnName = evpnAugmentation.getEvpnName();
    String rd = vpnManager.getVpnRd(broker, evpnName);
    if (rd == null) {
        LOG.debug("withdrawEvpnRT2Routes : rd is null for {}", elanName);
        return;
    }
    List<MacEntry> macEntries = elanUtils.getElanMacEntries(elanName);
    if (macEntries == null || macEntries.isEmpty()) {
        LOG.debug("withdrawEvpnRT2Routes : macEntries  is empty for elan {} ", elanName);
        return;
    }
    for (MacEntry macEntry : macEntries) {
        if (!isIpv4PrefixAvailable.test(macEntry)) {
            LOG.debug("withdrawEvpnRT2Routes macEntry does not have IPv4 prefix {}", macEntry);
            continue;
        }
        String prefix = macEntry.getIpPrefix().getIpv4Address().getValue();
        LOG.info("Withdrawing routes with rd {}, prefix {}", rd, prefix);
        bgpManager.withdrawPrefix(rd, prefix);
    }
}
Also used : MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)

Example 3 with EvpnAugmentation

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

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

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

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 EvpnAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentationBuilder)3 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)3 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)1 EvpnAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation)1