Fixing a collateral damage due to a recent commit.
[ovsdb.git] / ovsdb / src / main / java / org / opendaylight / ovsdb / plugin / ConfigurationService.java
1 package org.opendaylight.ovsdb.plugin;
2
3 import java.net.InetAddress;
4 import java.util.*;
5
6 import org.eclipse.osgi.framework.console.CommandInterpreter;
7 import org.eclipse.osgi.framework.console.CommandProvider;
8 import org.opendaylight.ovsdb.lib.database.OVSBridge;
9 import org.opendaylight.ovsdb.lib.database.OVSInstance;
10 import org.opendaylight.ovsdb.lib.database.OvsdbType;
11 import org.opendaylight.ovsdb.lib.message.TransactBuilder;
12 import org.opendaylight.ovsdb.lib.message.operations.InsertOperation;
13 import org.opendaylight.ovsdb.lib.message.operations.MutateOperation;
14 import org.opendaylight.ovsdb.lib.message.operations.Operation;
15 import org.opendaylight.ovsdb.lib.message.operations.OperationResult;
16 import org.opendaylight.ovsdb.lib.notation.Condition;
17 import org.opendaylight.ovsdb.lib.notation.Function;
18 import org.opendaylight.ovsdb.lib.notation.Mutation;
19 import org.opendaylight.ovsdb.lib.notation.Mutator;
20 import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
21 import org.opendaylight.ovsdb.lib.notation.UUID;
22 import org.opendaylight.ovsdb.lib.table.Bridge;
23 import org.opendaylight.ovsdb.lib.table.Interface;
24 import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
25 import org.opendaylight.ovsdb.lib.table.Port;
26 import org.opendaylight.ovsdb.lib.table.internal.Table;
27 import org.opendaylight.controller.sal.connection.ConnectionConstants;
28 import org.opendaylight.controller.sal.core.Node;
29 import org.opendaylight.controller.sal.core.NodeConnector;
30 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
31 import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
32 import org.opendaylight.controller.sal.utils.Status;
33 import org.opendaylight.controller.sal.utils.StatusCode;
34 import org.osgi.framework.BundleContext;
35 import org.osgi.framework.FrameworkUtil;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 import com.google.common.util.concurrent.ListenableFuture;
40
41 public class ConfigurationService implements IPluginInBridgeDomainConfigService, CommandProvider
42 {
43     private static final Logger logger = LoggerFactory
44             .getLogger(ConfigurationService.class);
45
46     IConnectionServiceInternal connectionService;
47     InventoryServiceInternal inventoryServiceInternal;
48     boolean forceConnect = false;
49
50     void init() {
51     }
52
53     /**
54      * Function called by the dependency manager when at least one dependency
55      * become unsatisfied or when the component is shutting down because for
56      * example bundle is being stopped.
57      *
58      */
59     void destroy() {
60     }
61
62     /**
63      * Function called by dependency manager after "init ()" is called and after
64      * the services provided by the class are registered in the service registry
65      *
66      */
67     void start() {
68         registerWithOSGIConsole();
69     }
70
71     private void registerWithOSGIConsole() {
72         BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass())
73                 .getBundleContext();
74         bundleContext.registerService(CommandProvider.class.getName(), this,
75                 null);
76     }
77
78     /**
79      * Function called by the dependency manager before the services exported by
80      * the component are unregistered, this will be followed by a "destroy ()"
81      * calls
82      *
83      */
84     void stop() {
85     }
86
87     public void setConnectionServiceInternal(IConnectionServiceInternal connectionService) {
88         this.connectionService = connectionService;
89     }
90
91     public void unsetConnectionServiceInternal(IConnectionServiceInternal connectionService) {
92         if (this.connectionService == connectionService) {
93             this.connectionService = null;
94         }
95     }
96
97     public void setInventoryServiceInternal(InventoryServiceInternal inventoryServiceInternal) {
98         this.inventoryServiceInternal = inventoryServiceInternal;
99     }
100
101     public void unsetInventoryServiceInternal(InventoryServiceInternal inventoryServiceInternal) {
102         if (this.inventoryServiceInternal == inventoryServiceInternal) {
103             this.inventoryServiceInternal = null;
104         }
105     }
106
107     private Connection getConnection (Node node) {
108         Connection connection = connectionService.getConnection(node);
109         if (connection == null || !connection.getChannel().isActive()) {
110             return null;
111         }
112
113         return connection;
114     }
115     /**
116      * Add a new bridge
117      * @param node Node serving this configuration service
118      * @param bridgeConnectorIdentifier String representation of a Bridge Connector
119      * @return Bridge Connector configurations
120      */
121     @Override
122     public Status createBridgeDomain(Node node, String bridgeIdentifier,
123             Map<ConfigConstants, Object> configs) throws Throwable {
124         try{
125             if (connectionService == null) {
126                 logger.error("Couldn't refer to the ConnectionService");
127                 return new Status(StatusCode.NOSERVICE);
128             }
129
130             Connection connection = this.getConnection(node);
131             if (connection == null) {
132                 return new Status(StatusCode.NOSERVICE, "Connection to ovsdb-server not available");
133             }
134
135             Map<String, Table<?>> ovsTable = inventoryServiceInternal.getTableCache(node, Open_vSwitch.NAME.getName());
136             String newBridge = "new_bridge";
137             String newInterface = "new_interface";
138             String newPort = "new_port";
139             String newSwitch = "new_switch";
140
141             Operation addSwitchRequest = null;
142
143             if(ovsTable != null){
144                 String ovsTableUUID = (String) ovsTable.keySet().toArray()[0];
145                 UUID bridgeUuidPair = new UUID(newBridge);
146                 Mutation bm = new Mutation("bridges", Mutator.INSERT, bridgeUuidPair);
147                 List<Mutation> mutations = new ArrayList<Mutation>();
148                 mutations.add(bm);
149
150                 UUID uuid = new UUID(ovsTableUUID);
151                 Condition condition = new Condition("_uuid", Function.EQUALS, uuid);
152                 List<Condition> where = new ArrayList<Condition>();
153                 where.add(condition);
154                 addSwitchRequest = new MutateOperation(Open_vSwitch.NAME.getName(), where, mutations);
155             }
156             else{
157                 Open_vSwitch ovsTableRow = new Open_vSwitch();
158                 OvsDBSet<UUID> bridges = new OvsDBSet<UUID>();
159                 UUID bridgeUuidPair = new UUID(newBridge);
160                 bridges.add(bridgeUuidPair);
161                 ovsTableRow.setBridges(bridges);
162                 addSwitchRequest = new InsertOperation(Open_vSwitch.NAME.getName(), newSwitch, ovsTableRow);
163             }
164
165             Bridge bridgeRow = new Bridge();
166             bridgeRow.setName(bridgeIdentifier);
167             OvsDBSet<UUID> ports = new OvsDBSet<UUID>();
168             UUID port = new UUID(newPort);
169             ports.add(port);
170             bridgeRow.setPorts(ports);
171             InsertOperation addBridgeRequest = new InsertOperation(Bridge.NAME.getName(), newBridge, bridgeRow);
172
173             Port portRow = new Port();
174             portRow.setName(bridgeIdentifier);
175             OvsDBSet<UUID> interfaces = new OvsDBSet<UUID>();
176             UUID interfaceid = new UUID(newInterface);
177             interfaces.add(interfaceid);
178             portRow.setInterfaces(interfaces);
179             InsertOperation addPortRequest = new InsertOperation(Port.NAME.getName(), newPort, portRow);
180
181             Interface interfaceRow = new Interface();
182             interfaceRow.setName(bridgeIdentifier);
183             interfaceRow.setType("internal");
184             InsertOperation addIntfRequest = new InsertOperation(Interface.NAME.getName(), newInterface, interfaceRow);
185
186             TransactBuilder transaction = new TransactBuilder();
187             transaction.addOperations(new ArrayList<Operation>(
188                                       Arrays.asList(addSwitchRequest, addIntfRequest, addPortRequest, addBridgeRequest)));
189
190             ListenableFuture<List<OperationResult>> transResponse = connection.getRpc().transact(transaction);
191             List<OperationResult> tr = transResponse.get();
192             List<Operation> requests = transaction.getRequests();
193             Status status = new Status(StatusCode.SUCCESS);
194             for (int i = 0; i < tr.size() ; i++) {
195                 if (i < requests.size()) requests.get(i).setResult(tr.get(i));
196                 if (tr.get(i).getError() != null && tr.get(i).getError().trim().length() > 0) {
197                     OperationResult result = tr.get(i);
198                     status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
199                 }
200             }
201
202             if (tr.size() > requests.size()) {
203                 OperationResult result = tr.get(tr.size()-1);
204                 logger.error("Error creating Bridge : {}\n Error : {}\n Details : {}", bridgeIdentifier,
205                                                                                        result.getError(),
206                                                                                        result.getDetails());
207                 status = new Status(StatusCode.BADREQUEST, result.getError() + " : " + result.getDetails());
208             }
209             return status;
210         } catch(Exception e){
211             e.printStackTrace();
212         }
213         return new Status(StatusCode.INTERNALERROR);
214     }
215
216     /**
217      * Create a Port Attached to a Bridge
218      * Ex. ovs-vsctl add-port br0 vif0
219      * @param node Node serving this configuration service
220      * @param bridgeDomainIdentifier String representation of a Bridge Domain
221      * @param portIdentifier String representation of a user defined Port Name
222      */
223     @Override
224     public Status addPort(Node node, String bridgeIdentifier, String portIdentifier, Map<ConfigConstants, Object> configs) {
225         try{
226             if (connectionService == null) {
227                 logger.error("Couldn't refer to the ConnectionService");
228                 return new Status(StatusCode.NOSERVICE);
229             }
230             Connection connection = this.getConnection(node);
231             if (connection == null) {
232                 return new Status(StatusCode.NOSERVICE, "Connection to ovsdb-server not available");
233             }
234
235             if (connection != null) {
236                 String newInterface = "new_interface";
237                 String newPort = "new_port";
238
239                 Map<String, OVSBridge> existingBridges = OVSBridge.monitorBridge(connection);
240
241                 OVSBridge bridge = existingBridges.get(bridgeIdentifier);
242
243                 List<String> portUuidPair = new ArrayList<String>();
244                 portUuidPair.add("named-uuid");
245                 portUuidPair.add(newPort);
246
247                 List<Object> mutation = new ArrayList<Object>();
248                 mutation.add("ports");
249                 mutation.add("insert");
250                 mutation.add(portUuidPair);
251                 List<Object> mutations = new ArrayList<Object>();
252                 mutations.add(mutation);
253
254                 List<String> bridgeUuidPair = new ArrayList<String>();
255                 bridgeUuidPair.add("uuid");
256                 bridgeUuidPair.add(bridge.getUuid());
257
258                 List<Object> whereInner = new ArrayList<Object>();
259                 whereInner.add("_uuid");
260                 whereInner.add("==");
261                 whereInner.add(bridgeUuidPair);
262
263                 List<Object> where = new ArrayList<Object>();
264                 where.add(whereInner);
265
266                 MutateRequest mutateBridgeRequest = new MutateRequest("Bridge", where, mutations);
267
268                 Map<String, Object> portRow = new HashMap<String, Object>();
269                 portRow.put("name", portIdentifier);
270                 String portType = null;
271                 if (configs != null) {
272                     portType = (String)configs.get(ConfigConstants.TYPE);
273                     if (portType != null && portType.equalsIgnoreCase(OvsdbType.PortType.VLAN.name())) {
274                         try {
275                         portRow.put("tag", Integer.parseInt((String)configs.get(ConfigConstants.VLAN)));
276                         } catch (Exception e) {
277                         }
278                     }
279                 }
280                 ArrayList<String> interfaces = new ArrayList<String>();
281                 interfaces.add("named-uuid");
282                 interfaces.add(newInterface);
283                 portRow.put("interfaces", interfaces);
284                 InsertRequest addPortRequest = new InsertRequest("insert", "Port", newPort, portRow);
285
286                 Map<String, Object> interfaceRow = new HashMap<String, Object>();
287                 interfaceRow.put("name", portIdentifier);
288                 //Tunnel specific
289
290                 if (portType != null && portType.equalsIgnoreCase(OvsdbType.PortType.TUNNEL.name())) {
291                     interfaceRow.put("type", configs.get(ConfigConstants.TUNNEL_TYPE));
292                     ArrayList<Object> intopt = new ArrayList<Object>();
293                     interfaceRow.put("options", intopt);
294                     ArrayList<Object> intoptmap = new ArrayList<Object>();
295                     ArrayList<String> intoptep = new ArrayList<String>();
296                     intopt.add("map");
297                     intopt.add(intoptmap);
298                     intoptmap.add(intoptep);
299                     intoptep.add("remote_ip");
300                     intoptep.add((String)configs.get(ConfigConstants.DEST_IP));
301                 }
302                 InsertRequest addIntfRequest = new InsertRequest("insert", "Interface", newInterface, interfaceRow);
303
304                 Object[] params = {"Open_vSwitch", mutateBridgeRequest, addIntfRequest, addPortRequest};
305                 OvsdbMessage msg = new OvsdbMessage("transact", params);
306
307                 //connection.sendMessage(msg);
308             }
309         }catch(Exception e){
310             e.printStackTrace();
311         }
312         return new Status(StatusCode.SUCCESS);
313     }
314     /**
315      * Implements the OVS Connection for Managers
316      *
317      * @param node Node serving this configuration service
318      * @param String with IP and connection types
319      */
320     @SuppressWarnings("unchecked")
321     public boolean setManager(Node node, String managerip) throws Throwable{
322         try{
323             if (connectionService == null) {
324                 logger.error("Couldn't refer to the ConnectionService");
325                 return false;
326             }
327             Connection connection = this.getConnection(node);
328             if (connection == null) {
329                 return false;
330             }
331
332             if (connection != null) {
333                 String newmanager = "new_manager";
334
335                 OVSInstance instance = OVSInstance.monitorOVS(connection);
336
337                 Map ovsoutter = new LinkedHashMap();
338                 Map ovsinner = new LinkedHashMap();
339                 ArrayList ovsalist1 = new ArrayList();
340                 ArrayList ovsalist2 = new ArrayList();
341                 ArrayList ovsalist3 = new ArrayList();
342                 ArrayList ovsalist4 = new ArrayList();
343
344                 //OVS Table Update
345                 ovsoutter.put("where", ovsalist1);
346                 ovsalist1.add(ovsalist2);
347                 ovsalist2.add("_uuid");
348                 ovsalist2.add("==");
349                 ovsalist2.add(ovsalist3);
350                 ovsalist3.add("uuid");
351                 ovsalist3.add(instance.getUuid());
352                 ovsoutter.put("op", "update");
353                 ovsoutter.put("table", "Open_vSwitch");
354                 ovsoutter.put("row", ovsinner);
355                 ovsinner.put("manager_options", ovsalist4);
356                 ovsalist4.add("named-uuid");
357                 ovsalist4.add(newmanager);
358
359                 Map mgroutside = new LinkedHashMap();
360                 Map mgrinside = new LinkedHashMap();
361
362                 //Manager Table Insert
363                 mgroutside.put("uuid-name", newmanager);
364                 mgroutside.put("op", "insert");
365                 mgroutside.put("table","Manager");
366                 mgroutside.put("row", mgrinside);
367                 mgrinside.put("target", managerip);
368
369                 Object[] params = {"Open_vSwitch", ovsoutter, mgroutside};
370                 OvsdbMessage msg = new OvsdbMessage("transact", params);
371
372                 //connection.sendMessage(msg);
373
374             }
375         }catch(Exception e){
376             e.printStackTrace();
377         }
378         return true;
379     }
380
381     @Override
382     public Status addBridgeDomainConfig(Node node, String bridgeIdentfier,
383             Map<ConfigConstants, Object> configs) {
384         String mgmt = (String)configs.get(ConfigConstants.MGMT);
385         if (mgmt != null) {
386             try {
387                 if (setManager(node, mgmt)) return new Status(StatusCode.SUCCESS);
388             } catch (Throwable e) {
389                 // TODO Auto-generated catch block
390                 e.printStackTrace();
391                 return new Status(StatusCode.INTERNALERROR);
392             }
393         }
394         return new Status(StatusCode.BADREQUEST);
395     }
396
397     @Override
398     public Status addPortConfig(Node node, String bridgeIdentifier, String portIdentifier,
399             Map<ConfigConstants, Object> configs) {
400         // TODO Auto-generated method stub
401         return null;
402     }
403
404     @Override
405     public Status deletePort(Node node, String bridgeIdentifier, String portIdentifier) {
406         // TODO Auto-generated method stub
407         return null;
408     }
409
410     @Override
411     public Node getBridgeDomainNode(Node node, String bridgeIdentifier) {
412         // TODO Auto-generated method stub
413         return null;
414     }
415
416     @Override
417     public Map<ConfigConstants, Object> getPortConfigs(Node node, String bridgeIdentifier,
418             String portIdentifier) {
419         // TODO Auto-generated method stub
420         return null;
421     }
422
423     @Override
424     public Status removeBridgeDomainConfig(Node node, String bridgeIdentifier,
425             Map<ConfigConstants, Object> configs) {
426         // TODO Auto-generated method stub
427         return null;
428     }
429
430     @Override
431     public Status removePortConfig(Node node, String bridgeIdentifier, String portIdentifier,
432             Map<ConfigConstants, Object> configs) {
433         // TODO Auto-generated method stub
434         return null;
435     }
436
437     @Override
438     public Status deleteBridgeDomain(Node node, String bridgeIdentifier) {
439         // TODO Auto-generated method stub
440         return null;
441     }
442
443     @Override
444     public Map<ConfigConstants, Object> getBridgeDomainConfigs(Node node, String bridgeIdentifier) {
445         // TODO Auto-generated method stub
446         return null;
447     }
448
449     @Override
450     public List<String> getBridgeDomains(Node node) {
451
452         Connection connection = connectionService.getConnection(node);
453         Map<String, OVSBridge> existingBridges = OVSBridge.monitorBridge(connection);
454         List<String> bridgeDomains = new ArrayList<String>(existingBridges.keySet());
455         return bridgeDomains;
456     }
457
458     @Override
459     public NodeConnector getNodeConnector(Node arg0, String arg1, String arg2) {
460         return null;
461     }
462
463     public void _ovsconnect (CommandInterpreter ci) {
464         String bridgeName = ci.nextArgument();
465         if (bridgeName == null) {
466             ci.println("Please enter Bridge Name");
467             return;
468         }
469
470         String ovsdbserver = ci.nextArgument();
471         if (ovsdbserver == null) {
472             ci.println("Please enter valid IP-Address");
473             return;
474         }
475         try {
476             InetAddress.getByName(ovsdbserver);
477         }  catch (Exception e) {
478             e.printStackTrace();
479             ci.println("Please enter valid IP-Address");
480             return;
481         }
482         String port = ci.nextArgument();
483         if (port == null) {
484             port = "6634";
485         }
486
487         ci.println("connecting to ovsdb server : "+ovsdbserver+":"+port+" ... ");
488         Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
489         params.put(ConnectionConstants.ADDRESS, ovsdbserver);
490         params.put(ConnectionConstants.PORT, port);
491         Node node = connectionService.connect(bridgeName, params);
492         if (node != null) ci.println("Node Name: "+node.toString());
493         else ci.println("Could not connect to Node");
494     }
495
496     public void _addBridge (CommandInterpreter ci) {
497         String nodeName = ci.nextArgument();
498         if (nodeName == null) {
499             ci.println("Please enter Node Name");
500             return;
501         }
502
503         String bridgeName = ci.nextArgument();
504         if (bridgeName == null) {
505             ci.println("Please enter Bridge Name");
506             return;
507         }
508         Status status;
509         try {
510             status = this.createBridgeDomain(Node.fromString(nodeName), bridgeName, null);
511             ci.println("Bridge creation status : "+status.toString());
512         } catch (Throwable e) {
513             // TODO Auto-generated catch block
514             e.printStackTrace();
515             ci.println("Failed to create Bridge "+bridgeName);
516         }
517     }
518
519     public void _addPort (CommandInterpreter ci) {
520         String nodeName = ci.nextArgument();
521         if (nodeName == null) {
522             ci.println("Please enter Node Name");
523             return;
524         }
525
526         String bridgeName = ci.nextArgument();
527         if (bridgeName == null) {
528             ci.println("Please enter Bridge Name");
529             return;
530         }
531
532         String portName = ci.nextArgument();
533         if (portName == null) {
534             ci.println("Please enter Port Name");
535             return;
536         }
537
538         Status status;
539         try {
540             status = this.addPort(Node.fromString(nodeName), bridgeName, portName, null);
541             ci.println("Port creation status : "+status.toString());
542         } catch (Throwable e) {
543             // TODO Auto-generated catch block
544             e.printStackTrace();
545             ci.println("Failed to create Port "+portName+" in Bridge "+bridgeName);
546         }
547     }
548
549     public void _addPortVlan (CommandInterpreter ci) {
550         String nodeName = ci.nextArgument();
551         if (nodeName == null) {
552             ci.println("Please enter Node Name");
553             return;
554         }
555
556         String bridgeName = ci.nextArgument();
557         if (bridgeName == null) {
558             ci.println("Please enter Bridge Name");
559             return;
560         }
561
562         String portName = ci.nextArgument();
563         if (portName == null) {
564             ci.println("Please enter Port Name");
565             return;
566         }
567
568         String vlan = ci.nextArgument();
569         if (vlan == null) {
570             ci.println("Please enter Valid Vlan");
571             return;
572         } else {
573             try {
574             Integer.parseInt(vlan);
575             } catch (Exception e) {
576                 ci.println("Please enter Valid Vlan");
577                 return;
578             }
579         }
580
581         Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
582         configs.put(ConfigConstants.TYPE, "VLAN");
583         configs.put(ConfigConstants.VLAN, vlan);
584
585         Status status;
586         try {
587             status = this.addPort(Node.fromString(nodeName), bridgeName, portName, configs);
588             ci.println("Port creation status : "+status.toString());
589         } catch (Throwable e) {
590             // TODO Auto-generated catch block
591             e.printStackTrace();
592             ci.println("Failed to create Port "+portName+" in Bridge "+bridgeName);
593         }
594     }
595
596     public void _addTunnel (CommandInterpreter ci) {
597         String nodeName = ci.nextArgument();
598         if (nodeName == null) {
599             ci.println("Please enter Node Name");
600             return;
601         }
602
603         String bridgeName = ci.nextArgument();
604         if (bridgeName == null) {
605             ci.println("Please enter Bridge Name");
606             return;
607         }
608
609         String portName = ci.nextArgument();
610         if (portName == null) {
611             ci.println("Please enter Port Name");
612             return;
613         }
614
615         String tunnelType = ci.nextArgument();
616         if (tunnelType == null) {
617             ci.println("Please enter Tunnel Type");
618             return;
619         }
620
621         String remoteIp = ci.nextArgument();
622         if (remoteIp == null) {
623             ci.println("Please enter valid Remote IP Address");
624             return;
625         }
626
627         try {
628             InetAddress.getByName(remoteIp);
629         }  catch (Exception e) {
630             e.printStackTrace();
631             ci.println("Please enter valid Remote IP Address");
632             return;
633         }
634
635         Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
636         configs.put(ConfigConstants.TYPE, "TUNNEL");
637         configs.put(ConfigConstants.TUNNEL_TYPE, tunnelType);
638         configs.put(ConfigConstants.DEST_IP, remoteIp);
639
640         Status status;
641         try {
642             status = this.addPort(Node.fromString(nodeName), bridgeName, portName, configs);
643             ci.println("Port creation status : "+status.toString());
644         } catch (Throwable e) {
645             // TODO Auto-generated catch block
646             e.printStackTrace();
647             ci.println("Failed to create Port "+portName+" in Bridge "+bridgeName);
648         }
649     }
650
651     public void _printCache (CommandInterpreter ci) {
652         String nodeName = ci.nextArgument();
653         if (nodeName == null) {
654             ci.println("Please enter Node Name");
655             return;
656         }
657         inventoryServiceInternal.printCache(Node.fromString(nodeName));
658     }
659
660     public void _forceConnect (CommandInterpreter ci) {
661         String force = ci.nextArgument();
662         if (force.equalsIgnoreCase("YES")) forceConnect = true;
663         else if (force.equalsIgnoreCase("NO")) forceConnect = false;
664         else ci.println("Please enter YES or NO.");
665         ci.println("Current ForceConnect State : "+forceConnect);
666         return;
667     }
668
669     @Override
670     public String getHelp() {
671         StringBuffer help = new StringBuffer();
672         help.append("---OVSDB CLI---\n");
673         help.append("\t ovsconnect <ConnectionName> <ip-address>                        - Connect to OVSDB\n");
674         help.append("\t addBridge <Node> <BridgeName>                                   - Add Bridge\n");
675         help.append("\t addPort <Node> <BridgeName> <PortName>                          - Add Port\n");
676         help.append("\t addPortVlan <Node> <BridgeName> <PortName> <vlan>               - Add Port, Vlan\n");
677         help.append("\t addTunnel <Node> <Bridge> <Port> <tunnel-type> <remote-ip>      - Add Tunnel\n");
678         help.append("\t printCache <Node>                                               - Prints Table Cache");
679         return help.toString();
680     }
681 }