blob: 3e89ca47e03cb64de10ac2f976f22b979176d570 [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
19import org.apache.karaf.shell.commands.Argument;
20import org.apache.karaf.shell.commands.Command;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.net.Device;
23import org.onosproject.net.DeviceId;
24import org.onosproject.net.device.DeviceService;
25import org.onosproject.segmentrouting.SegmentRoutingService;
26
27/**
28 * Triggers the verification of hashed group buckets in the specified device,
29 * and corrects the buckets if necessary. Outcome can be viewed in the 'groups'
30 * command.
31 */
32@Command(scope = "onos", name = "sr-verify-groups",
33 description = "Triggers the verification of hashed groups in the specified "
34 + "device. Does not return any output; users can query the results "
35 + "in the 'groups' command")
36public class VerifyGroupsCommand extends AbstractShellCommand {
37
38 @Argument(index = 0, name = "uri", description = "Device ID",
39 required = true, multiValued = false)
40 String uri = null;
41
42 @Override
43 protected void execute() {
44 DeviceService deviceService = get(DeviceService.class);
45 SegmentRoutingService srService =
46 AbstractShellCommand.get(SegmentRoutingService.class);
47
48 if (uri != null) {
49 Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
50 if (dev != null) {
51 srService.verifyGroups(dev.id());
52 }
53 }
54 }
55}