Search in sources :

Example 11 with ApplicationId

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

the class EventSubscriptionManager method validGroupId.

/**
 * Checks if the group id is valid for this registered application.
 *
 * @param groupId GroupId assigned to the subscriber
 * @param appName Registered Application name
 * @return true if valid groupId and false otherwise
 */
private boolean validGroupId(EventSubscriberGroupId groupId, String appName) {
    checkNotNull(groupId);
    ApplicationId appId = coreService.getAppId(appName);
    EventSubscriberGroupId registeredGroupId = registeredApps.get(appId);
    if (registeredGroupId.equals(groupId)) {
        return true;
    }
    return false;
}
Also used : EventSubscriberGroupId(org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId) ApplicationId(org.onosproject.core.ApplicationId)

Example 12 with ApplicationId

use of org.onosproject.core.ApplicationId 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 13 with ApplicationId

use of org.onosproject.core.ApplicationId 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)

Example 14 with ApplicationId

use of org.onosproject.core.ApplicationId 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 15 with ApplicationId

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

the class FlowTableConfigTest method setUp.

@Before
public void setUp() throws Exception {
    directory.add(CoreService.class, new CoreServiceAdapter() {

        @Override
        public ApplicationId getAppId(Short id) {
            return APP_ID;
        }

        @Override
        public ApplicationId registerApplication(String name) {
            return APP_ID;
        }
    });
    mapper = testFriendlyMapper();
    JsonNode sample = loadJsonFromResource(SAMPLE, mapper);
    cfgnode = sample.path("devices").path(DID.toString()).path(FlowTableConfig.CONFIG_KEY);
}
Also used : CoreServiceAdapter(org.onosproject.core.CoreServiceAdapter) JsonNode(com.fasterxml.jackson.databind.JsonNode) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) Before(org.junit.Before)

Aggregations

ApplicationId (org.onosproject.core.ApplicationId)138 CoreService (org.onosproject.core.CoreService)36 Activate (org.osgi.service.component.annotations.Activate)36 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)25 Path (javax.ws.rs.Path)21 Produces (javax.ws.rs.Produces)16 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)15 GET (javax.ws.rs.GET)14 Test (org.junit.Test)13 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)11 FlowRuleService (org.onosproject.net.flow.FlowRuleService)11 TrafficSelector (org.onosproject.net.flow.TrafficSelector)11 Intent (org.onosproject.net.intent.Intent)11 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 InputStream (java.io.InputStream)9 DeviceId (org.onosproject.net.DeviceId)9 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)9 IntentService (org.onosproject.net.intent.IntentService)9 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8