3 #Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
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 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 import sys, glob, getopt
16 sys.path.insert(0, glob.glob('./lib')[0])
18 from dominoCLI import DominoClientCLI
19 from dominoCLI.ttypes import *
20 from dominoCLI.constants import *
22 from thrift import Thrift
23 from thrift.transport import TSocket
24 from thrift.transport import TTransport
25 from thrift.protocol import TBinaryProtocol
27 #Load configuration parameters
28 from domino_conf import *
32 # if argv[0] == 'heartbeat':
33 # print 'Heartbeat input'
34 # except IndexError as ex:
35 # print 'Insufficient number of arguments entered'
37 # print('Error: %s', sys.exc_info()[0])
41 transport = TSocket.TSocket('localhost', DOMINO_CLI_PORT)
42 # Buffering is critical. Raw sockets are very slow
43 transport = TTransport.TBufferedTransport(transport)
45 protocol = TBinaryProtocol.TBinaryProtocol(transport)
47 # Create a client to use the protocol encoder
48 client = DominoClientCLI.Client(protocol)
54 CLImsg.CLI_input = argv
55 CLIrespmsg = client.d_CLI(CLImsg)
56 print CLIrespmsg.CLI_response
58 except Thrift.TException, tx:
59 print '%s' % (tx.message)
61 if __name__ == "__main__":