Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.xosintegration.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Argument; |
| 19 | import org.apache.karaf.shell.commands.Command; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 22 | import org.onosproject.xosintegration.VoltTenant; |
| 23 | import 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") |
| 30 | public class VoltTenantsCreateCommand extends AbstractShellCommand { |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 31 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 32 | @Argument(index = 0, name = "service specific ID", |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 33 | description = "service specific ID", |
| 34 | required = true, multiValued = false) |
| 35 | String serviceSpecificId; |
| 36 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame] | 37 | @Argument(index = 1, name = "vlan ID", |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 38 | description = "vlan ID", |
| 39 | required = true, multiValued = false) |
| 40 | String vlanId; |
| 41 | |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 42 | @Argument(index = 2, name = "port", |
| 43 | description = "Port", |
| 44 | required = true, multiValued = false) |
| 45 | String port; |
| 46 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 47 | @Override |
| 48 | protected void execute() { |
| 49 | VoltTenantService service = get(VoltTenantService.class); |
| 50 | |
| 51 | VoltTenant newTenant = VoltTenant.builder() |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 52 | .withServiceSpecificId(serviceSpecificId) |
| 53 | .withVlanId(vlanId) |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 54 | .withPort(ConnectPoint.deviceConnectPoint(port)) |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 55 | .build(); |
Jonathan Hart | 5e9a63d | 2015-05-19 16:21:46 -0700 | [diff] [blame] | 56 | |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 57 | service.addTenant(newTenant); |
| 58 | } |
| 59 | } |