Search in sources :

Example 1 with NetworkConfigService

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

the class AddSpeakerCommand method doExecute.

@Override
protected void doExecute() {
    NetworkConfigService configService = get(NetworkConfigService.class);
    CoreService coreService = get(CoreService.class);
    ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
    BgpConfig config = configService.addConfig(appId, BgpConfig.class);
    if (name != null) {
        BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
        if (speaker != null) {
            log.debug("Speaker already exists: {}", name);
            return;
        }
    }
    if (vlanId == null || vlanId.isEmpty()) {
        vlanIdObj = VlanId.NONE;
    } else {
        vlanIdObj = VlanId.vlanId(Short.valueOf(vlanId));
    }
    addSpeakerToConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());
    print(SPEAKER_ADD_SUCCESS);
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with NetworkConfigService

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

the class BgpSpeakersListCommand method doExecute.

@Override
protected void doExecute() {
    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) {
        print("No speakers configured");
        return;
    }
    List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
    Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
    if (config.bgpSpeakers().isEmpty()) {
        print("No speakers configured");
    } else {
        bgpSpeakers.forEach(s -> {
            if (s.name().isPresent()) {
                print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
            } else {
                print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
            }
        });
    }
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 3 with NetworkConfigService

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

the class RemoveSpeakerCommand method doExecute.

@Override
protected void doExecute() {
    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.peers().isEmpty()) {
            // Removal not allowed when peer connections exist.
            print(PEERS_EXIST, name);
            return;
        }
    }
    removeSpeakerFromConf(config);
    configService.applyConfig(appId, BgpConfig.class, config.node());
    print(SPEAKER_REMOVE_SUCCESS);
}
Also used : BgpConfig(org.onosproject.routing.config.BgpConfig) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) ApplicationId(org.onosproject.core.ApplicationId)

Example 4 with NetworkConfigService

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

the class FibInstallerTest method setUp.

@Before
public void setUp() throws Exception {
    sSfibInstaller = new FibInstaller();
    sSfibInstaller.componentConfigService = createNiceMock(ComponentConfigService.class);
    ComponentContext mockContext = createNiceMock(ComponentContext.class);
    routerConfig = new TestRouterConfig();
    interfaceService = createMock(InterfaceService.class);
    networkConfigService = createMock(NetworkConfigService.class);
    networkConfigService.addListener(anyObject(NetworkConfigListener.class));
    expectLastCall().anyTimes();
    networkConfigRegistry = createMock(NetworkConfigRegistry.class);
    flowObjectiveService = createMock(FlowObjectiveService.class);
    applicationService = createNiceMock(ApplicationService.class);
    replay(applicationService);
    deviceService = new TestDeviceService();
    CoreService coreService = createNiceMock(CoreService.class);
    expect(coreService.registerApplication(anyString())).andReturn(APPID).anyTimes();
    replay(coreService);
    sSfibInstaller.networkConfigService = networkConfigService;
    sSfibInstaller.networkConfigRegistry = networkConfigRegistry;
    sSfibInstaller.interfaceService = interfaceService;
    sSfibInstaller.flowObjectiveService = flowObjectiveService;
    sSfibInstaller.applicationService = applicationService;
    sSfibInstaller.coreService = coreService;
    sSfibInstaller.routeService = new TestRouteService();
    sSfibInstaller.deviceService = deviceService;
    setUpNetworkConfigService();
    setUpInterfaceService();
    sSfibInstaller.activate(mockContext);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ComponentContext(org.osgi.service.component.ComponentContext) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) CoreService(org.onosproject.core.CoreService) InterfaceService(org.onosproject.net.intf.InterfaceService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) ApplicationService(org.onosproject.app.ApplicationService) Before(org.junit.Before)

Example 5 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)

Aggregations

NetworkConfigService (org.onosproject.net.config.NetworkConfigService)31 CoreService (org.onosproject.core.CoreService)9 DeviceId (org.onosproject.net.DeviceId)8 ApplicationId (org.onosproject.core.ApplicationId)7 ConnectPoint (org.onosproject.net.ConnectPoint)6 BgpConfig (org.onosproject.routing.config.BgpConfig)5 DeviceService (org.onosproject.net.device.DeviceService)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 NetworkConfigListener (org.onosproject.net.config.NetworkConfigListener)3 SubjectFactory (org.onosproject.net.config.SubjectFactory)3 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 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 Before (org.junit.Before)2