2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.vtnrsc.cli.network;
18 import org.apache.karaf.shell.commands.Command;
19 import org.apache.karaf.shell.commands.Option;
20 import org.onosproject.cli.AbstractShellCommand;
21 import org.onosproject.vtnrsc.TenantNetwork;
22 import org.onosproject.vtnrsc.TenantNetworkId;
23 import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
26 * Supports for querying TenantNetworks by network id.
28 @Command(scope = "onos", name = "tenantnetworks", description = "Supports for querying"
29 + "tenantNetworks by networkid")
30 public class TenantNetworkQueryCommand extends AbstractShellCommand {
32 @Option(name = "-i", aliases = "--id", description = "TenantNetwork id", required = false,
36 private static final String FMT = "networkId=%s, networkName=%s, segmentationId=%s,"
37 + "tenantId=%s, type=%s, adminStateUp=%s";
40 protected void execute() {
41 TenantNetworkService service = get(TenantNetworkService.class);
43 TenantNetwork network = service.getNetwork(TenantNetworkId.networkId(id));
44 printNetwork(network);
46 Iterable<TenantNetwork> networks = service.getNetworks();
47 for (TenantNetwork network : networks) {
48 printNetwork(network);
53 private void printNetwork(TenantNetwork network) {
54 if (network == null) {
57 print(FMT, network.id(), network.name(), network.segmentationId(),
58 network.tenantId(), network.type(), network.adminStateUp());