Search in sources :

Example 1 with DefaultApplicationId

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());
                }
            });
        }
    }
}
Also used : IntentService(org.onosproject.net.intent.IntentService) IntentMonitorAndRerouteService(org.onosproject.imr.IntentMonitorAndRerouteService) Key(org.onosproject.net.intent.Key) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 2 with DefaultApplicationId

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();
}
Also used : IntentMonitorAndRerouteService(org.onosproject.imr.IntentMonitorAndRerouteService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with DefaultApplicationId

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();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Test(org.junit.Test)

Example 4 with DefaultApplicationId

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());
    }
}
Also used : TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) TunnelSubscription(org.onosproject.incubator.net.tunnel.TunnelSubscription) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) DefaultApplicationId(org.onosproject.core.DefaultApplicationId)

Example 5 with DefaultApplicationId

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);
    }
}
Also used : TunnelService(org.onosproject.incubator.net.tunnel.TunnelService) ProviderId(org.onosproject.net.provider.ProviderId) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) 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) DefaultOpticalTunnelEndPoint(org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) TunnelName(org.onosproject.incubator.net.tunnel.TunnelName) 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