blob: de76903552867540d9112fd069113f54de643ef2 [file] [log] [blame]
Jonathan Harte533a422015-10-20 17:31:24 -07001/*
Brian O'Connord6a135a2017-08-03 22:46:05 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Harte533a422015-10-20 17:31:24 -07003 *
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
alshabib36a4d732016-06-01 16:03:59 -070017package org.opencord.olt.cli;
Jonathan Harte533a422015-10-20 17:31:24 -070018
Carmelo Casconeca931162019-07-15 18:22:24 -070019import org.apache.karaf.shell.api.action.Argument;
20import org.apache.karaf.shell.api.action.Command;
21import org.apache.karaf.shell.api.action.Completion;
22import org.apache.karaf.shell.api.action.lifecycle.Service;
Jonathan Harte533a422015-10-20 17:31:24 -070023import org.onosproject.cli.AbstractShellCommand;
Carmelo Casconeca931162019-07-15 18:22:24 -070024import org.onosproject.cli.net.DeviceIdCompleter;
Jonathan Harte533a422015-10-20 17:31:24 -070025import org.onosproject.net.ConnectPoint;
26import org.onosproject.net.DeviceId;
27import org.onosproject.net.PortNumber;
alshabib36a4d732016-06-01 16:03:59 -070028import org.opencord.olt.AccessDeviceService;
Jonathan Harte533a422015-10-20 17:31:24 -070029
30/**
31 * Adds a subscriber to an access device.
32 */
Carmelo Casconeca931162019-07-15 18:22:24 -070033@Service
Saurav Das82b8e6d2018-10-04 15:25:12 -070034@Command(scope = "onos", name = "volt-add-subscriber-access",
Jonathan Harte533a422015-10-20 17:31:24 -070035 description = "Adds a subscriber to an access device")
36public class SubscriberAddCommand extends AbstractShellCommand {
37
38 @Argument(index = 0, name = "deviceId", description = "Access device ID",
39 required = true, multiValued = false)
Carmelo Casconeca931162019-07-15 18:22:24 -070040 @Completion(DeviceIdCompleter.class)
Jonathan Harte533a422015-10-20 17:31:24 -070041 private String strDeviceId = null;
42
43 @Argument(index = 1, name = "port", description = "Subscriber port number",
44 required = true, multiValued = false)
Matteo Scandolo8abd7022021-06-11 15:03:46 +020045 @Completion(OltUniPortCompleter.class)
Jonathan Harte533a422015-10-20 17:31:24 -070046 private String strPort = null;
47
Jonathan Harte533a422015-10-20 17:31:24 -070048 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070049 protected void doExecute() {
Jonathan Harte533a422015-10-20 17:31:24 -070050 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
51
52 DeviceId deviceId = DeviceId.deviceId(strDeviceId);
53 PortNumber port = PortNumber.portNumber(strPort);
Jonathan Harte533a422015-10-20 17:31:24 -070054 ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
55
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010056 service.provisionSubscriber(connectPoint);
Jonathan Harte533a422015-10-20 17:31:24 -070057 }
58}