Search in sources :

Example 11 with NetworkConfigService

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());
}
Also used : EncapsulationType(org.onosproject.net.EncapsulationType) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 12 with NetworkConfigService

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();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SubjectFactory(org.onosproject.net.config.SubjectFactory) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with NetworkConfigService

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();
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DELETE(javax.ws.rs.DELETE)

Example 14 with NetworkConfigService

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();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SubjectFactory(org.onosproject.net.config.SubjectFactory) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with NetworkConfigService

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();
}
Also used : SubjectFactory(org.onosproject.net.config.SubjectFactory) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) JsonNode(com.fasterxml.jackson.databind.JsonNode) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Aggregations

NetworkConfigService (org.onosproject.net.config.NetworkConfigService)34 CoreService (org.onosproject.core.CoreService)10 DeviceId (org.onosproject.net.DeviceId)9 ApplicationId (org.onosproject.core.ApplicationId)7 ConnectPoint (org.onosproject.net.ConnectPoint)6 DeviceService (org.onosproject.net.device.DeviceService)6 BgpConfig (org.onosproject.routing.config.BgpConfig)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 Before (org.junit.Before)3 NetworkConfigListener (org.onosproject.net.config.NetworkConfigListener)3 SubjectFactory (org.onosproject.net.config.SubjectFactory)3 BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Consumes (javax.ws.rs.Consumes)2 DELETE (javax.ws.rs.DELETE)2 GET (javax.ws.rs.GET)2