Search in sources :

Example 1 with DeviceAdminService

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");
    }
}
Also used : Device(org.onosproject.net.Device) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) PortNumber(org.onosproject.net.PortNumber)

Example 2 with DeviceAdminService

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);
        }
    }
}
Also used : Device(org.onosproject.net.Device) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with DeviceAdminService

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();
}
Also used : OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Before(org.junit.Before)

Example 4 with DeviceAdminService

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());
    }
}
Also used : Device(org.onosproject.net.Device) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) GroupService(org.onosproject.net.group.GroupService)

Example 5 with DeviceAdminService

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());
    }
}
Also used : Device(org.onosproject.net.Device) DeviceAdminService(org.onosproject.net.device.DeviceAdminService) MeterService(org.onosproject.net.meter.MeterService)

Aggregations

DeviceAdminService (org.onosproject.net.device.DeviceAdminService)6 Device (org.onosproject.net.Device)5 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Before (org.junit.Before)1 Port (org.onosproject.net.Port)1 PortNumber (org.onosproject.net.PortNumber)1 DeviceService (org.onosproject.net.device.DeviceService)1 FlowRuleService (org.onosproject.net.flow.FlowRuleService)1 GroupService (org.onosproject.net.group.GroupService)1 MeterService (org.onosproject.net.meter.MeterService)1 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)1 OvsdbController (org.onosproject.ovsdb.controller.OvsdbController)1