Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | |
| 17 | package org.onosproject.segmentrouting.cli; |
| 18 | |
Ray Milkey | db38bc8 | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 19 | import org.apache.karaf.shell.api.action.Argument; |
| 20 | import org.apache.karaf.shell.api.action.Command; |
Ray Milkey | 5105ec3 | 2018-10-05 10:17:34 -0700 | [diff] [blame^] | 21 | import org.apache.karaf.shell.api.action.Completion; |
Ray Milkey | 52ca4e9 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 22 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 23 | import org.onosproject.cli.AbstractShellCommand; |
Ray Milkey | 5105ec3 | 2018-10-05 10:17:34 -0700 | [diff] [blame^] | 24 | import org.onosproject.cli.net.DeviceIdCompleter; |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 25 | import org.onosproject.net.Device; |
| 26 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.device.DeviceService; |
| 28 | import org.onosproject.segmentrouting.SegmentRoutingService; |
| 29 | |
| 30 | /** |
| 31 | * Triggers the verification of hashed group buckets in the specified device, |
| 32 | * and corrects the buckets if necessary. Outcome can be viewed in the 'groups' |
| 33 | * command. |
| 34 | */ |
Ray Milkey | 52ca4e9 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 35 | @Service |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 36 | @Command(scope = "onos", name = "sr-verify-groups", |
| 37 | description = "Triggers the verification of hashed groups in the specified " |
| 38 | + "device. Does not return any output; users can query the results " |
| 39 | + "in the 'groups' command") |
| 40 | public class VerifyGroupsCommand extends AbstractShellCommand { |
| 41 | |
| 42 | @Argument(index = 0, name = "uri", description = "Device ID", |
| 43 | required = true, multiValued = false) |
Ray Milkey | 5105ec3 | 2018-10-05 10:17:34 -0700 | [diff] [blame^] | 44 | @Completion(DeviceIdCompleter.class) |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 45 | String uri = null; |
| 46 | |
| 47 | @Override |
Ray Milkey | db38bc8 | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 48 | protected void doExecute() { |
Saurav Das | fbe7457 | 2017-08-03 18:30:35 -0700 | [diff] [blame] | 49 | DeviceService deviceService = get(DeviceService.class); |
| 50 | SegmentRoutingService srService = |
| 51 | AbstractShellCommand.get(SegmentRoutingService.class); |
| 52 | |
| 53 | if (uri != null) { |
| 54 | Device dev = deviceService.getDevice(DeviceId.deviceId(uri)); |
| 55 | if (dev != null) { |
| 56 | srService.verifyGroups(dev.id()); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | } |