blob: 94578a7ee4dc8da553b70c3a4904c15d1bdb9c81 [file] [log] [blame]
Jonathan Harte533a422015-10-20 17:31:24 -07001/*
Brian O'Connord4fbd352016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
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
Srikanth Vavilapalli2e684912016-01-16 19:21:59 -080017package org.onosproject.olt.cli;
Jonathan Harte533a422015-10-20 17:31:24 -070018
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.packet.VlanId;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.ConnectPoint;
24import org.onosproject.net.DeviceId;
25import org.onosproject.net.PortNumber;
Srikanth Vavilapalli2e684912016-01-16 19:21:59 -080026import org.onosproject.olt.AccessDeviceService;
Jonathan Harte533a422015-10-20 17:31:24 -070027
28/**
29 * Adds a subscriber to an access device.
30 */
31@Command(scope = "onos", name = "add-subscriber-access",
32 description = "Adds a subscriber to an access device")
33public class SubscriberAddCommand extends AbstractShellCommand {
34
35 @Argument(index = 0, name = "deviceId", description = "Access device ID",
36 required = true, multiValued = false)
37 private String strDeviceId = null;
38
39 @Argument(index = 1, name = "port", description = "Subscriber port number",
40 required = true, multiValued = false)
41 private String strPort = null;
42
43 @Argument(index = 2, name = "vlanId",
44 description = "VLAN ID to add",
45 required = true, multiValued = false)
46 private String strVlanId = null;
47
48 @Override
49 protected void execute() {
50 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
51
52 DeviceId deviceId = DeviceId.deviceId(strDeviceId);
53 PortNumber port = PortNumber.portNumber(strPort);
54 VlanId vlan = VlanId.vlanId(Short.parseShort(strVlanId));
55 ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
56
57 service.provisionSubscriber(connectPoint, vlan);
58 }
59}