blob: e1e621bd13da660589f548681eadb75aa6ede546 [file] [log] [blame]
Ray Milkey140e4782015-04-24 11:25:13 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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.xosintegration.cli;
17
18import java.util.Set;
19
20import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.xosintegration.VoltTenant;
24import org.onosproject.xosintegration.VoltTenantService;
25
26/**
27 * CLI command for listing VOLT tenant objects.
28 */
29
30/**
31 * CLI command to list the existing tenants.
32 */
33@Command(scope = "onos", name = "tenants",
34 description = "Lists the inventory of VOLT tenants and their contents")
35public class VoltTenantsListCommand extends AbstractShellCommand {
36
37 @Argument(index = 0, name = "tenantId",
38 description = "Tenant ID",
39 required = false, multiValued = false)
40 private String tenantId = null;
41
42 @Override
43 protected void execute() {
44 VoltTenantService service = get(VoltTenantService.class);
45
46 if (tenantId != null) {
47 VoltTenant tenant = service.getTenant(Long.parseLong(tenantId));
48 if (tenant != null) {
49 print(tenant.toString());
50 } else {
51 error("Tenant not found {}", tenantId);
52 }
53 } else {
54 Set<VoltTenant> tenants = service.getAllTenants();
55 for (VoltTenant tenant : tenants) {
56 print(tenant.toString());
57 }
58 }
59 }
60
61}