use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries in project netvirt by opendaylight.
the class ElanInterfaceManager method setupEntriesForElanInterface.
List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) throws ElanException {
String elanInstanceName = elanInstance.getElanInstanceName();
String interfaceName = elanInterface.getName();
WriteTransaction tx = broker.newWriteOnlyTransaction();
BigInteger dpId = interfaceInfo.getDpId();
WriteTransaction writeFlowGroupTx = broker.newWriteOnlyTransaction();
installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo, isFirstInterfaceInDpn, tx, writeFlowGroupTx);
List<StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
List<PhysAddress> staticMacAddresses = Lists.newArrayList();
boolean isInterfaceOperational = isOperational(interfaceInfo);
if (ElanUtils.isNotEmpty(staticMacEntriesList)) {
for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress());
Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
if (existingMacEntry.isPresent()) {
elanForwardingEntriesHandler.updateElanInterfaceForwardingTablesList(elanInstanceName, interfaceName, existingMacEntry.get().getInterface(), existingMacEntry.get(), tx);
} else {
elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
}
if (isInterfaceOperational) {
// Setting SMAC, DMAC, UDMAC in this DPN and also in other
// DPNs
String macAddress = staticMacEntry.getMacAddress().getValue();
LOG.info("programming smac and dmacs for {} on source and other DPNs for elan {} and interface {}", macAddress, elanInstanceName, interfaceName);
elanUtils.setupMacFlows(elanInstance, interfaceInfo, ElanConstants.STATIC_MAC_TIMEOUT, staticMacEntry.getMacAddress().getValue(), true, writeFlowGroupTx);
}
}
if (isInterfaceOperational) {
// on purpose.
for (StaticMacEntries staticMacEntry : staticMacEntriesList) {
staticMacAddresses.add(staticMacEntry.getMacAddress());
}
elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId, staticMacAddresses);
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(tx));
futures.add(ElanUtils.waitForTransactionToComplete(writeFlowGroupTx));
if (isInterfaceOperational && !interfaceManager.isExternalInterface(interfaceName)) {
// At this point, the interface is operational and D/SMAC flows have been configured, mark the port active
try {
Port neutronPort = neutronVpnManager.getNeutronPort(interfaceName);
if (neutronPort != null) {
NeutronUtils.updatePortStatus(interfaceName, NeutronUtils.PORT_STATUS_ACTIVE, broker);
}
} catch (IllegalArgumentException ex) {
LOG.trace("Interface: {} is not part of Neutron Network", interfaceName);
}
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries in project netvirt by opendaylight.
the class ElanServiceProvider method updateElanInterface.
@Override
public void updateElanInterface(String elanInstanceName, String interfaceName, List<String> updatedStaticMacAddresses, String newDescription) {
Optional<ElanInterface> existingElanInterface = elanInterfaceCache.get(interfaceName);
if (!existingElanInterface.isPresent()) {
return;
}
List<StaticMacEntries> updatedStaticMacEntries = ElanUtils.getStaticMacEntries(updatedStaticMacAddresses);
LOG.debug("updating the ElanInterface with new Mac Entries {}", updatedStaticMacAddresses);
ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setName(interfaceName).setDescription(newDescription).setStaticMacEntries(updatedStaticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries in project netvirt by opendaylight.
the class ElanServiceProvider method addElanInterface.
@Override
public void addElanInterface(String elanInstanceName, String interfaceName, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
if (existingElanInstance.isPresent()) {
ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName));
if (staticMacAddresses != null) {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterfaceBuilder.setStaticMacEntries(staticMacEntries);
}
ElanInterface elanInterface = elanInterfaceBuilder.build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Created the new ELan Interface {}", elanInterface);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries in project netvirt by opendaylight.
the class ElanServiceProvider method addEtreeInterface.
@Override
public void addEtreeInterface(String etreeInstanceName, String interfaceName, EtreeInterfaceType interfaceType, List<String> staticMacAddresses, String description) {
Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(etreeInstanceName);
if (existingElanInstance.isPresent() && existingElanInstance.get().getAugmentation(EtreeInstance.class) != null) {
EtreeInterface etreeInterface = new EtreeInterfaceBuilder().setEtreeInterfaceType(interfaceType).build();
ElanInterface elanInterface;
if (staticMacAddresses == null) {
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
} else {
List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
elanInterface = new ElanInterfaceBuilder().setElanInstanceName(etreeInstanceName).setDescription(description).setName(interfaceName).setStaticMacEntries(staticMacEntries).setKey(new ElanInterfaceKey(interfaceName)).addAugmentation(EtreeInterface.class, etreeInterface).build();
}
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
LOG.debug("Creating the new Etree Interface {}", elanInterface);
}
}
Aggregations