import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Uni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
-@Command(name = "list", scope = "uni", description = "Lists all uni in the controller.")
+@Command(name = "uni-list", scope = "uni", description = "Lists all uni in the controller.")
public class UniListShellCommand extends OsgiCommandSupport {
protected IUnimgrConsoleProvider provider;
@Override
protected Object doExecute() throws Exception {
- List<Uni> listUnis = provider.listUnis(isConfigurationData);
+ LogicalDatastoreType storeType = isConfigurationData ? LogicalDatastoreType.CONFIGURATION : LogicalDatastoreType.OPERATIONAL;
+ List<UniAugmentation> listUnis = provider.listUnis(storeType);
if (listUnis.size() > 0) {
StringBuilder sb = new StringBuilder();
Integer counter = 1;
- for (Uni uni : listUnis) {
+ for (UniAugmentation uni : listUnis) {
// TODO
- sb.append(String.format("#%d - id: %s\n", counter, uni.getIpAddress().getIpv4Address()));
+ sb.append(String.format("#%d - IpAddress: %s\n", counter, uni.getIpAddress().getIpv4Address().getValue()));
counter++;
}
return sb.toString();
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Uni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
-@Command(name = "show", scope = "uni", description = "Shows detailed information about an uni.")
+@Command(name = "uni-show", scope = "uni", description = "Shows detailed information about an uni.")
public class UniShowShellCommand extends OsgiCommandSupport {
protected IUnimgrConsoleProvider provider;
protected Object doExecute() throws Exception {
StringBuilder sb = new StringBuilder();
IpAddress ipAddre = new IpAddress(ipAddress.toCharArray());
- Uni uni = provider.getUni(ipAddre);
+ UniAugmentation uni = provider.getUni(ipAddre);
if (uni != null) {
- //sb.append(String.format("Uni Id: <%s>\n", uni.getUniId()));
- sb.append(String.format("Physical medium: <%s>\n", uni.getPhysicalMedium()));
+ sb.append(String.format("Ip Address: <%s>\n", uni.getIpAddress().getIpv4Address().getValue()));
sb.append(String.format("Mac address: <%s>\n", uni.getMacAddress()));
+ sb.append(String.format("Physical medium: <%s>\n", uni.getPhysicalMedium()));
sb.append(String.format("Speed: " + uni.getSpeed() + "\n"));
sb.append(String.format("Mode: <%s>\n", uni.getMode()));
sb.append(String.format("Mac layer: <%s>\n", uni.getMacLayer()));
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Uni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
public interface IUnimgrConsoleProvider extends AutoCloseable {
boolean removeUni(IpAddress ipAddress);
- List<Uni> listUnis(Boolean isConfigurationData);
+ List<UniAugmentation> listUnis(LogicalDatastoreType dataStoreType);
- Uni getUni(IpAddress ipAddress);
+ UniAugmentation getUni(IpAddress ipAddress);
boolean removeEvc(String uuid);
import org.opendaylight.unimgr.command.TransactionInvoker;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Uni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder;
}
@Override
- public List<Uni> listUnis(Boolean isConfigurationData) {
- // TODO Auto-generated method stub
- return null;
+ public List<UniAugmentation> listUnis(LogicalDatastoreType dataStoreType) {
+ return UnimgrUtils.getUnis(dataBroker, dataStoreType);
}
@Override
- public Uni getUni(IpAddress ipAddress) {
- // TODO Auto-generated method stub
- return null;
+ public UniAugmentation getUni(IpAddress ipAddress) {
+ return UnimgrUtils.getUni(dataBroker, LogicalDatastoreType.CONFIGURATION, ipAddress);
}
return uniNodes;
}
+ /**
+ * Retrieve a list of Unis on a specific DataStore
+ * @param dataBroker instance to create transactions
+ * @param store to which send the read request
+ * @return A List of Unis.
+ */
+ public static List<UniAugmentation> getUnis(DataBroker dataBroker,
+ LogicalDatastoreType store) {
+ List<UniAugmentation> unis = new ArrayList<>();
+ InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+ Topology topology = read(dataBroker,
+ store,
+ topologyInstanceIdentifier);
+ if (topology != null && topology.getNode() != null) {
+ for (Node node : topology.getNode()) {
+ UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+ if (uniAugmentation != null) {
+ unis.add(uniAugmentation);
+ }
+ }
+ }
+ return unis;
+ }
+
+ /**
+ * Retrieve a list of Unis on a specific DataStore
+ * @param dataBroker instance to create transactions
+ * @param store to which send the read request
+ * @param ipAddress of the required Uni
+ * @return uni.
+ */
+ public static UniAugmentation getUni(DataBroker dataBroker,
+ LogicalDatastoreType store, IpAddress ipAddress) {
+ InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+ Topology topology = read(dataBroker,
+ store,
+ topologyInstanceIdentifier);
+ if (topology != null && topology.getNode() != null) {
+ for (Node node : topology.getNode()) {
+ UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+ if (uniAugmentation != null && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(ipAddress.getIpv4Address().getValue())) {
+ return uniAugmentation;
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Read a specific datastore type and return a DataObject as a casted
* class type Object.