use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface.EtreeInterfaceType 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);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface.EtreeInterfaceType in project netvirt by opendaylight.
the class EtreeInterfaceAdd method doExecute.
@Override
protected Object doExecute() {
EtreeInterfaceType inputType = null;
for (EtreeInterfaceType type : EtreeInterfaceType.values()) {
if (interfaceType.equals(type.getName())) {
inputType = type;
break;
}
}
if (inputType == null) {
session.getConsole().println("interfaceType must be one of: leaf/root, but was: " + interfaceType);
return null;
}
ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
if (elanInstance == null) {
session.getConsole().println("Etree instance " + elanName + " does not exist.");
return null;
} else {
if (elanInstance.getAugmentation(EtreeInstance.class) == null) {
session.getConsole().println("Etree instance " + elanName + " exists but isn't configured as Etree.");
return null;
}
}
LOG.debug("Executing create EtreeInterface command elanName:{}, interfaceName:{}, interfaceType:{}," + "staticMacAddresses:{}, elanInterfaceDescr:{}", elanName, interfaceName, interfaceType, staticMacAddresses, elanInterfaceDescr);
elanProvider.addEtreeInterface(elanName, interfaceName, inputType, staticMacAddresses, elanInterfaceDescr);
session.getConsole().println("Created etree interface successfully");
return null;
}
Aggregations