blob: c8c39cb2d119162ca527e8d109586e4949b6ba36 [file] [log] [blame]
jiangruia0fc6052015-11-28 14:03:42 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jiangruia0fc6052015-11-28 14:03:42 +08003 *
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.vtnrsc.cli.routerinterface;
17
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
Ray Milkey7a2dee52018-09-28 10:58:28 -070020import org.apache.karaf.shell.api.action.lifecycle.Service;
jiangruia0fc6052015-11-28 14:03:42 +080021import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.vtnrsc.RouterId;
23import org.onosproject.vtnrsc.RouterInterface;
24import org.onosproject.vtnrsc.SubnetId;
25import org.onosproject.vtnrsc.TenantId;
26import org.onosproject.vtnrsc.VirtualPortId;
27import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
28
29/**
30 * Supports for create a router interface.
31 */
Ray Milkey7a2dee52018-09-28 10:58:28 -070032@Service
jiangruia0fc6052015-11-28 14:03:42 +080033@Command(scope = "onos", name = "routerinterface-create", description = "Supports for creating a router interface")
34public 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 Milkey86ad7bb2018-09-27 12:32:28 -070052 protected void doExecute() {
jiangruia0fc6052015-11-28 14:03:42 +080053 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}