Added cliport support for domino-cli.py to be able to run multiple domino clients... 79/15479/1
authorUlas Kozat <ulas.kozat@gmail.com>
Mon, 13 Jun 2016 18:04:35 +0000 (11:04 -0700)
committerUlas Kozat <ulas.kozat@gmail.com>
Mon, 13 Jun 2016 18:04:35 +0000 (11:04 -0700)
Change-Id: I38dd5061d60739ba2e37c50e8887abe69fa0b137
Signed-off-by: Ulas Kozat <ulas.kozat@gmail.com>
DominoClient.py
DominoServer.py
domino-cli.py

index a31e074..19aaa65 100755 (executable)
@@ -142,6 +142,10 @@ class DominoClientCLIService(threading.Thread):
     self.interactive = interactive
 
   def process_input(self, args):
+    if len(args) == 0:
+      print 'Empty API body'
+      return
+
     try:
       if args[0] == 'heartbeat':
         self.dominoclient.heartbeat()
@@ -408,11 +412,11 @@ def main(argv):
   try:
       opts, args = getopt.getopt(argv,"hc:p:i:l:",["conf=","port=","ipaddr=","log=","iac=","cliport="])
   except getopt.GetoptError:
-      print 'DominoClient.py -c/--conf <configfile> -p/--port <socketport> -i/--ipaddr <IPaddr> -l/--log <loglevel> --iac=true/false'
+      print 'DominoClient.py -c/--conf <configfile> -p/--port <socketport> -i/--ipaddr <IPaddr> -l/--log <loglevel> --iac=true/false --cliport <cliport>'
       sys.exit(2)
   for opt, arg in opts:
       if opt == '-h':
-         print 'DominoClient.py -c/--conf <configfile> -p/--port <socketport> -i/--ipaddr <IPaddr> -l/--log <loglevel> --iac=true/false'
+         print 'DominoClient.py -c/--conf <configfile> -p/--port <socketport> -i/--ipaddr <IPaddr> -l/--log <loglevel> --iac=true/false --cliport <cliport>'
          sys.exit()
       elif opt in ("-c", "--conf"):
          configfile = arg
index fc9f0ad..c7d58ef 100755 (executable)
@@ -380,7 +380,7 @@ def main(argv):
       sys.exit(2)
   for opt, arg in opts:
       if opt == '-h':
-         print 'DominoClient.py -c/--conf <configfile> -p/--port <socketport> -i/--ipaddr <IPaddr> -l/--log <loglevel>'
+         print 'DominoServer.py -c/--conf <configfile> -l/--log <loglevel>'
          sys.exit()
       elif opt in ("-c", "--conf"):
          configfile = arg
index 3edf22c..5e55d38 100755 (executable)
@@ -12,6 +12,7 @@
 #   limitations under the License.
 
 import sys, glob, getopt
+import getopt
 
 sys.path.insert(0, glob.glob('./lib')[0])
 
@@ -27,18 +28,13 @@ from thrift.protocol import TBinaryProtocol
 #Load configuration parameters
 from domino_conf import *
 
-def main(argv):
-#  try:
-#    if argv[0] == 'heartbeat':
-#      print 'Heartbeat input'
-#  except IndexError as ex:
-#    print 'Insufficient number of arguments entered'
-#  except:
-#    print('Error: %s', sys.exc_info()[0])
+def main(argv, cli_port):
+  #cli_port = DOMINO_CLI_PORT
 
   try:
     # Make socket
-    transport = TSocket.TSocket('localhost', DOMINO_CLI_PORT)
+    # NOTE that domino-cli.py and DominoClient.py are assumed to be run in the same machine
+    transport = TSocket.TSocket('localhost', cli_port)
     # Buffering is critical. Raw sockets are very slow
     transport = TTransport.TBufferedTransport(transport)
     # Wrap in a protocol
@@ -58,4 +54,8 @@ def main(argv):
     print '%s' % (tx.message)
 
 if __name__ == "__main__":
-   main(sys.argv[1:])
+   if len(sys.argv) >= 2:
+     main(sys.argv[2:], sys.argv[1])
+   else:
+     print 'domino-cli.py <cliport> ...'
+     sys.exit(2)