40e7540173995b642f1592fa0d9a3000bebf7b97
[tests.git] / qaapi / qa / tests / plc_start.py
1 #!/usr/bin/python
2
3 import traceback
4 import sys
5 from Test import Test
6 from qa import utils
7 from qa.PLCs import PLC, PLCs
8
9 class plc_start(Test):
10     """
11     Starts the myplc service
12     """
13
14     def call(self, plc_name = None):
15
16         # Get plc configuration from config
17         plc = PLC(self.config)
18         plcs = getattr(self.config, 'plcs', [])
19         for p in plcs:
20             if p['name'] in [plc_name]:
21                 plc.update(p)   
22                 
23         command = "/sbin/service plc start "
24         if self.config.verbose:
25             utils.header(command)       
26         (status, output) = plc.commands(command)
27
28         if self.config.verbose:
29             utils.header(output)
30
31         # Some plcs may fail when trying to start the http/xmlrpc server 
32         # because the port is already in use. We must start a server on 
33         # another port.
34         plc.start_xmlrpc_server()  
35   
36         
37         return 1
38
39 if __name__ == '__main__':
40     args = tuple(sys.argv[1:])
41     plc_start()(*args)