blob: 250fb3b62dbd2a7b627695f84d0ba1f6b9a3d4d9 [file] [log] [blame]
Charles Chanb13e0702018-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
Ray Milkeydb38bc82018-09-27 12:32:28 -070019import org.apache.karaf.shell.api.action.Command;
Ray Milkey52ca4e92018-09-28 10:58:28 -070020import org.apache.karaf.shell.api.action.lifecycle.Service;
Charles Chanb13e0702018-04-17 18:56:53 -070021import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.cluster.NodeId;
23import org.onosproject.net.DeviceId;
24import org.onosproject.segmentrouting.SegmentRoutingService;
25
26import java.util.Map;
27import java.util.Set;
28
29/**
30 * Display current shouldProgram map.
31 */
Ray Milkey52ca4e92018-09-28 10:58:28 -070032@Service
Charles Chanb13e0702018-04-17 18:56:53 -070033@Command(scope = "onos", name = "sr-should-program",
34 description = "Display current shouldProgram map")
35public class ShouldProgramCommand extends AbstractShellCommand {
36 @Override
Ray Milkeydb38bc82018-09-27 12:32:28 -070037 protected void doExecute() {
Charles Chanb13e0702018-04-17 18:56:53 -070038 SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
39 Map<Set<DeviceId>, NodeId> shouldProgram = srService.getShouldProgram();
40 Map<DeviceId, Boolean> shouldProgramCache = srService.getShouldProgramCache();
41
42 print("shouldProgram");
43 shouldProgram.forEach((k, v) -> print("%s -> %s", k, v));
44
45 print("shouldProgramCache");
46 shouldProgramCache.forEach((k, v) -> print("%s -> %s", k, v));
47 }
48}