use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces in project netvirt by opendaylight.
the class ElanServiceProvider method flushMACTable.
@Override
public void flushMACTable(String elanInstanceName) {
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
if (elanInfo == null) {
return;
}
List<String> elanInterfaces = elanInfo.getElanInterfaces();
if (elanInterfaces == null || elanInterfaces.isEmpty()) {
return;
}
for (String elanInterface : elanInterfaces) {
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
List<MacEntry> macEntries = elanInterfaceMac.getMacEntry();
for (MacEntry macEntry : macEntries) {
deleteStaticMacAddress(elanInterface, macEntry.getMacAddress().getValue());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces in project netvirt by opendaylight.
the class EtreeInterfaceGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get EtreeInterface command for the corresponding Etree Instance {}", etreeName);
if (etreeName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(etreeName);
if (elanInstance == null || elanInstance.getAugmentation(EtreeInstance.class) == null) {
session.getConsole().println("Etree instance doesn't exist or isn't configured as etree: " + etreeName);
return null;
}
List<String> elanInterfaces = elanProvider.getElanInterfaces(etreeName);
if (elanInterfaces == null) {
session.getConsole().println("No Etree Interfaces present for ELan Instance:" + etreeName);
return null;
}
session.getConsole().println(getEtreeInterfaceHeaderOutput());
displayInterfaces(elanInstance, elanInterfaces);
} else {
List<ElanInstance> elanInstances = elanProvider.getElanInstances();
if (!elanInstances.isEmpty()) {
session.getConsole().println(getEtreeInterfaceHeaderOutput());
for (ElanInstance elanInstance : elanInstances) {
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
displayInterfaces(elanInstance, elanInterfaces);
session.getConsole().println("\n");
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces in project netvirt by opendaylight.
the class ElanInterfaceGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get ElanInterface command for the corresponding Elan Instance for {}", elanName);
if (elanName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanName);
if (elanInterfaces == null) {
session.getConsole().println("No Elan Interfaces present for ELan Instance:" + elanName);
return null;
}
session.getConsole().println(getElanInterfaceHeaderOutput());
displayInterfaces(elanInstance, elanInterfaces);
} else {
List<ElanInstance> elanInstances = elanProvider.getElanInstances();
if (!elanInstances.isEmpty()) {
session.getConsole().println(getElanInterfaceHeaderOutput());
for (ElanInstance elanInstance : elanInstances) {
List<String> elanInterfaces = elanProvider.getElanInterfaces(elanInstance.getElanInstanceName());
displayInterfaces(elanInstance, elanInterfaces);
session.getConsole().println("\n");
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInterfaces in project netvirt by opendaylight.
the class ElanServiceProvider method getElanMacTable.
@Override
public Collection<MacEntry> getElanMacTable(String elanInstanceName) {
Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
List<MacEntry> macAddress = new ArrayList<>();
if (elanInfo == null) {
return macAddress;
}
List<String> elanInterfaces = elanInfo.getElanInterfaces();
if (elanInterfaces != null && elanInterfaces.size() > 0) {
for (String elanInterface : elanInterfaces) {
ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(elanInterface);
if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null && elanInterfaceMac.getMacEntry().size() > 0) {
macAddress.addAll(elanInterfaceMac.getMacEntry());
}
}
}
return macAddress;
}
Aggregations