use of org.onosproject.net.device.DeviceAdminService in project onos by opennetworkinglab.
the class DevicePortStateCommand method doExecute.
@Override
protected void doExecute() {
DeviceService deviceService = get(DeviceService.class);
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
if (dev == null) {
print(" %s", "Device does not exist");
return;
}
PortNumber pnum = PortNumber.fromString(portNumber);
Port p = deviceService.getPort(dev.id(), pnum);
if (p == null) {
print(" %s", "Port does not exist");
return;
}
if ("enable".equals(portState)) {
deviceAdminService.changePortState(dev.id(), p.number(), true);
} else if ("disable".equals(portState)) {
deviceAdminService.changePortState(dev.id(), p.number(), false);
} else {
print(" %s", "State must be enable or disable");
}
}
use of org.onosproject.net.device.DeviceAdminService in project onos by opennetworkinglab.
the class WipeOutCommand method wipeOutDevices.
private void wipeOutDevices() {
print("Wiping devices");
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
while (deviceAdminService.getDeviceCount() > 0) {
try {
for (Device device : deviceAdminService.getDevices()) {
deviceAdminService.removeDevice(device.id());
}
} catch (Exception e) {
log.info("Unable to wipe-out devices", e);
}
}
}
use of org.onosproject.net.device.DeviceAdminService in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandlerTest method setUp.
@Before
public void setUp() throws Exception {
DeviceAdminService mockDeviceAdminService = createMock(DeviceAdminService.class);
mockDeviceAdminService.removeDevice(anyObject());
replay(mockDeviceAdminService);
OvsdbClientService mockOvsdbClient = createMock(OvsdbClientService.class);
expect(mockOvsdbClient.isConnected()).andReturn(true).anyTimes();
replay(mockOvsdbClient);
OvsdbController mockOvsdbController = createMock(OvsdbController.class);
expect(mockOvsdbController.getOvsdbClient(anyObject())).andReturn(mockOvsdbClient).anyTimes();
replay(mockOvsdbController);
testNodeManager = new TestOpenstackNodeManager();
target = new DefaultOpenstackNodeHandler();
target.coreService = new TestCoreService();
target.leadershipService = new TestLeadershipService();
target.clusterService = new TestClusterService();
target.deviceService = TEST_DEVICE_SERVICE;
target.deviceAdminService = mockDeviceAdminService;
target.ovsdbController = mockOvsdbController;
target.osNodeService = testNodeManager;
target.osNodeAdminService = testNodeManager;
target.componentConfigService = new TestComponentConfigService();
TestUtils.setField(target, "eventExecutor", MoreExecutors.newDirectExecutorService());
target.activate();
}
use of org.onosproject.net.device.DeviceAdminService in project onos by opennetworkinglab.
the class WipeOutCommand method wipeOutGroups.
private void wipeOutGroups() {
print("Wiping groups");
GroupService groupService = get(GroupService.class);
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
for (Device device : deviceAdminService.getDevices()) {
groupService.purgeGroupEntries(device.id());
}
}
use of org.onosproject.net.device.DeviceAdminService in project onos by opennetworkinglab.
the class WipeOutCommand method wipeOutMeters.
private void wipeOutMeters() {
print("Wiping meters");
MeterService meterService = get(MeterService.class);
DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
for (Device device : deviceAdminService.getDevices()) {
meterService.purgeMeters(device.id());
}
}
Aggregations