blob: a5de8a70e6331bc923cb0bbd82a163567b00f608 [file] [log] [blame]
Ray Milkey140e4782015-04-24 11:25:13 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkey140e4782015-04-24 11:25:13 -07003 *
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 org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070021import org.onosproject.net.ConnectPoint;
Ray Milkey140e4782015-04-24 11:25:13 -070022import org.onosproject.xosintegration.VoltTenant;
23import org.onosproject.xosintegration.VoltTenantService;
24
25/**
26 * CLI command to create a new tenant.
27 */
28@Command(scope = "onos", name = "add-tenant",
29 description = "Lists the inventory of VOLT tenants and their contents")
30public class VoltTenantsCreateCommand extends AbstractShellCommand {
Ray Milkey140e4782015-04-24 11:25:13 -070031
Ray Milkeydea98172015-05-18 10:39:39 -070032 @Argument(index = 0, name = "service specific ID",
Ray Milkey140e4782015-04-24 11:25:13 -070033 description = "service specific ID",
34 required = true, multiValued = false)
35 String serviceSpecificId;
36
Ray Milkeydea98172015-05-18 10:39:39 -070037 @Argument(index = 1, name = "vlan ID",
Ray Milkey140e4782015-04-24 11:25:13 -070038 description = "vlan ID",
39 required = true, multiValued = false)
40 String vlanId;
41
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070042 @Argument(index = 2, name = "port",
43 description = "Port",
44 required = true, multiValued = false)
45 String port;
46
Ray Milkey140e4782015-04-24 11:25:13 -070047 @Override
48 protected void execute() {
49 VoltTenantService service = get(VoltTenantService.class);
50
51 VoltTenant newTenant = VoltTenant.builder()
Ray Milkey140e4782015-04-24 11:25:13 -070052 .withServiceSpecificId(serviceSpecificId)
53 .withVlanId(vlanId)
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070054 .withPort(ConnectPoint.deviceConnectPoint(port))
Ray Milkey140e4782015-04-24 11:25:13 -070055 .build();
Jonathan Hart5e9a63d2015-05-19 16:21:46 -070056
Ray Milkey140e4782015-04-24 11:25:13 -070057 service.addTenant(newTenant);
58 }
59}