Search in sources :

Example 11 with RegionId

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

the class RegionsWebResource method getRegionById.

/**
 * Returns the region with the specified identifier.
 *
 * @param regionId region identifier
 * @return 200 OK with a region, 404 not found
 * @onos.rsModel Region
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{regionId}")
public Response getRegionById(@PathParam("regionId") String regionId) {
    final RegionId rid = RegionId.regionId(regionId);
    final Region region = nullIsNotFound(regionService.getRegion(rid), REGION_NOT_FOUND + rid.toString());
    return ok(codec(Region.class).encode(region, this)).build();
}
Also used : Region(org.onosproject.net.region.Region) RegionId(org.onosproject.net.region.RegionId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 12 with RegionId

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

the class UiTopoSession method navToRegion.

/**
 * Navigates to the specified region by setting the associated layout as
 * current.
 *
 * @param regionId region identifier
 */
public void navToRegion(String regionId) {
    // 1. find the layout corresponding to the region ID
    // 2. set this layout to be "current"
    RegionId r = RegionId.regionId(regionId);
    UiTopoLayout layout = layoutService.getLayout(r);
    setCurrentLayout(layout);
}
Also used : RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout)

Example 13 with RegionId

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

the class UiTopoSession method getPeerNodes.

/**
 * Returns the regions/devices that are "peers" to this region. That is,
 * based on the layout the user is viewing, all the regions/devices that
 * are associated with layouts that share the same parent layout as this
 * layout, AND that are linked to an element within this region.
 *
 * @param layout the layout being viewed
 * @return all regions/devices that are "siblings" to this layout's region
 */
public Set<UiNode> getPeerNodes(UiTopoLayout layout) {
    Set<UiNode> peers = new HashSet<>();
    // first, get the peer regions
    Set<UiTopoLayout> peerLayouts = layoutService.getPeerLayouts(layout.id());
    peerLayouts.forEach(l -> {
        RegionId peerRegion = l.regionId();
        peers.add(sharedModel.getRegion(peerRegion));
    });
    // now add the devices that reside in the parent region
    if (!layout.isRoot()) {
        UiTopoLayout parentLayout = layoutService.getLayout(layout.parent());
        peers.addAll(getRegion(parentLayout).devices());
    }
    // directly to this region by an implicit link
    return peers;
}
Also used : RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) UiNode(org.onosproject.ui.model.topo.UiNode) HashSet(java.util.HashSet)

Example 14 with RegionId

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

the class ModelCache method fixupContainmentHierarchy.

private void fixupContainmentHierarchy(UiRegion region) {
    UiTopoLayoutService ls = services.layout();
    RegionId regionId = region.id();
    UiTopoLayout layout = ls.getLayout(regionId);
    if (layout == null) {
        // no layout backed by this region
        log.warn("No layout backed by region {}", regionId);
        return;
    }
    UiTopoLayoutId layoutId = layout.id();
    if (!layout.isRoot()) {
        UiTopoLayoutId parentId = layout.parent();
        UiTopoLayout parentLayout = ls.getLayout(parentId);
        RegionId parentRegionId = parentLayout.regionId();
        region.setParent(parentRegionId);
    }
    Set<UiTopoLayout> kids = ls.getChildren(layoutId);
    Set<RegionId> kidRegionIds = new HashSet<>(kids.size());
    kids.forEach(k -> kidRegionIds.add(k.regionId()));
    region.setChildren(kidRegionIds);
}
Also used : UiTopoLayoutService(org.onosproject.ui.UiTopoLayoutService) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) HashSet(java.util.HashSet)

Example 15 with RegionId

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

the class ModelCache method removeRegion.

// invoked from UiSharedTopologyModel region listener
void removeRegion(Region region) {
    RegionId id = region.id();
    UiRegion uiRegion = uiTopology.findRegion(id);
    if (uiRegion != null) {
        uiTopology.remove(uiRegion);
        postEvent(REGION_REMOVED, uiRegion, MEMO_REMOVED);
    } else {
        log.warn(E_NO_ELEMENT, "region", id);
    }
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion) RegionId(org.onosproject.net.region.RegionId)

Aggregations

RegionId (org.onosproject.net.region.RegionId)25 DeviceId (org.onosproject.net.DeviceId)7 Region (org.onosproject.net.region.Region)7 Set (java.util.Set)5 Path (javax.ws.rs.Path)5 RegionAdminService (org.onosproject.net.region.RegionAdminService)5 HashSet (java.util.HashSet)4 NodeId (org.onosproject.cluster.NodeId)4 UiRegion (org.onosproject.ui.model.topo.UiRegion)4 Produces (javax.ws.rs.Produces)3 Annotations (org.onosproject.net.Annotations)3 DefaultRegion (org.onosproject.net.region.DefaultRegion)3 UiTopoLayout (org.onosproject.ui.model.topo.UiTopoLayout)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)2