2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.forwardingrulesmanager.internal;
10 import java.util.Dictionary;
11 import java.util.Hashtable;
12 import java.util.List;
14 import org.apache.felix.service.command.Descriptor;
15 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
16 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
17 import org.opendaylight.controller.sal.core.Node;
18 import org.opendaylight.controller.sal.utils.ServiceHelper;
19 import org.osgi.framework.ServiceRegistration;
22 * This class provides osgi cli commands for developers to debug
23 * ForwardingRulesManager functionality
25 public class ForwardingRulesManagerCLI {
26 @SuppressWarnings("rawtypes")
27 private ServiceRegistration sr = null;
32 public void destroy() {
36 final Dictionary<String, Object> props = new Hashtable<String, Object>();
37 props.put("osgi.command.scope", "odpcontroller");
38 props.put("osgi.command.function", new String[] { "showRequestedGroupFlows", "showInstalledGroupFlows",
39 "showRequestedNodeFlows", "showInstalledNodeFlows" });
40 this.sr = ServiceHelper.registerGlobalServiceWReg(ForwardingRulesManagerCLI.class, this, props);
44 if (this.sr != null) {
50 @Descriptor("Displays all the flow entries in a given group")
51 public void showRequestedGroupFlows(@Descriptor("Container in which to query FRM") String container,
52 @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) {
53 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
54 IForwardingRulesManager.class, container, this);
56 System.out.println("Cannot find the FRM instance on container: " + container);
59 List<FlowEntry> groupFlows = frm.getFlowEntriesForGroup(group);
60 System.out.println("Group " + group);
61 for (FlowEntry flowEntry : groupFlows) {
63 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
65 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
70 @Descriptor("Displays all the installed flow entries in a given group")
71 public void showInstalledGroupFlows(@Descriptor("Container in which to query FRM") String container,
72 @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) {
73 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
74 IForwardingRulesManager.class, container, this);
76 System.out.println("Cannot find the FRM instance on container: " + container);
79 List<FlowEntry> groupFlows = frm.getInstalledFlowEntriesForGroup(group);
80 System.out.println("Group " + group);
81 for (FlowEntry flowEntry : groupFlows) {
83 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
85 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
90 @Descriptor("Displays all the flow entries for a network node")
91 public void showRequestedNodeFlows(
92 @Descriptor("Container in which to query FRM") String container,
93 @Descriptor("String representation of the Node, this need to be consumable from Node.fromString()") String nodeId,
94 @Descriptor("True for verbose else false") Boolean verbose) {
95 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
96 IForwardingRulesManager.class, container, this);
98 System.out.println("Cannot find the FRM instance on container: " + container);
101 Node node = Node.fromString(nodeId);
103 System.out.println("Please enter a valid node id");
106 List<FlowEntry> groupFlows = frm.getFlowEntriesForNode(node);
107 System.out.println("Node " + nodeId);
108 for (FlowEntry flowEntry : groupFlows) {
110 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
112 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
117 @Descriptor("Displays all the flow entries installed in a network node")
118 public void showInstalledNodeFlows(
119 @Descriptor("Container in which to query FRM") String container,
120 @Descriptor("String representation of the Node, this need to be consumable from Node.fromString()") String nodeId,
121 @Descriptor("True for verbose else false") Boolean verbose) {
122 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
123 IForwardingRulesManager.class, container, this);
125 System.out.println("Cannot find the FRM instance on container: " + container);
128 Node node = Node.fromString(nodeId);
130 System.out.println("Please enter a valid node id");
133 List<FlowEntry> groupFlows = frm.getInstalledFlowEntriesForNode(node);
134 System.out.println("Node " + nodeId);
135 for (FlowEntry flowEntry : groupFlows) {
137 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
139 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());