blob: 782b339c6256b503814849bf9786e0753e52917e [file] [log] [blame]
Andreas Pantelopoulos5e7be3d2017-10-23 12:18:25 -07001/*
2 * Copyright 2017-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 */
16package org.onosproject.segmentrouting.cli;
17
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.segmentrouting.SegmentRoutingManager;
23import org.onosproject.segmentrouting.SegmentRoutingService;
24import org.onosproject.segmentrouting.pwaas.L2TunnelHandler;
25
26
27/**
28 * Command to remove a pseudowire.
29 */
30@Command(scope = "onos", name = "pseudowire-remove",
31 description = "Remove a pseudowire")
32public class PseudowireRemoveCommand extends AbstractShellCommand {
33
34 @Argument(index = 0, name = "pwId",
35 description = "pseudowire ID",
36 required = true, multiValued = false)
37 String pwId;
38
39 @Override
40 protected void execute() {
41
42 SegmentRoutingService srService =
43 AbstractShellCommand.get(SegmentRoutingService.class);
44
45 // remove the pseudowire
46 SegmentRoutingManager mngr = (SegmentRoutingManager) srService;
47 L2TunnelHandler.Result res = mngr.removePseudowire(pwId);
48
49 switch (res) {
50 case REMOVAL_ERROR:
51 error("Error in deletion, pseudowire not found!");
52 break;
53 case CONFIG_NOT_FOUND:
54 error("Could not fetch pseudowire class configuration!");
55 break;
56 default:
57 return;
58 }
59 }
60}