blob: 71a9c5f7ffa2f0257ed4d9b804ca3b8c4c7cea6b [file] [log] [blame]
Kyuhwi Choi70537882016-06-24 17:24:12 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Kyuhwi Choi70537882016-06-24 17:24:12 +09003 *
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
17package org.onosproject.scalablegateway.cli;
18
Kyuhwi Choi70537882016-06-24 17:24:12 +090019import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.packet.Ip4Address;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.DeviceId;
24import org.onosproject.scalablegateway.api.GatewayNode;
25import org.onosproject.scalablegateway.api.ScalableGatewayService;
26
Kyuhwi Choi70537882016-06-24 17:24:12 +090027/**
28 * Adds gateway node information for scalablegateway node managements.
29 */
30
31@Command(scope = "onos", name = "gateway-add",
32 description = "Adds gateway node information for scalablegateway node managements")
33public class ScalableGatewayAddCommand extends AbstractShellCommand {
34
35 private static final String SUCCESS = "Process of adding gateway node is succeed";
36 private static final String FAIL = "Process of adding gateway node is failed";
37
38 @Argument(index = 0, name = "DeviceId", description = "GatewayNode device id",
39 required = true, multiValued = false)
40 String deviceId = null;
41
42 @Argument(index = 1, name = "dataPlaneIp",
43 description = "GatewayNode datePlane interface ip address",
44 required = true, multiValued = false)
45 String ipAddress = null;
46
47 @Argument(index = 2, name = "extInterfaceNames",
48 description = "GatewayNode Interface name to outgoing external network",
49 required = true, multiValued = true)
50 String interfaceName = null;
51
52 @Override
53 protected void execute() {
54 ScalableGatewayService service = get(ScalableGatewayService.class);
55
56 GatewayNode gatewayNode = GatewayNode.builder()
57 .gatewayDeviceId(DeviceId.deviceId(deviceId))
58 .dataIpAddress(Ip4Address.valueOf(ipAddress))
Hyunsun Moonf9a16ed2016-07-20 21:59:48 -070059 .uplinkIntf(interfaceName)
Kyuhwi Choi70537882016-06-24 17:24:12 +090060 .build();
61 if (service.addGatewayNode(gatewayNode)) {
62 print(SUCCESS);
63 } else {
64 print(FAIL);
65 }
66 }
67
Kyuhwi Choi70537882016-06-24 17:24:12 +090068}