1 package org.opendaylight.controller.forwardingrulesmanager.internal;
3 import java.util.Dictionary;
4 import java.util.Hashtable;
7 import org.apache.felix.service.command.Descriptor;
8 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
9 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
10 import org.opendaylight.controller.sal.core.Node;
11 import org.opendaylight.controller.sal.utils.ServiceHelper;
12 import org.osgi.framework.ServiceRegistration;
15 * This class provides osgi cli commands for developers to debug
16 * ForwardingRulesManager functionality
18 public class ForwardingRulesManagerCLI {
19 @SuppressWarnings("rawtypes")
20 private ServiceRegistration sr = null;
25 public void destroy() {
29 final Dictionary<String, Object> props = new Hashtable<String, Object>();
30 props.put("osgi.command.scope", "odpcontroller");
31 props.put("osgi.command.function", new String[] { "showRequestedGroupFlows", "showInstalledGroupFlows",
32 "showRequestedNodeFlows", "showInstalledNodeFlows" });
33 this.sr = ServiceHelper.registerGlobalServiceWReg(ForwardingRulesManagerCLI.class, this, props);
37 if (this.sr != null) {
43 @Descriptor("Displays all the flow entries in a given group")
44 public void showRequestedGroupFlows(@Descriptor("Container in which to query FRM") String container,
45 @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) {
46 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
47 IForwardingRulesManager.class, container, this);
49 System.out.println("Cannot find the FRM instance on container: " + container);
52 List<FlowEntry> groupFlows = frm.getFlowEntriesForGroup(group);
53 System.out.println("Group " + group);
54 for (FlowEntry flowEntry : groupFlows) {
56 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
58 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
63 @Descriptor("Displays all the installed flow entries in a given group")
64 public void showInstalledGroupFlows(@Descriptor("Container in which to query FRM") String container,
65 @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) {
66 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
67 IForwardingRulesManager.class, container, this);
69 System.out.println("Cannot find the FRM instance on container: " + container);
72 List<FlowEntry> groupFlows = frm.getInstalledFlowEntriesForGroup(group);
73 System.out.println("Group " + group);
74 for (FlowEntry flowEntry : groupFlows) {
76 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
78 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
83 @Descriptor("Displays all the flow entries for a network node")
84 public void showRequestedNodeFlows(
85 @Descriptor("Container in which to query FRM") String container,
86 @Descriptor("String representation of the Node, this need to be consumable from Node.fromString()") String nodeId,
87 @Descriptor("True for verbose else false") Boolean verbose) {
88 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
89 IForwardingRulesManager.class, container, this);
91 System.out.println("Cannot find the FRM instance on container: " + container);
94 Node node = Node.fromString(nodeId);
96 System.out.println("Please enter a valid node id");
99 List<FlowEntry> groupFlows = frm.getFlowEntriesForNode(node);
100 System.out.println("Node " + nodeId);
101 for (FlowEntry flowEntry : groupFlows) {
103 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
105 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());
110 @Descriptor("Displays all the flow entries installed in a network node")
111 public void showInstalledNodeFlows(
112 @Descriptor("Container in which to query FRM") String container,
113 @Descriptor("String representation of the Node, this need to be consumable from Node.fromString()") String nodeId,
114 @Descriptor("True for verbose else false") Boolean verbose) {
115 IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance(
116 IForwardingRulesManager.class, container, this);
118 System.out.println("Cannot find the FRM instance on container: " + container);
121 Node node = Node.fromString(nodeId);
123 System.out.println("Please enter a valid node id");
126 List<FlowEntry> groupFlows = frm.getInstalledFlowEntriesForNode(node);
127 System.out.println("Node " + nodeId);
128 for (FlowEntry flowEntry : groupFlows) {
130 System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName());
132 System.out.println(flowEntry.getNode() + " " + flowEntry.toString());