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