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());
});
}
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);
}
}
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());
}
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());
}
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();
}
Aggregations