Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 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; |
| 21 | import org.onosproject.xosintegration.VoltTenant; |
| 22 | import org.onosproject.xosintegration.VoltTenantService; |
| 23 | |
| 24 | /** |
| 25 | * CLI command to create a new tenant. |
| 26 | */ |
| 27 | @Command(scope = "onos", name = "add-tenant", |
| 28 | description = "Lists the inventory of VOLT tenants and their contents") |
| 29 | public class VoltTenantsCreateCommand extends AbstractShellCommand { |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 30 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame^] | 31 | @Argument(index = 0, name = "service specific ID", |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 32 | description = "service specific ID", |
| 33 | required = true, multiValued = false) |
| 34 | String serviceSpecificId; |
| 35 | |
Ray Milkey | dea9817 | 2015-05-18 10:39:39 -0700 | [diff] [blame^] | 36 | @Argument(index = 1, name = "vlan ID", |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 37 | description = "vlan ID", |
| 38 | required = true, multiValued = false) |
| 39 | String vlanId; |
| 40 | |
| 41 | @Override |
| 42 | protected void execute() { |
| 43 | VoltTenantService service = get(VoltTenantService.class); |
| 44 | |
| 45 | VoltTenant newTenant = VoltTenant.builder() |
Ray Milkey | 140e478 | 2015-04-24 11:25:13 -0700 | [diff] [blame] | 46 | .withServiceSpecificId(serviceSpecificId) |
| 47 | .withVlanId(vlanId) |
| 48 | .build(); |
| 49 | service.addTenant(newTenant); |
| 50 | } |
| 51 | } |