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