blob: 385260e795db8c7dd08f06abde47dd9b1ec0f81c [file] [log] [blame]
Saurav Dasceccf242017-08-03 18:30:35 -07001/*
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
17package org.onosproject.segmentrouting.cli;
18
Ray Milkey86ad7bb2018-09-27 12:32:28 -070019import org.apache.karaf.shell.api.action.Argument;
20import org.apache.karaf.shell.api.action.Command;
Ray Milkeyb52acf32018-10-05 10:17:34 -070021import org.apache.karaf.shell.api.action.Completion;
Ray Milkey7a2dee52018-09-28 10:58:28 -070022import org.apache.karaf.shell.api.action.lifecycle.Service;
Saurav Dasceccf242017-08-03 18:30:35 -070023import org.onosproject.cli.AbstractShellCommand;
Ray Milkeyb52acf32018-10-05 10:17:34 -070024import org.onosproject.cli.net.DeviceIdCompleter;
Saurav Dasceccf242017-08-03 18:30:35 -070025import org.onosproject.net.Device;
26import org.onosproject.net.DeviceId;
27import org.onosproject.net.device.DeviceService;
28import 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 Milkey7a2dee52018-09-28 10:58:28 -070035@Service
Saurav Dasceccf242017-08-03 18:30:35 -070036@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")
40public class VerifyGroupsCommand extends AbstractShellCommand {
41
42 @Argument(index = 0, name = "uri", description = "Device ID",
43 required = true, multiValued = false)
Ray Milkey3d5d0022018-10-10 11:54:07 -070044 @Completion(DeviceIdCompleter.class)
Saurav Dasceccf242017-08-03 18:30:35 -070045 String uri = null;
46
47 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070048 protected void doExecute() {
Saurav Dasceccf242017-08-03 18:30:35 -070049 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}