blob: c50e42a9784572ef899279bcb22d3bf2aa55f022 [file] [log] [blame]
Daniele Moro94660a02019-12-02 12:02:07 -08001/*
Joey Armstronga68e7852024-01-28 13:27:02 -05002 * Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
Daniele Moro94660a02019-12-02 12:02:07 -08003 *
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.bng.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.Completion;
22import org.apache.karaf.shell.api.action.lifecycle.Service;
23import org.onosproject.cli.AbstractShellCommand;
24import org.opencord.bng.BngService;
25
26@Service
27@Command(scope = "bng", name = "attachment-remove",
28 description = "Remove an attachment from the BNG")
29public class RemoveAttachment extends AbstractShellCommand {
30
31 @Argument(index = 0, name = "attachmentKey", description = "Attachment Key. No Key or 0 means ALL")
32 @Completion(AttachmentKeyCompleter.class)
33 String attachmentKey = null;
34
35 @Override
36 protected void doExecute() throws Exception {
37 BngService bngService = AbstractShellCommand.get(BngService.class);
38 if (attachmentKey == null) {
39 bngService.getAttachments().keySet()
40 .forEach(bngService::removeAttachment);
41 return;
42 }
43 bngService.removeAttachment(attachmentKey);
44 print("Attachment removed");
45 }
46}