blob: 34fe40d81f8cf969027bbd7aa409ca561c5534db [file] [log] [blame]
sangho6703da22015-06-11 14:49:59 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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;
sangho71abe1b2015-06-29 14:58:47 -070022import org.onosproject.segmentrouting.PolicyHandler;
sangho6703da22015-06-11 14:49:59 -070023import org.onosproject.segmentrouting.SegmentRoutingService;
24import org.onosproject.segmentrouting.TunnelPolicy;
25
26/**
sangho36c9d2c2015-06-24 09:37:40 -070027 * Command to remove a policy.
sangho6703da22015-06-11 14:49:59 -070028 */
29@Command(scope = "onos", name = "srpolicy-remove",
30 description = "Remove a policy")
31public class PolicyRemoveCommand extends AbstractShellCommand {
32
33 @Argument(index = 0, name = "policy ID",
34 description = "policy ID",
35 required = true, multiValued = false)
36 String policyId;
37
38 @Override
39 protected void execute() {
40
41 SegmentRoutingService srService =
42 AbstractShellCommand.get(SegmentRoutingService.class);
43
44 TunnelPolicy.Builder tpb = TunnelPolicy.builder().setPolicyId(policyId);
sangho71abe1b2015-06-29 14:58:47 -070045 PolicyHandler.Result result = srService.removePolicy(tpb.build());
46 if (result == PolicyHandler.Result.POLICY_NOT_FOUND) {
47 print("ERROR: the policy is not found");
48 }
sangho6703da22015-06-11 14:49:59 -070049 }
50}