blob: 74d05b752919a485a335f223ca1f2f92b5b33be6 [file] [log] [blame]
Gamze Abaka1b7816e2019-11-25 06:38:41 +00001/*
2 * Copyright 2016-present Open Networking Foundation
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.opencord.olt.cli;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.apache.karaf.shell.commands.Option;
22import org.onlab.packet.VlanId;
23import org.onosproject.cli.AbstractShellCommand;
24import org.opencord.olt.AccessDeviceService;
25import org.opencord.olt.AccessSubscriberId;
26
27import java.util.Optional;
28
29/**
30 * Removes a uni tag from a subscriber (portname).
31 */
32@Command(scope = "onos", name = "volt-remove-subscriber-unitag",
33 description = "Removes a uni tag from an access device")
34public class UniTagRemoveCommand extends AbstractShellCommand {
35
36 @Argument(index = 0, name = "portName", description = "Port name",
37 required = true, multiValued = false)
38 private String strPortName = null;
39
40 @Option(name = "--cTag", description = "Inner vlan id",
41 required = false, multiValued = false)
42 private String strCtag = null;
43
44 @Option(name = "--sTag", description = "Outer vlan id",
45 required = false, multiValued = false)
46 private String strStag = null;
47
48 @Option(name = "--tpId", description = "Technology profile id",
49 required = false, multiValued = false)
50 private String strTpId = null;
51
52 @Override
53 protected void execute() {
54
55 AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class);
56 AccessSubscriberId portName = new AccessSubscriberId(strPortName);
57
58 Optional<VlanId> cTag = strCtag == null ? Optional.empty() : Optional.of(VlanId.vlanId(strCtag));
59 Optional<VlanId> sTag = strStag == null ? Optional.empty() : Optional.of(VlanId.vlanId(strStag));
60 Optional<Integer> tpId = strTpId == null ? Optional.empty() : Optional.of(Integer.parseInt(strTpId));
61 service.removeSubscriber(portName, sTag, cTag, tpId);
62 }
63}