use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class SdnIpCommand method setEncap.
/**
* Sets the encapsulation type for SDN-IP.
*
* @param encap the encapsulation type
*/
private void setEncap(String encap) {
EncapsulationType encapType = EncapsulationType.enumFromString(encap);
if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) {
print(ENCAP_NOT_FOUND, encap);
return;
}
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(SdnIp.SDN_IP_APP);
SdnIpConfig config = configService.addConfig(appId, SdnIpConfig.class);
config.setEncap(encapType);
config.apply();
// configService.applyConfig(appId, SdnIpConfig.class, config.node());
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method download.
/**
* Gets entire network configuration base.
*
* @return 200 OK with network configuration JSON
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response download() {
NetworkConfigService service = get(NetworkConfigService.class);
ObjectNode root = mapper().createObjectNode();
service.getSubjectClasses().forEach(sc -> {
SubjectFactory subjectFactory = service.getSubjectFactory(sc);
produceJson(service, newObject(root, subjectFactory.subjectClassKey()), subjectFactory, sc);
});
return ok(root).build();
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method delete.
// FIXME: Refactor to allow queued configs to be removed
/**
* Clear entire network configuration base.
*
* @return 204 NO CONTENT
*/
@DELETE
@SuppressWarnings("unchecked")
public Response delete() {
NetworkConfigService service = get(NetworkConfigService.class);
service.removeConfig();
return Response.noContent().build();
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method download.
/**
* Gets all network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @return 200 OK with network configuration JSON
*/
@GET
@Path("{subjectClassKey}/{subjectKey}")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response download(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey) {
NetworkConfigService service = get(NetworkConfigService.class);
ObjectNode root = mapper().createObjectNode();
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotFoundErrorString(subjectClassKey));
produceSubjectJson(service, root, subjectFactory.createSubject(subjectKey), true, subjectNotFoundErrorString(subjectClassKey, subjectKey));
return ok(root).build();
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class NetworkConfigWebResource method upload.
/**
* Upload specific network configuration for a subjectKey.
*
* @param subjectClassKey subjectKey class key
* @param subjectKey subjectKey key
* @param configKey configuration class key
* @param request network configuration JSON rooted at the top node
* @return 200 OK
* @throws IOException if unable to parse the request
*/
@POST
@Path("{subjectClassKey}/{subjectKey}/{configKey}")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectClassKey") String subjectClassKey, @PathParam("subjectKey") String subjectKey, @PathParam("configKey") String configKey, InputStream request) throws IOException {
NetworkConfigService service = get(NetworkConfigService.class);
JsonNode root = readTreeFromStream(mapper(), request);
SubjectFactory subjectFactory = nullIsNotFound(service.getSubjectFactory(subjectClassKey), subjectClassNotValidErrorString(subjectClassKey));
service.applyConfig(subjectClassKey, subjectFactory.createSubject(subjectKey), configKey, root);
return Response.ok().build();
}
Aggregations