blob: b1a87202b02913e1bdeb6b3af889210ebc2a6576 [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;
Matteo Scandoloaadf17a2020-04-17 14:34:01 -070025import org.onosproject.cli.net.PortNumberCompleter;
Jonathan Harte533a422015-10-20 17:31:24 -070026import org.onosproject.net.ConnectPoint;
27import org.onosproject.net.DeviceId;
28import org.onosproject.net.PortNumber;
alshabib36a4d732016-06-01 16:03:59 -070029import org.opencord.olt.AccessDeviceService;
Jonathan Harte533a422015-10-20 17:31:24 -070030
31/**
32 * Adds a subscriber to an access device.
33 */
Carmelo Casconeca931162019-07-15 18:22:24 -070034@Service
Saurav Das82b8e6d2018-10-04 15:25:12 -070035@Command(scope = "onos", name = "volt-add-subscriber-access",
Jonathan Harte533a422015-10-20 17:31:24 -070036 description = "Adds a subscriber to an access device")
37public class SubscriberAddCommand extends AbstractShellCommand {
38
39 @Argument(index = 0, name = "deviceId", description = "Access device ID",
40 required = true, multiValued = false)
Carmelo Casconeca931162019-07-15 18:22:24 -070041 @Completion(DeviceIdCompleter.class)
Jonathan Harte533a422015-10-20 17:31:24 -070042 private String strDeviceId = null;
43
44 @Argument(index = 1, name = "port", description = "Subscriber port number",
45 required = true, multiValued = false)
Matteo Scandoloaadf17a2020-04-17 14:34:01 -070046 @Completion(PortNumberCompleter.class)
Jonathan Harte533a422015-10-20 17:31:24 -070047 private String strPort = null;
48
Jonathan Harte533a422015-10-20 17:31:24 -070049 @Override
Carmelo Casconeca931162019-07-15 18:22:24 -070050 protected void doExecute() {
Jonathan Harte533a422015-10-20 17:31:24 -070051 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
52
53 DeviceId deviceId = DeviceId.deviceId(strDeviceId);
54 PortNumber port = PortNumber.portNumber(strPort);
Jonathan Harte533a422015-10-20 17:31:24 -070055 ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
56
Amit Ghosh1ed9aef2018-07-17 17:08:16 +010057 service.provisionSubscriber(connectPoint);
Jonathan Harte533a422015-10-20 17:31:24 -070058 }
59}