blob: fed8e6442efc2e28f3dc281a2ba48b440e38aa9e [file] [log] [blame]
jccd8697232015-05-05 14:42:23 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jccd8697232015-05-05 14:42:23 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.cli.net;
17
18import java.util.Collection;
19
Ray Milkeyd84f89b2018-08-17 14:54:17 -070020import org.apache.karaf.shell.api.action.Argument;
21import org.apache.karaf.shell.api.action.Command;
22import org.apache.karaf.shell.api.action.lifecycle.Service;
jccd8697232015-05-05 14:42:23 +080023import org.onosproject.cli.AbstractShellCommand;
24import org.onosproject.core.ApplicationId;
25import org.onosproject.core.DefaultApplicationId;
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070026import org.onosproject.incubator.net.tunnel.TunnelService;
27import org.onosproject.incubator.net.tunnel.TunnelSubscription;
jccd8697232015-05-05 14:42:23 +080028
29/**
30 * Query all tunnel subscriptions of consumer by consumer id.
31 * It's used by consumers.
32 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070033@Service
samuel7a5691a2015-05-23 00:36:32 +080034@Command(scope = "onos", name = "tunnel-subscriptions",
jccd8697232015-05-05 14:42:23 +080035 description = "Query all request orders of consumer by consumer id. It's used by consumers.")
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070036public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
jccd8697232015-05-05 14:42:23 +080037 @Argument(index = 0, name = "consumerId",
38 description = "consumer id means provider id",
39 required = true, multiValued = false)
40 String consumerId = null;
41 private static final String FMT = "appId=%s, src=%s, dst=%s,"
42 + "type=%s, tunnelId=%s";
43
44 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070045 protected void doExecute() {
jccd8697232015-05-05 14:42:23 +080046 TunnelService service = get(TunnelService.class);
47 ApplicationId applicationId = new DefaultApplicationId(1, consumerId);
48 Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId);
49 for (TunnelSubscription order : tunnelSet) {
50 print(FMT, order.consumerId(), order.src(), order.dst(),
51 order.type(), order.tunnelId());
52 }
53 }
54
55}