Search in sources :

Example 26 with NetworkConfigService

use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.

the class ConfigFlowRuleProgrammable method getFlowTableConfig.

private Optional<FlowTableConfig> getFlowTableConfig() {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    DeviceId did = data().deviceId();
    return Optional.ofNullable(netcfg.getConfig(did, FlowTableConfig.class));
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId)

Example 27 with NetworkConfigService

use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.

the class ConfigFlowRuleProgrammable method createFlowTableConfig.

private Optional<FlowTableConfig> createFlowTableConfig() {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    DeviceId did = data().deviceId();
    return Optional.ofNullable(netcfg.addConfig(did, FlowTableConfig.class));
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId)

Example 28 with NetworkConfigService

use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.

the class ConfigOpticalDeviceDiscovery method discoverPortDetails.

@Override
public List<PortDescription> discoverPortDetails() {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    DeviceId did = data().deviceId();
    DeviceInjectionConfig cfg = netcfg.getConfig(did, DeviceInjectionConfig.class);
    if (cfg == null) {
        return ImmutableList.of();
    }
    String ports = cfg.ports();
    // TODO: parse port format like [1-3,6] in the future
    int numPorts = Integer.parseInt(ports);
    List<PortDescription> portDescs = new ArrayList<>(numPorts);
    for (int i = 1; i <= numPorts; ++i) {
        PortNumber number = PortNumber.portNumber(i);
        ConnectPoint cp = new ConnectPoint(did, number);
        Optional<OpticalPortConfig> port = Optional.ofNullable(netcfg.getConfig(cp, OpticalPortConfig.class));
        boolean isEnabled = true;
        // default packet port speed on configured-optical device (in Mbps)
        int speedFallback = 10_000;
        long portSpeed = port.flatMap(OpticalPortConfig::speed).orElse(speedFallback);
        Port.Type type = port.map(OpticalPortConfig::type).orElse(Port.Type.COPPER);
        portDescs.add(DefaultPortDescription.builder().withPortNumber(number).isEnabled(isEnabled).type(type).portSpeed(portSpeed).build());
    }
    return portDescs;
}
Also used : NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) ArrayList(java.util.ArrayList) OpticalPortConfig(org.onosproject.net.optical.config.OpticalPortConfig) DeviceInjectionConfig(org.onosproject.net.config.inject.DeviceInjectionConfig) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) PortDescription(org.onosproject.net.device.PortDescription) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) PortNumber(org.onosproject.net.PortNumber)

Example 29 with NetworkConfigService

use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.

the class ConfigLambdaQuery method queryLambdas.

@Override
public Set<OchSignal> queryLambdas(PortNumber port) {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    ConnectPoint cp = new ConnectPoint(data().deviceId(), port);
    LambdaConfig cfg = netcfg.getConfig(cp, LambdaConfig.class);
    if (cfg == null) {
        return ImmutableSet.of();
    }
    GridType type = cfg.gridType();
    Optional<ChannelSpacing> dwdmSpacing = cfg.dwdmSpacing();
    int start = cfg.slotStart();
    int step = cfg.slotStep();
    int end = cfg.slotEnd();
    Set<OchSignal> lambdas = new LinkedHashSet<>();
    for (int i = start; i <= end; i += step) {
        switch(type) {
            case DWDM:
                lambdas.add(OchSignal.newDwdmSlot(dwdmSpacing.get(), i));
                break;
            case FLEX:
                lambdas.add(OchSignal.newFlexGridSlot(i));
                break;
            case CWDM:
            default:
                log.warn("Unsupported grid type: {}", type);
                break;
        }
    }
    return lambdas;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ChannelSpacing(org.onosproject.net.ChannelSpacing) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) OchSignal(org.onosproject.net.OchSignal) LambdaConfig(org.onosproject.driver.optical.config.LambdaConfig) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 30 with NetworkConfigService

use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.

the class AddPeerCommand method doExecute.

@Override
protected void doExecute() {
    peerAddress = IpAddress.valueOf(ip);
    NetworkConfigService configService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
    BgpConfig config = configService.getConfig(appId, BgpConfig.class);
    if (config == null || config.bgpSpeakers().isEmpty()) {
        print(NO_CONFIGURATION);
        return;
    }
    BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
    if (speaker == null) {
        print(SPEAKER_NOT_FOUND, name);
        return;
    } else {
        if (speaker.isConnectedToPeer(peerAddress)) {
            // Peering already exists.
            return;
        }
    }
    InterfaceService interfaceService = get(InterfaceService.class);
    if (interfaceService.getMatchingInterface(peerAddress) == null) {
        print(NO_INTERFACE, ip);
        return;
    }
    addPeerToSpeakerConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());
    print(PEER_ADD_SUCCESS);
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) InterfaceService(org.onosproject.net.intf.InterfaceService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

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