Search in sources :

Example 21 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class DistributedSecurityModeStoreTest method setUp.

@Before
public void setUp() throws Exception {
    appId = new DefaultApplicationId(1, "test");
    testPermissions = new HashSet<Permission>();
    testPermission = new Permission("testClass", "testName");
    testPermissions.add(testPermission);
    testFeatures = new ArrayList<String>();
    testFeatures.add("testFeature");
    testRequiredApps = new ArrayList<String>();
    testRequiredApps.add("testRequiredApp");
    app = DefaultApplication.builder().withAppId(appId).withVersion(Version.version(1, 1, "patch", "build")).withTitle("testTitle").withDescription("testDes").withOrigin("testOri").withCategory("testCT").withUrl("testurl").withReadme("test").withIcon(null).withRole(ApplicationRole.ADMIN).withPermissions(testPermissions).withFeaturesRepo(Optional.ofNullable(null)).withFeatures(testFeatures).withRequiredApps(testRequiredApps).build();
    testLocations = new HashSet<String>();
    testLocations.add("locationA");
    testLocations.add("locationB");
    Set<ApplicationId> appIdSet = new HashSet<ApplicationId>();
    appIdSet.add(appId);
    localBundleAppDirectory = new ConcurrentHashMap<>();
    localBundleAppDirectory.put("testLocation", appIdSet);
    localAppBundleDirectory = new ConcurrentHashMap<>();
    localAppBundleDirectory.put(appId, testLocations);
    violations = new ConcurrentHashMap<ApplicationId, Set<Permission>>();
    violations.put(appId, testPermissions);
    testSecInfo = new SecurityInfo(testPermissions, SECURED);
    states = new ConcurrentHashMap<ApplicationId, SecurityInfo>();
    states.put(appId, testSecInfo);
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Permission(org.onosproject.security.Permission) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 22 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class SecurityModeManagerTest method testGetPrintableRequestedPermissions.

@Test
public void testGetPrintableRequestedPermissions() {
    DefaultApplicationId appIdViolation;
    appIdViolation = new DefaultApplicationId(2, "violation");
    Map<Integer, List<Permission>> result = getPrintablePermissionMap(store.getRequestedPermissions(appIdViolation));
    assertNotNull(result.get(2).get(0));
    assertTrue(result.get(2).size() > 0);
    assertEquals("testNameViolation", result.get(2).get(0).getName());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 23 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class ForwardingObjectiveCodecTest method testForwardingObjectiveDecode.

/**
 * Test decoding of a ForwardingObjective object.
 */
@Test
public void testForwardingObjectiveDecode() throws IOException {
    ApplicationId appId = new DefaultApplicationId(0, SAMPLE_APP_ID);
    expect(mockCoreService.registerApplication(SAMPLE_APP_ID)).andReturn(appId).anyTimes();
    replay(mockCoreService);
    ForwardingObjective forwardingObjective = getForwardingObjective("ForwardingObjective.json");
    assertThat(forwardingObjective.flag(), is(ForwardingObjective.Flag.SPECIFIC));
    assertThat(forwardingObjective.priority(), is(60));
    assertThat(forwardingObjective.timeout(), is(1));
    assertThat(forwardingObjective.op(), is(ForwardingObjective.Operation.ADD));
    assertThat(forwardingObjective.permanent(), is(false));
    assertThat(forwardingObjective.appId().name(), is(SAMPLE_APP_ID));
}
Also used : DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) ForwardingObjectiveJsonMatcher.matchesForwardingObjective(org.onosproject.codec.impl.ForwardingObjectiveJsonMatcher.matchesForwardingObjective) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 24 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class TunnelBorrowCommand method doExecute.

@Override
protected void doExecute() {
    Collection<Tunnel> tunnelSet = null;
    Tunnel.Type trueType = null;
    TunnelService service = get(TunnelService.class);
    ApplicationId appId = new DefaultApplicationId(1, consumerId);
    ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
    if (!isNull(src) && !isNull(dst) && !isNull(type)) {
        TunnelEndPoint srcPoint = null;
        TunnelEndPoint dstPoint = null;
        if ("MPLS".equals(type)) {
            trueType = Tunnel.Type.MPLS;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("VXLAN".equals(type)) {
            trueType = Tunnel.Type.VXLAN;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("GRE".equals(type)) {
            trueType = Tunnel.Type.GRE;
            srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
            dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
        } else if ("VLAN".equals(type)) {
            trueType = Tunnel.Type.VLAN;
            String[] srcArray = src.split("-");
            String[] dstArray = dst.split("-");
            srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, null, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, null, OpticalLogicId.logicId(0), true);
        } else if ("ODUK".equals(type)) {
            trueType = Tunnel.Type.ODUK;
            String[] srcArray = src.split("-");
            String[] dstArray = dst.split("-");
            srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
        } else if ("OCH".equals(type)) {
            trueType = Tunnel.Type.OCH;
            String[] srcArray = src.split("-");
            String[] dstArray = dst.split("-");
            srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
            dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
        } else {
            print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
            return;
        }
        tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType);
    }
    if (!isNull(tunnelId)) {
        TunnelId id = TunnelId.valueOf(tunnelId);
        Tunnel tunnel = service.borrowTunnel(appId, id);
        tunnelSet = new HashSet<Tunnel>();
        tunnelSet.add(tunnel);
    }
    if (!isNull(tunnelName)) {
        TunnelName name = TunnelName.tunnelName(tunnelName);
        tunnelSet = service.borrowTunnel(appId, name);
    }
    for (Tunnel tunnel : tunnelSet) {
        print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), tunnel.groupId());
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) OpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) TunnelName(org.onosproject.incubator.net.tunnel.TunnelName) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId)

Example 25 with DefaultApplicationId

use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.

the class SimpleApplicationIdStore method registerApplication.

@Override
public ApplicationId registerApplication(String name) {
    DefaultApplicationId appId = appIdsByName.get(name);
    if (appId == null) {
        short id = (short) ID_DISPENSER.getAndIncrement();
        appId = new DefaultApplicationId(id, name);
        appIds.put(id, appId);
        appIdsByName.put(name, appId);
    }
    return appId;
}
Also used : DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Aggregations

DefaultApplicationId (org.onosproject.core.DefaultApplicationId)28 ApplicationId (org.onosproject.core.ApplicationId)19 Test (org.junit.Test)12 IntentMonitorAndRerouteService (org.onosproject.imr.IntentMonitorAndRerouteService)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 WebTarget (javax.ws.rs.client.WebTarget)3 Response (javax.ws.rs.core.Response)3 Before (org.junit.Before)3 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)3 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)3 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)3 FlowRule (org.onosproject.net.flow.FlowRule)3 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)3 EqualsTester (com.google.common.testing.EqualsTester)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)2