blob: ad84a2ae6823d9acb37a4271606c0050f232c395 [file] [log] [blame]
jccd8697232015-05-05 14:42:23 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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
20import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.core.ApplicationId;
24import org.onosproject.core.DefaultApplicationId;
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070025import org.onosproject.incubator.net.tunnel.TunnelService;
26import org.onosproject.incubator.net.tunnel.TunnelSubscription;
jccd8697232015-05-05 14:42:23 +080027
28/**
29 * Query all tunnel subscriptions of consumer by consumer id.
30 * It's used by consumers.
31 */
samuel7a5691a2015-05-23 00:36:32 +080032@Command(scope = "onos", name = "tunnel-subscriptions",
jccd8697232015-05-05 14:42:23 +080033 description = "Query all request orders of consumer by consumer id. It's used by consumers.")
Thomas Vachuskabf916ea2015-05-20 18:24:34 -070034public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
jccd8697232015-05-05 14:42:23 +080035 @Argument(index = 0, name = "consumerId",
36 description = "consumer id means provider id",
37 required = true, multiValued = false)
38 String consumerId = null;
39 private static final String FMT = "appId=%s, src=%s, dst=%s,"
40 + "type=%s, tunnelId=%s";
41
42 @Override
43 protected void execute() {
44 TunnelService service = get(TunnelService.class);
45 ApplicationId applicationId = new DefaultApplicationId(1, consumerId);
46 Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId);
47 for (TunnelSubscription order : tunnelSet) {
48 print(FMT, order.consumerId(), order.src(), order.dst(),
49 order.type(), order.tunnelId());
50 }
51 }
52
53}