Search in sources :

Example 1 with RegionService

use of org.onosproject.net.region.RegionService 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)

Example 2 with RegionService

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

the class LayoutAddCommand method doExecute.

@Override
protected void doExecute() {
    UiTopoLayoutService service = get(UiTopoLayoutService.class);
    RegionService regionService = get(RegionService.class);
    UiTopoLayout layout;
    if (ROOT.equals(id)) {
        layout = service.getRootLayout();
        setAppropriateBackground(layout);
        setZoomParameters(layout);
        return;
    }
    // Otherwise, it is a user-defined layout...
    Region region = nullToken(regionId) ? null : regionService.getRegion(regionId(regionId));
    UiTopoLayoutId pid = nullToken(parentId) ? UiTopoLayoutId.DEFAULT_ID : layoutId(parentId);
    layout = new UiTopoLayout(layoutId(id)).region(region).parent(pid);
    setAppropriateBackground(layout);
    setZoomParameters(layout);
    service.addLayout(layout);
}
Also used : UiTopoLayoutService(org.onosproject.ui.UiTopoLayoutService) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) Region(org.onosproject.net.region.Region) RegionService(org.onosproject.net.region.RegionService) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout)

Aggregations

RegionService (org.onosproject.net.region.RegionService)2 Set (java.util.Set)1 NodeId (org.onosproject.cluster.NodeId)1 Region (org.onosproject.net.region.Region)1 RegionAdminService (org.onosproject.net.region.RegionAdminService)1 RegionId (org.onosproject.net.region.RegionId)1 UiTopoLayoutService (org.onosproject.ui.UiTopoLayoutService)1 UiTopoLayout (org.onosproject.ui.model.topo.UiTopoLayout)1 UiTopoLayoutId (org.onosproject.ui.model.topo.UiTopoLayoutId)1