blob: ff35423a28defceeb39a9ebffbbf3598a95c62cb [file] [log] [blame]
sangho2eae4c62015-06-11 14:49:59 -07001/*
Brian O'Connor0947d7e2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
sangho2eae4c62015-06-11 14:49:59 -07003 *
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
Ray Milkeydb38bc82018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
Ray Milkey52ca4e92018-09-28 10:58:28 -070020import org.apache.karaf.shell.api.action.lifecycle.Service;
pierventre30368ab2021-02-24 23:23:22 +010021
sangho2eae4c62015-06-11 14:49:59 -070022import org.onosproject.cli.AbstractShellCommand;
pierventre30368ab2021-02-24 23:23:22 +010023import org.onosproject.segmentrouting.policy.api.PolicyId;
24import org.onosproject.segmentrouting.policy.api.PolicyService;
sangho2eae4c62015-06-11 14:49:59 -070025
26/**
sangho316d4382015-06-24 09:37:40 -070027 * Command to remove a policy.
sangho2eae4c62015-06-11 14:49:59 -070028 */
Ray Milkey52ca4e92018-09-28 10:58:28 -070029@Service
Saurav Das07c74602016-04-27 18:35:50 -070030@Command(scope = "onos", name = "sr-policy-remove",
sangho2eae4c62015-06-11 14:49:59 -070031 description = "Remove a policy")
32public class PolicyRemoveCommand extends AbstractShellCommand {
33
pierventre30368ab2021-02-24 23:23:22 +010034 @Argument(index = 0, name = "policyId",
35 description = "policy id",
sangho2eae4c62015-06-11 14:49:59 -070036 required = true, multiValued = false)
37 String policyId;
38
39 @Override
Ray Milkeydb38bc82018-09-27 12:32:28 -070040 protected void doExecute() {
pierventre30368ab2021-02-24 23:23:22 +010041 PolicyService policyService = AbstractShellCommand.get(PolicyService.class);
42 if (policyService.removePolicy(PolicyId.of(policyId))) {
43 print("Removing policy %s", policyId);
44 } else {
45 print("Unable to remove policy %s", policyId);
sanghobd812f82015-06-29 14:58:47 -070046 }
sangho2eae4c62015-06-11 14:49:59 -070047 }
48}