Adding tooling for null providers to assist in finding sw version refresh issue.
Change-Id: Ib55abf6f4da8c9304e937887a645794856b2adc4
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java b/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
index e7a5788..8ed469e 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
@@ -85,6 +85,23 @@
}
/**
+ * Creates simulated device.
+ *
+ * @param id device identifier
+ * @param name device name
+ * @param type device type
+ * @param hw hardware revision
+ * @param sw software revision
+ * @param portCount number of device ports
+ */
+ public void createDevice(DeviceId id, String name, Device.Type type,
+ String hw, String sw, int portCount) {
+ int chassisId = Integer.parseInt(id.uri().getSchemeSpecificPart(), 16);
+ createDevice(id, chassisId, type, hw, sw, portCount);
+ nameToId.put(name, id);
+ }
+
+ /**
* Creates a simulated host.
*
* @param hostId host identifier
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/TopologySimulator.java b/providers/null/src/main/java/org/onosproject/provider/nil/TopologySimulator.java
index 62410a3..3a35971 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/TopologySimulator.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/TopologySimulator.java
@@ -204,9 +204,23 @@
* @param portCount number of device ports
*/
public void createDevice(DeviceId id, int chassisId, Device.Type type, int portCount) {
+ createDevice(id, chassisId, type, "0.1", "0.1.2", portCount);
+ }
+
+ /**
+ * Creates simulated device.
+ *
+ * @param id device identifier
+ * @param chassisId chassis identifier number
+ * @param type device type
+ * @param hw hardware revision
+ * @param sw software revision
+ * @param portCount number of device ports
+ */
+ public void createDevice(DeviceId id, int chassisId, Device.Type type,
+ String hw, String sw, int portCount) {
DeviceDescription desc =
- new DefaultDeviceDescription(id.uri(), type,
- "ONF", "0.1", "0.1", "1234",
+ new DefaultDeviceDescription(id.uri(), type, "ONF", hw, sw, "1234",
new ChassisId(chassisId));
deviceIds.add(id);
mastershipAdminService.setRoleSync(localNode, id, MASTER);
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/cli/CreateNullDevice.java b/providers/null/src/main/java/org/onosproject/provider/nil/cli/CreateNullDevice.java
index dc1ff92..acb9d22 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/cli/CreateNullDevice.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/cli/CreateNullDevice.java
@@ -17,6 +17,7 @@
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
import org.onlab.util.Tools;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
@@ -59,6 +60,15 @@
required = false)
String locType = GEO;
+ @Option(name = "-I", aliases = "--id", description = "Device identifier")
+ String id = null;
+
+ @Option(name = "-H", aliases = "--hw", description = "Hardware version")
+ String hw = "0.1";
+
+ @Option(name = "-S", aliases = "--sw", description = "Software version")
+ String sw = "0.1.2";
+
@Override
protected void execute() {
NullProviders service = get(NullProviders.class);
@@ -70,13 +80,14 @@
}
CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
- DeviceId deviceId = sim.nextDeviceId();
+ DeviceId deviceId = id == null ? sim.nextDeviceId() : DeviceId.deviceId(id);
BasicDeviceConfig cfg = cfgService.addConfig(deviceId, BasicDeviceConfig.class);
cfg.name(name);
setUiCoordinates(cfg, locType, latOrY, longOrX);
Tools.delay(10);
- sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()), portCount);
+ sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()),
+ hw, sw, portCount);
}
}