blob: a8e1bb970618f473d5c942a4921a6fa66121b7ce [file] [log] [blame]
Andreas Papazoisc2c45012016-01-20 14:26:11 +02001/*
Andreas Papazoise6aebaa2016-05-26 15:25:51 +03002 * Copyright 2016-present Open Networking Laboratory
Andreas Papazoisc2c45012016-01-20 14:26:11 +02003 *
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.sdxl3.cli;
18
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onlab.packet.IpAddress;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.sdxl3.SdxL3PeerService;
24
25/**
26 * Command to remove details for a peer from configuration.
27 */
28@Command(scope = "onos", name = "peer-remove-details",
29 description = "Removes the details of an external BGP peer")
30public class RemovePeerDetailsCommand extends AbstractShellCommand {
31
32 @Argument(index = 0, name = "ip",
33 description = "BGP peer IP",
34 required = true, multiValued = false)
35 private String ip = null;
36
37 private static final String DETAILS_REMOVE_SUCCESS =
38 "Details successfully removed from peer.";
39 private static final String DETAILS_REMOVE_FAIL =
40 "Details could not be added to peer: ";
41
42 private IpAddress peerAddress = null;
43
44 @Override
45 protected void execute() {
46 peerAddress = IpAddress.valueOf(ip);
47
48 SdxL3PeerService peerService = get(SdxL3PeerService.class);
49 try {
50 peerService.removePeerDetails(peerAddress);
51 print(DETAILS_REMOVE_SUCCESS);
52 } catch (Exception e) {
53 print(DETAILS_REMOVE_FAIL + e.getMessage());
54 }
55 }
56}