blob: d9b4559b301efdc7ae2a9dc00d4f669808702139 [file] [log] [blame]
Jonathan Harte533a422015-10-20 17:31:24 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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.olt;
18
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;
26
27/**
28 * Adds a subscriber to an access device.
29 */
30@Command(scope = "onos", name = "add-subscriber-access",
31 description = "Adds a subscriber to an access device")
32public class SubscriberAddCommand extends AbstractShellCommand {
33
34 @Argument(index = 0, name = "deviceId", description = "Access device ID",
35 required = true, multiValued = false)
36 private String strDeviceId = null;
37
38 @Argument(index = 1, name = "port", description = "Subscriber port number",
39 required = true, multiValued = false)
40 private String strPort = null;
41
42 @Argument(index = 2, name = "vlanId",
43 description = "VLAN ID to add",
44 required = true, multiValued = false)
45 private String strVlanId = null;
46
47 @Override
48 protected void execute() {
49 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
50
51 DeviceId deviceId = DeviceId.deviceId(strDeviceId);
52 PortNumber port = PortNumber.portNumber(strPort);
53 VlanId vlan = VlanId.vlanId(Short.parseShort(strVlanId));
54 ConnectPoint connectPoint = new ConnectPoint(deviceId, port);
55
56 service.provisionSubscriber(connectPoint, vlan);
57 }
58}