blob: 0a0b6e9dd15a7b9d0cf176f169607239bbbe6258 [file] [log] [blame]
jiangruia0fc6052015-11-28 14:03:42 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.vtnrsc.RouterId;
22import org.onosproject.vtnrsc.RouterInterface;
23import org.onosproject.vtnrsc.SubnetId;
24import org.onosproject.vtnrsc.TenantId;
25import org.onosproject.vtnrsc.VirtualPortId;
26import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
27
28/**
29 * Supports for create a router interface.
30 */
31@Command(scope = "onos", name = "routerinterface-create", description = "Supports for creating a router interface")
32public class RouterInterfaceCreateCommand extends AbstractShellCommand {
33 @Argument(index = 0, name = "routerId", description = "The router identifier of router interface",
34 required = true, multiValued = false)
35 String routerId = null;
36
37 @Argument(index = 1, name = "tenantId", description = "The tenant identifier of router interface",
38 required = true, multiValued = false)
39 String tenantId = null;
40
41 @Argument(index = 2, name = "portId", description = "The port identifier of router interface",
42 required = true, multiValued = false)
43 String portId = null;
44
45 @Argument(index = 3, name = "subnetId", description = "The subnet identifier of router interface",
46 required = true, multiValued = false)
47 String subnetId = null;
48
49 @Override
50 protected void execute() {
51 RouterInterfaceService service = get(RouterInterfaceService.class);
52 try {
53 RouterInterface routerInterface = RouterInterface.routerInterface(
54 SubnetId.subnetId(subnetId),
55 VirtualPortId.portId(portId),
56 RouterId.valueOf(routerId),
57 TenantId.tenantId(tenantId));
58 service.addRouterInterface(routerInterface);
59 } catch (Exception e) {
60 print(null, e.getMessage());
61 }
62 }
63
64}