Search in sources :

Example 1 with NetworkConfigRegistry

use of org.onosproject.net.config.NetworkConfigRegistry 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 2 with NetworkConfigRegistry

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

the class SubjectKeyCompleter method choices.

@Override
protected List<String> choices() {
    NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
    String subjectClassKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1];
    SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey);
    if (subjectFactory == null) {
        return Collections.emptyList();
    }
    // get all registered subject objects.
    Set<Object> subjects = service.getSubjects(subjectFactory.subjectClass());
    return subjects.stream().map(subjectFactory::subjectKey).collect(Collectors.toList());
}
Also used : SubjectFactory(org.onosproject.net.config.SubjectFactory) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry)

Example 3 with NetworkConfigRegistry

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

the class TestCodecService method setup.

@Before
public void setup() throws IOException {
    storageService = new TestStorageService();
    mastershipService = createNiceMock(MastershipService.class);
    coreService = createNiceMock(CoreService.class);
    hostService = createNiceMock(HostService.class);
    deviceService = createNiceMock(DeviceService.class);
    expect(deviceService.getDevices()).andReturn(ImmutableList.of()).anyTimes();
    networkConfigRegistry = createNiceMock(NetworkConfigRegistry.class);
    networkConfigService = createNiceMock(NetworkConfigService.class);
    manager = new SimpleIntManager();
    manager.coreService = coreService;
    manager.deviceService = deviceService;
    manager.storageService = storageService;
    manager.mastershipService = mastershipService;
    manager.hostService = hostService;
    manager.netcfgService = networkConfigService;
    manager.netcfgRegistry = networkConfigRegistry;
    manager.eventExecutor = MoreExecutors.newDirectExecutorService();
    manager.codecService = codecService;
    expect(coreService.registerApplication(APP_NAME)).andReturn(APP_ID).anyTimes();
    networkConfigRegistry.registerConfigFactory(anyObject());
    expectLastCall().once();
    Capture<NetworkConfigListener> capture = newCapture();
    networkConfigService.addListener(EasyMock.capture(capture));
    expectLastCall().once();
    IntReportConfig config = getIntReportConfig("/report-config.json");
    expect(networkConfigService.getConfig(APP_ID, IntReportConfig.class)).andReturn(config).anyTimes();
    replay(mastershipService, deviceService, coreService, hostService, networkConfigRegistry, networkConfigService);
    manager.activate();
    networkConfigListener = capture.getValue();
}
Also used : HostService(org.onosproject.net.host.HostService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) TestStorageService(org.onosproject.store.service.TestStorageService) DeviceService(org.onosproject.net.device.DeviceService) CoreService(org.onosproject.core.CoreService) MastershipService(org.onosproject.mastership.MastershipService) IntReportConfig(org.onosproject.net.behaviour.inbandtelemetry.IntReportConfig) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) Before(org.junit.Before)

Example 4 with NetworkConfigRegistry

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

the class ConfigKeyCompleter method choices.

// FIXME ConfigKeyCompleter never gets called??
@Override
protected List<String> choices() {
    NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
    checkArgument(commandLine.getCursorArgumentIndex() >= 2);
    String subjectClassKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 2];
    SubjectFactory<?> subjectFactory = service.getSubjectFactory(subjectClassKey);
    if (subjectFactory == null) {
        return ImmutableList.of();
    }
    String subjectKey = commandLine.getArguments()[commandLine.getCursorArgumentIndex() - 1];
    Object subject = subjectFactory.createSubject(subjectKey);
    Set<? extends Config<Object>> configs = service.getConfigs(subject);
    return configs.stream().map(Config::key).collect(Collectors.toList());
}
Also used : NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry)

Example 5 with NetworkConfigRegistry

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

the class OpenFlowControllerImplTest method setUp.

/**
 * Sets up switches to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        switch1 = new OpenflowSwitchDriverAdapter();
        dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
        switch2 = new OpenflowSwitchDriverAdapter();
        dpid2 = Dpid.dpid(new URI("of:0000000000000222"));
        switch3 = new OpenflowSwitchDriverAdapter();
        dpid3 = Dpid.dpid(new URI("of:0000000000000333"));
    } catch (URISyntaxException ex) {
        // Does not happen
        fail();
    }
    controller = new OpenFlowControllerImpl();
    agent = controller.agent;
    switchListener = new TestSwitchListener();
    controller.addListener(switchListener);
    CoreService mockCoreService = EasyMock.createMock(CoreService.class);
    controller.coreService = mockCoreService;
    OpenFlowService mockOpenFlowService = EasyMock.createMock(OpenFlowService.class);
    controller.openFlowManager = mockOpenFlowService;
    ComponentConfigService mockConfigService = EasyMock.createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(controller.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(controller.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    controller.cfgService = mockConfigService;
    replay(mockConfigService);
    NetworkConfigRegistry netConfigService = EasyMock.createMock(NetworkConfigRegistry.class);
    controller.netCfgService = netConfigService;
    ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("openflowPorts", Integer.toString(EPHEMERAL_PORT));
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    controller.activate(mockContext);
}
Also used : OpenFlowService(org.onosproject.openflow.controller.OpenFlowService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) CoreService(org.onosproject.core.CoreService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) EasyMock.anyObject(org.easymock.EasyMock.anyObject) Before(org.junit.Before)

Aggregations

NetworkConfigRegistry (org.onosproject.net.config.NetworkConfigRegistry)5 Before (org.junit.Before)3 CoreService (org.onosproject.core.CoreService)3 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)2 NetworkConfigListener (org.onosproject.net.config.NetworkConfigListener)2 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)2 ComponentContext (org.osgi.service.component.ComponentContext)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Hashtable (java.util.Hashtable)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 ApplicationService (org.onosproject.app.ApplicationService)1 MastershipService (org.onosproject.mastership.MastershipService)1 IntReportConfig (org.onosproject.net.behaviour.inbandtelemetry.IntReportConfig)1 SubjectFactory (org.onosproject.net.config.SubjectFactory)1 DeviceService (org.onosproject.net.device.DeviceService)1 FlowObjectiveService (org.onosproject.net.flowobjective.FlowObjectiveService)1 HostService (org.onosproject.net.host.HostService)1 InterfaceService (org.onosproject.net.intf.InterfaceService)1 OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)1