use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class StopMonitorCommand method doExecute.
@Override
protected void doExecute() {
imrService = get(IntentMonitorAndRerouteService.class);
intentService = get(IntentService.class);
if (appId != null && appName != null) {
if (key != null) {
/*
Intent key might be a StringKey or a LongKey, but in any case is
provided via CLI as a string. To solve only ambiguity we check if
"--longkey" CLI parameter has been set.
*/
if (treatAsLongKey) {
try {
Key intentKeyLong = Key.of(Integer.decode(key), new DefaultApplicationId(appId, appName));
if (imrService.stopMonitorIntent(intentKeyLong)) {
print("Stopped monitoring of intent with LongKey %s", intentKeyLong);
return;
}
} catch (NumberFormatException nfe) {
print("\"%s\" is not a valid LongKey", key);
return;
}
} else {
Key intentKeyString = Key.of(key, new DefaultApplicationId(appId, appName));
if (imrService.stopMonitorIntent(intentKeyString)) {
print("Stopped monitoring of intent with StringKey %s", intentKeyString);
return;
}
}
// No intent found in IMR
print("No monitored intent with key %s found", key);
} else {
intentService.getIntents().forEach(i -> {
if (i.appId().equals(new DefaultApplicationId(appId, appName))) {
imrService.stopMonitorIntent(i.key());
print("Stopped monitoring of intent with key %s", i.key());
}
});
}
}
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class ImrWebResource method getMonitoredIntents.
/**
* Get the list of monitored intents of a specific application.
* Shows for each intent key the related end points (as inElements and OutElements).
*
* @onos.rsModel monitoredIntentsGet
* @param id Application ID
* @param name Application Name
* @return 200 OK
*/
@GET
@Path("monitoredIntents/{id}/{name}")
@Produces(MediaType.APPLICATION_JSON)
public Response getMonitoredIntents(@PathParam("id") short id, @PathParam("name") String name) {
imrService = get(IntentMonitorAndRerouteService.class);
ApplicationId appId = new DefaultApplicationId(id, name);
ArrayNode jsonMonitoredIntents = getJsonMonitoredIntents(imrService.getMonitoredIntents(appId));
ObjectNode result = mapper.createObjectNode();
result.putArray(ROOT_FIELD_MONITORED_INTENTS).addAll(jsonMonitoredIntents);
return ok(result).build();
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class TunnelSubscriptionTest method testEquality.
/**
* Checks the operation of equals(), hashCode() and toString() methods.
*/
@Test
public void testEquality() {
TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
ApplicationId appId = new DefaultApplicationId(243, "test");
ApplicationId appId2 = new DefaultApplicationId(2431, "test1");
TunnelId tunnelId = TunnelId.valueOf("41654654");
TunnelSubscription p1 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN, null);
TunnelSubscription p2 = new TunnelSubscription(appId, src, dst, tunnelId, Tunnel.Type.VXLAN, null);
TunnelSubscription p3 = new TunnelSubscription(appId2, src, dst, tunnelId, Tunnel.Type.VXLAN, null);
new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3).testEquals();
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class TunnelQuerySubscriptionCommand method doExecute.
@Override
protected void doExecute() {
TunnelService service = get(TunnelService.class);
ApplicationId applicationId = new DefaultApplicationId(1, consumerId);
Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId);
for (TunnelSubscription order : tunnelSet) {
print(FMT, order.consumerId(), order.src(), order.dst(), order.type(), order.tunnelId());
}
}
use of org.onosproject.core.DefaultApplicationId in project onos by opennetworkinglab.
the class TunnelReturnCommand method doExecute.
@Override
protected void doExecute() {
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;
}
service.returnTunnel(appId, srcPoint, dstPoint, trueType);
}
if (!isNull(tunnelId)) {
TunnelId id = TunnelId.valueOf(tunnelId);
service.returnTunnel(appId, id);
}
if (!isNull(tunnelName)) {
TunnelName name = TunnelName.tunnelName(tunnelName);
service.returnTunnel(appId, name);
}
}
Aggregations