Search in sources :

Example 21 with NetworkConfigService

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);
}
Also used : CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId) NullProviders(org.onosproject.provider.nil.NullProviders) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 22 with NetworkConfigService

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);
        }
    }
}
Also used : PortNumberCompleter(org.onosproject.cli.net.PortNumberCompleter) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Argument(org.apache.karaf.shell.api.action.Argument) Command(org.apache.karaf.shell.api.action.Command) ConnectPoint(org.onosproject.net.ConnectPoint) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Optional(java.util.Optional) Completion(org.apache.karaf.shell.api.action.Completion) Option(org.apache.karaf.shell.api.action.Option) DeviceId(org.onosproject.net.DeviceId) LinkDiscoveryFromPort(org.onosproject.provider.lldp.impl.LinkDiscoveryFromPort) DeviceIdCompleter(org.onosproject.cli.net.DeviceIdCompleter) LinkDiscoveryFromDevice(org.onosproject.provider.lldp.impl.LinkDiscoveryFromDevice) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) LinkDiscoveryFromPort(org.onosproject.provider.lldp.impl.LinkDiscoveryFromPort) DeviceId(org.onosproject.net.DeviceId) DeviceService(org.onosproject.net.device.DeviceService) LinkDiscoveryFromDevice(org.onosproject.provider.lldp.impl.LinkDiscoveryFromDevice) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 23 with NetworkConfigService

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.");
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) Set(java.util.Set) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) RegionId(org.onosproject.net.region.RegionId) BasicRegionConfig(org.onosproject.net.config.basics.BasicRegionConfig)

Example 24 with NetworkConfigService

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();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) ArrayList(java.util.ArrayList) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 25 with NetworkConfigService

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

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