use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class ModelCache method updateDevice.
// make sure the UiDevice is tagged with the region it belongs to
private void updateDevice(UiDevice device) {
Region r = services.region().getRegionForDevice(device.id());
RegionId rid = r == null ? UiRegion.NULL_ID : r.id();
device.setRegionId(rid);
}
use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class ModelCache method updateRegion.
private void updateRegion(UiRegion region) {
RegionId rid = region.id();
Set<DeviceId> deviceIds = services.region().getRegionDevices(rid);
Set<HostId> hostIds = services.region().getRegionHosts(rid);
// Make sure device objects refer to their region
deviceIds.forEach(d -> {
UiDevice dev = uiTopology.findDevice(d);
if (dev != null) {
dev.setRegionId(rid);
} else {
// if we don't have the UiDevice in the topology, what can we do?
log.warn("Region device {}, but we don't have UiDevice in topology", d);
}
});
hostIds.forEach(d -> {
UiHost host = uiTopology.findHost(d);
if (host != null) {
host.setRegionId(rid);
} else {
// if we don't have the UiDevice in the topology, what can we do?
log.warn("Region host {}, but we don't have UiHost in topology", d);
}
});
// Make sure the region object refers to the devices
region.reconcileDevices(deviceIds);
region.reconcileHosts(hostIds);
fixupContainmentHierarchy(region);
}
use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class RegionCodec method decode.
@Override
public Region decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
// parse masters
List<Set<NodeId>> masters = new ArrayList<>();
JsonNode mastersJson = json.get(MASTERS);
checkNotNull(mastersJson);
IntStream.range(0, mastersJson.size()).forEach(i -> {
JsonNode setsJson = mastersJson.get(i);
final Set<NodeId> nodeIds = Sets.newHashSet();
if (setsJson != null && setsJson.isArray()) {
Set<NodeId> localNodeIds = Sets.newHashSet();
IntStream.range(0, setsJson.size()).forEach(j -> {
JsonNode nodeIdJson = setsJson.get(j);
localNodeIds.add(decodeNodeId(nodeIdJson));
});
nodeIds.addAll(localNodeIds);
}
masters.add(nodeIds);
});
RegionId regionId = RegionId.regionId(extractMember(REGION_ID, json));
String name = extractMember(NAME, json);
Region.Type type = REGION_TYPE_MAP.get(extractMember(TYPE, json));
Annotations annots = extractAnnotations(json, context);
return new DefaultRegion(regionId, name, type, annots, masters);
}
use of org.onosproject.net.region.RegionId 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.");
}
use of org.onosproject.net.region.RegionId in project onos by opennetworkinglab.
the class RegionAddDevicesCommand 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.addDevices(regionId, dids);
}
Aggregations