blob: 43a021300d2416ace578f3db6d4e202ce06584ac [file] [log] [blame]
Charles Chan8bc75ee2018-04-17 18:56:53 -07001/*
2 * Copyright 2018-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.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.cluster.NodeId;
22import org.onosproject.net.DeviceId;
23import org.onosproject.segmentrouting.SegmentRoutingService;
24
25import java.util.Map;
26import java.util.Set;
27
28/**
29 * Display current shouldProgram map.
30 */
31@Command(scope = "onos", name = "sr-should-program",
32 description = "Display current shouldProgram map")
33public class ShouldProgramCommand extends AbstractShellCommand {
34 @Override
35 protected void execute() {
36 SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
37 Map<Set<DeviceId>, NodeId> shouldProgram = srService.getShouldProgram();
38 Map<DeviceId, Boolean> shouldProgramCache = srService.getShouldProgramCache();
39
40 print("shouldProgram");
41 shouldProgram.forEach((k, v) -> print("%s -> %s", k, v));
42
43 print("shouldProgramCache");
44 shouldProgramCache.forEach((k, v) -> print("%s -> %s", k, v));
45 }
46}