Search in sources :

Example 1 with RegionAdminService

use of org.onosproject.net.region.RegionAdminService in project onos by opennetworkinglab.

the class RegionRemoveDevicesCommand method doExecute.

@Override
protected void doExecute() {
    RegionAdminService service = get(RegionAdminService.class);
    RegionId regionId = RegionId.regionId(id);
    List<DeviceId> dids = devIds.stream().map(s -> DeviceId.deviceId(s)).collect(Collectors.toList());
    service.removeDevices(regionId, dids);
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Argument(org.apache.karaf.shell.api.action.Argument) Completion(org.apache.karaf.shell.api.action.Completion) RegionAdminService(org.onosproject.net.region.RegionAdminService) DeviceId(org.onosproject.net.DeviceId) RegionId(org.onosproject.net.region.RegionId) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) DeviceId(org.onosproject.net.DeviceId) RegionId(org.onosproject.net.region.RegionId)

Example 2 with RegionAdminService

use of org.onosproject.net.region.RegionAdminService in project onos by opennetworkinglab.

the class WipeOutCommand method wipeOutRegions.

private void wipeOutRegions() {
    print("Wiping regions");
    RegionAdminService service = get(RegionAdminService.class);
    service.getRegions().forEach(r -> service.removeRegion(r.id()));
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService)

Example 3 with RegionAdminService

use of org.onosproject.net.region.RegionAdminService in project onos by opennetworkinglab.

the class RegionRemoveCommand method doExecute.

@Override
protected void doExecute() {
    RegionAdminService service = get(RegionAdminService.class);
    RegionId regionId = RegionId.regionId(id);
    service.removeRegion(regionId);
    print("Region with id %s is successfully removed.", regionId);
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) RegionId(org.onosproject.net.region.RegionId)

Example 4 with RegionAdminService

use of org.onosproject.net.region.RegionAdminService in project onos by opennetworkinglab.

the class RegionAddCommand method doExecute.

@Override
protected void doExecute() {
    RegionAdminService service = get(RegionAdminService.class);
    RegionId regionId = RegionId.regionId(id);
    NetworkConfigService cfgService = get(NetworkConfigService.class);
    BasicRegionConfig cfg = cfgService.addConfig(regionId, BasicRegionConfig.class);
    setConfigurationData(cfg);
    List<Set<NodeId>> masters = parseMasterArgs();
    service.createRegion(regionId, name, REGION_TYPE_MAP.get(type), masters);
    print("Region successfully added.");
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) Set(java.util.Set) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) RegionId(org.onosproject.net.region.RegionId) BasicRegionConfig(org.onosproject.net.config.basics.BasicRegionConfig)

Example 5 with RegionAdminService

use of org.onosproject.net.region.RegionAdminService in project onos by opennetworkinglab.

the class RegionUpdateCommand method doExecute.

@Override
protected void doExecute() {
    RegionService regionService = get(RegionService.class);
    RegionAdminService regionAdminService = get(RegionAdminService.class);
    RegionId regionId = RegionId.regionId(id);
    if (regionService.getRegion(regionId) == null) {
        print("The region with id %s does not exist.", regionId);
        return;
    }
    List<Set<NodeId>> masters = Lists.newArrayList();
    Set<NodeId> nodeIds = Sets.newHashSet();
    for (String masterArg : masterArgs) {
        if ("/".equals(masterArg)) {
            masters.add(nodeIds);
            nodeIds = Sets.newHashSet();
        } else {
            nodeIds.add(NodeId.nodeId(masterArg));
        }
    }
    masters.add(nodeIds);
    regionAdminService.updateRegion(regionId, name, REGION_TYPE_MAP.get(type), masters);
    print("Region with id %s is successfully updated.", regionId);
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) Set(java.util.Set) NodeId(org.onosproject.cluster.NodeId) RegionService(org.onosproject.net.region.RegionService) RegionId(org.onosproject.net.region.RegionId)

Aggregations

RegionAdminService (org.onosproject.net.region.RegionAdminService)6 RegionId (org.onosproject.net.region.RegionId)5 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Argument (org.apache.karaf.shell.api.action.Argument)2 Command (org.apache.karaf.shell.api.action.Command)2 Completion (org.apache.karaf.shell.api.action.Completion)2 Service (org.apache.karaf.shell.api.action.lifecycle.Service)2 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)2 DeviceId (org.onosproject.net.DeviceId)2 NodeId (org.onosproject.cluster.NodeId)1 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)1 BasicRegionConfig (org.onosproject.net.config.basics.BasicRegionConfig)1 RegionService (org.onosproject.net.region.RegionService)1