jiangrui | a0fc605 | 2015-11-28 14:03:42 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
jiangrui | a0fc605 | 2015-11-28 14:03:42 +0800 | [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.vtnrsc.cli.routerinterface; |
| 17 | |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 18 | import org.apache.karaf.shell.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame^] | 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
jiangrui | a0fc605 | 2015-11-28 14:03:42 +0800 | [diff] [blame] | 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.vtnrsc.RouterId; |
| 23 | import org.onosproject.vtnrsc.RouterInterface; |
| 24 | import org.onosproject.vtnrsc.SubnetId; |
| 25 | import org.onosproject.vtnrsc.TenantId; |
| 26 | import org.onosproject.vtnrsc.VirtualPortId; |
| 27 | import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService; |
| 28 | |
| 29 | /** |
| 30 | * Supports for create a router interface. |
| 31 | */ |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame^] | 32 | @Service |
jiangrui | a0fc605 | 2015-11-28 14:03:42 +0800 | [diff] [blame] | 33 | @Command(scope = "onos", name = "routerinterface-create", description = "Supports for creating a router interface") |
| 34 | public class RouterInterfaceCreateCommand extends AbstractShellCommand { |
| 35 | @Argument(index = 0, name = "routerId", description = "The router identifier of router interface", |
| 36 | required = true, multiValued = false) |
| 37 | String routerId = null; |
| 38 | |
| 39 | @Argument(index = 1, name = "tenantId", description = "The tenant identifier of router interface", |
| 40 | required = true, multiValued = false) |
| 41 | String tenantId = null; |
| 42 | |
| 43 | @Argument(index = 2, name = "portId", description = "The port identifier of router interface", |
| 44 | required = true, multiValued = false) |
| 45 | String portId = null; |
| 46 | |
| 47 | @Argument(index = 3, name = "subnetId", description = "The subnet identifier of router interface", |
| 48 | required = true, multiValued = false) |
| 49 | String subnetId = null; |
| 50 | |
| 51 | @Override |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 52 | protected void doExecute() { |
jiangrui | a0fc605 | 2015-11-28 14:03:42 +0800 | [diff] [blame] | 53 | RouterInterfaceService service = get(RouterInterfaceService.class); |
| 54 | try { |
| 55 | RouterInterface routerInterface = RouterInterface.routerInterface( |
| 56 | SubnetId.subnetId(subnetId), |
| 57 | VirtualPortId.portId(portId), |
| 58 | RouterId.valueOf(routerId), |
| 59 | TenantId.tenantId(tenantId)); |
| 60 | service.addRouterInterface(routerInterface); |
| 61 | } catch (Exception e) { |
| 62 | print(null, e.getMessage()); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } |