Search in sources :

Example 6 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