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);
}
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());
}
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));
}
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());
}
}
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;
}
Aggregations