use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class CoeUtils method createElanInstanceForTheFirstPodInTheNetwork.
public static ElanInstance createElanInstanceForTheFirstPodInTheNetwork(String networkNS, String nodeIp, org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface podInterface, ReadWriteTransaction wrtConfigTxn) throws ReadFailedException {
String elanInstanceName = buildElanInstanceName(nodeIp, networkNS);
InstanceIdentifier<ElanInstance> id = createElanInstanceIdentifier(elanInstanceName);
ElanInstance existingElanInstance = wrtConfigTxn.read(LogicalDatastoreType.CONFIGURATION, id).checkedGet().orNull();
if (existingElanInstance != null) {
return existingElanInstance;
}
Class<? extends SegmentTypeBase> segmentType = getSegmentTypeFromNetwork(podInterface);
String segmentationId = String.valueOf(podInterface.getSegmentationId());
// FIXME String physicalNetworkName = ??
// TODO external network support not added currently
Boolean isExternal = false;
ElanInstance elanInstance = CoeUtils.buildElanInstance(elanInstanceName, segmentType, segmentationId, isExternal);
wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, elanInstance);
LOG.info("ELAN instance created for the first pod in the network {}", podInterface.getUid());
return elanInstance;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class EtreeGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get EtreeInstance command for {}", etreeName);
if (etreeName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(etreeName);
if (elanInstance == null || elanInstance.getAugmentation(EtreeInstance.class) == null) {
session.getConsole().println("No Etree Instance present with name:" + etreeName);
} else {
session.getConsole().println(getEtreeHeaderOutput());
session.getConsole().println(String.format(ElanCLIUtils.ETREE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getDescription()));
}
} else {
List<ElanInstance> elanInstanceList = elanProvider.getElanInstances();
if (elanInstanceList != null && !elanInstanceList.isEmpty()) {
session.getConsole().println(getEtreeHeaderOutput());
for (ElanInstance elanInstance : elanInstanceList) {
if (elanInstance.getAugmentation(EtreeInstance.class) != null) {
session.getConsole().println(String.format(ElanCLIUtils.ETREE_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getAugmentation(EtreeInstance.class).getEtreeLeafTagVal().getValue(), elanInstance.getDescription()));
}
}
} else {
session.getConsole().println("No Etree Instances are present");
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance 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.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing Get ElanInstance command for elanName: {}", elanName);
if (elanName != null) {
ElanInstance elanInstance = elanProvider.getElanInstance(elanName);
if (elanInstance == null) {
session.getConsole().println("No Elan Instance present with name:" + elanName);
} else {
session.getConsole().println(getElanHeaderOutput());
session.getConsole().println(String.format(ElanCLIUtils.ELAN_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getDescription()));
}
} else {
List<ElanInstance> elanInstanceList = elanProvider.getElanInstances();
if (elanInstanceList != null && !elanInstanceList.isEmpty()) {
session.getConsole().println(getElanHeaderOutput());
for (ElanInstance elanInstance : elanInstanceList) {
session.getConsole().println(String.format(ElanCLIUtils.ELAN_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName(), elanInstance.getMacTimeout(), elanInstance.getElanTag(), elanInstance.getDescription()));
}
} else {
session.getConsole().println("No Elan Instances are present");
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance 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;
}
Aggregations