Search in sources :

Example 11 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpticalCircuitIntentCompilerTest method setUp.

@Before
public void setUp() {
    sut = new OpticalCircuitIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
    sut.coreService = coreService;
    sut.deviceService = new MockDeviceService();
    sut.resourceService = new MockResourceService();
    sut.intentService = new TestIntentService();
    sut.intentSetMultimap = new MockIntentSetMultimap();
    super.setUp();
    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(OpticalCircuitIntent.class, sut);
    intentExtensionService.unregisterCompiler(OpticalCircuitIntent.class);
    sut.intentManager = intentExtensionService;
    replay(coreService, intentExtensionService);
    // mocking ComponentConfigService
    ComponentConfigService mockConfigService = EasyMock.createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(sut.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(sut.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    sut.cfgService = mockConfigService;
    replay(mockConfigService);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) MockResourceService(org.onosproject.net.resource.MockResourceService) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) CoreService(org.onosproject.core.CoreService) Before(org.junit.Before)

Example 12 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackManagementWebResource method configStatefulSnatBase.

private void configStatefulSnatBase(boolean snatFlag) {
    ComponentConfigService service = get(ComponentConfigService.class);
    String snatComponent = OpenstackRoutingSnatHandler.class.getName();
    service.setProperty(snatComponent, USE_STATEFUL_SNAT_NAME, String.valueOf(snatFlag));
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService)

Example 13 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackManagementWebResource method configArpModeBase.

private void configArpModeBase(String arpMode) {
    ComponentConfigService service = get(ComponentConfigService.class);
    String switchingComponent = OpenstackSwitchingArpHandler.class.getName();
    String routingComponent = OpenstackRoutingArpHandler.class.getName();
    service.setProperty(switchingComponent, ARP_MODE_NAME, arpMode);
    service.setProperty(routingComponent, ARP_MODE_NAME, arpMode);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService)

Example 14 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackManagementWebResource method configStatefulSnat.

/**
 * Configures the stateful SNAT flag (enable | disable).
 *
 * @param statefulSnat stateful SNAT flag
 * @return 200 OK with config result, 404 not found
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("config/statefulSnat/{statefulSnat}")
public Response configStatefulSnat(@PathParam("statefulSnat") String statefulSnat) {
    String statefulSnatStr = nullIsIllegal(statefulSnat, STATEFUL_SNAT_REQUIRED);
    boolean flag = checkActivationFlag(statefulSnatStr);
    configStatefulSnatBase(flag);
    ComponentConfigService service = get(ComponentConfigService.class);
    String snatComponent = OpenstackRoutingSnatHandler.class.getName();
    while (true) {
        boolean snatValue = getPropertyValueAsBoolean(service.getProperties(snatComponent), USE_STATEFUL_SNAT_NAME);
        if (flag == snatValue) {
            break;
        }
    }
    purgeRulesBase();
    syncRulesBase();
    return ok(mapper().createObjectNode()).build();
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with ComponentConfigService

use of org.onosproject.cfg.ComponentConfigService in project onos by opennetworkinglab.

the class OpenstackManagementWebResource method configSecurityGroup.

/**
 * Configures the security group (enable | disable).
 *
 * @param securityGroup security group activation flag
 * @return 200 OK with config result, 404 not found
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("config/securityGroup/{securityGroup}")
public Response configSecurityGroup(@PathParam("securityGroup") String securityGroup) {
    String securityGroupStr = nullIsIllegal(securityGroup, SECURITY_GROUP_FLAG_REQUIRED);
    boolean flag = checkActivationFlag(securityGroupStr);
    ComponentConfigService service = get(ComponentConfigService.class);
    String securityGroupComponent = OpenstackSecurityGroupHandler.class.getName();
    service.setProperty(securityGroupComponent, USE_SECURITY_GROUP_NAME, String.valueOf(flag));
    return ok(mapper().createObjectNode()).build();
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ComponentConfigService (org.onosproject.cfg.ComponentConfigService)27 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 GET (javax.ws.rs.GET)7 Before (org.junit.Before)5 CoreService (org.onosproject.core.CoreService)4 Hashtable (java.util.Hashtable)3 Consumes (javax.ws.rs.Consumes)3 ComponentContext (org.osgi.service.component.ComponentContext)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 POST (javax.ws.rs.POST)2 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)2 EasyMock.anyObject (org.easymock.EasyMock.anyObject)2 ConfigProperty (org.onosproject.cfg.ConfigProperty)2 NullProviders (org.onosproject.provider.nil.NullProviders)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DELETE (javax.ws.rs.DELETE)1