sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0947d7e | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.segmentrouting.cli; |
| 17 | |
Ray Milkey | db38bc8 | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 18 | import org.apache.karaf.shell.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
Ray Milkey | 52ca4e9 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
pierventre | 30368ab | 2021-02-24 23:23:22 +0100 | [diff] [blame] | 21 | |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 22 | import org.onosproject.cli.AbstractShellCommand; |
pierventre | 30368ab | 2021-02-24 23:23:22 +0100 | [diff] [blame] | 23 | import org.onosproject.segmentrouting.policy.api.PolicyId; |
| 24 | import org.onosproject.segmentrouting.policy.api.PolicyService; |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
sangho | 316d438 | 2015-06-24 09:37:40 -0700 | [diff] [blame] | 27 | * Command to remove a policy. |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 28 | */ |
Ray Milkey | 52ca4e9 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 29 | @Service |
Saurav Das | 07c7460 | 2016-04-27 18:35:50 -0700 | [diff] [blame] | 30 | @Command(scope = "onos", name = "sr-policy-remove", |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 31 | description = "Remove a policy") |
| 32 | public class PolicyRemoveCommand extends AbstractShellCommand { |
| 33 | |
pierventre | 30368ab | 2021-02-24 23:23:22 +0100 | [diff] [blame] | 34 | @Argument(index = 0, name = "policyId", |
| 35 | description = "policy id", |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 36 | required = true, multiValued = false) |
| 37 | String policyId; |
| 38 | |
| 39 | @Override |
Ray Milkey | db38bc8 | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 40 | protected void doExecute() { |
pierventre | 30368ab | 2021-02-24 23:23:22 +0100 | [diff] [blame] | 41 | 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); |
sangho | bd812f8 | 2015-06-29 14:58:47 -0700 | [diff] [blame] | 46 | } |
sangho | 2eae4c6 | 2015-06-11 14:49:59 -0700 | [diff] [blame] | 47 | } |
| 48 | } |