4 from Remote import Remote
5 from Table import Table
7 class PLC(dict, Remote):
9 'name': 'TestPLC', # PLC Name
10 'host': 'localhost', # Node Hostname
11 'ip': '127.0.0.1', # IP
13 'vserver': None, # Vserver where this PLC lives
14 'rootkey': '/home/tmack/.ssh/plc-root', # Root Key
15 'api_path': '/PLCAPI/', # PLCAPI path
16 'port': '443' # PLCAPI port
20 def __init__(self, config, fields = {}):
21 # XX Filter out fields not specified in fields
22 dict.__init__(self, self.fields)
24 # Merge defined fields with defaults
29 self.config.update_api(self)
31 def start_xmlrpc_server(self):
33 PLCAPI comes with a SimpleServer script that allows you to run a
34 standalone http server that listens on the specified port.
35 This is useful for running multiple api servers on the same machine.
37 if 'host' in self and not 'host' in ['localhost', None]:
38 server_script = "/usr/share/plc_api/Server.py"
39 self.commands("%s -p %s" % (server_script, self['port']))
40 if self.config.verbose:
41 utils.header("Starting api server at %s on listening on port %s" % (self['host'], self['port']))
43 class PLCs(list, Table):
45 def __init__(self, config, plcs):
46 plclist = [PLC(config, plc) for plc in plcs]
47 list.__init__(self, plclist)