use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class CreateNullDevice method doExecute.
@Override
protected void doExecute() {
NullProviders service = get(NullProviders.class);
NetworkConfigService cfgService = get(NetworkConfigService.class);
TopologySimulator simulator = service.currentSimulator();
if (!validateSimulator(simulator) || !validateLocType(locType)) {
return;
}
CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
DeviceId deviceId = id == null ? sim.nextDeviceId() : DeviceId.deviceId(id);
BasicDeviceConfig cfg = cfgService.addConfig(deviceId, BasicDeviceConfig.class);
cfg.name(name);
setUiCoordinates(cfg, locType, latOrY, longOrX);
Tools.delay(10);
sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()), hw, sw, portCount);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ConfigLinkDiscoveryCommand method doExecute.
@Override
protected void doExecute() {
DeviceService deviceService = get(DeviceService.class);
NetworkConfigService netcfgService = get(NetworkConfigService.class);
DeviceId did = DeviceId.deviceId(device);
ConnectPoint cp = Optional.ofNullable(port).map(PortNumber::fromString).map(pn -> new ConnectPoint(did, pn)).orElse(null);
if (cp == null) {
// device config
if (!remove) {
if (deviceService.getDevice(did) == null) {
print("[WARN] configuring about unknown device %s", did);
}
LinkDiscoveryFromDevice cfg;
cfg = netcfgService.addConfig(did, LinkDiscoveryFromDevice.class);
cfg.enabled(enable);
cfg.apply();
} else {
netcfgService.removeConfig(did, LinkDiscoveryFromDevice.class);
}
} else {
// port config
if (!remove) {
if (deviceService.getPort(cp) == null) {
print("[WARN] configuring about unknown port %s", cp);
}
LinkDiscoveryFromPort cfg;
cfg = netcfgService.addConfig(cp, LinkDiscoveryFromPort.class);
cfg.enabled(enable);
cfg.apply();
} else {
netcfgService.removeConfig(cp, LinkDiscoveryFromPort.class);
}
}
}
use of org.onosproject.net.config.NetworkConfigService 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.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method upload.
/**
* Uploads bulk network configuration.
*
* @param request network configuration JSON rooted at the top node
* @return 200 OK
* @throws IOException if unable to parse the request
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(InputStream request) throws IOException {
NetworkConfigService service = get(NetworkConfigService.class);
ObjectNode root = readTreeFromStream(mapper(), request);
List<String> errorMsgs = new ArrayList<String>();
root.fieldNames().forEachRemaining(sk -> {
if (service.getSubjectFactory(sk) == null) {
errorMsgs.add(subjectClassNotValidErrorString(sk));
} else if (!root.path(sk).isObject()) {
errorMsgs.add(subjectClassInvalidErrorString(sk));
} else {
errorMsgs.addAll(consumeJson(service, (ObjectNode) root.path(sk), service.getSubjectFactory(sk)));
}
});
if (!errorMsgs.isEmpty()) {
return Response.status(MULTI_STATUS_RESPONE).entity(produceErrorJson(errorMsgs)).build();
}
return Response.ok().build();
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method delete.
/**
* Clear specific network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @param configKey configuration class key
* @return 204 NO CONTENT
*/
@DELETE
@Path("{subjectClassKey}/{subjectKey}/{configKey}")
@SuppressWarnings("unchecked")
public Response delete(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey) {
NetworkConfigService service = get(NetworkConfigService.class);
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotValidErrorString(subjectClassKey));
service.removeConfig(subjectClassKey, subjectFactory.createSubject(subjectKey), configKey);
return Response.noContent().build();
}
Aggregations