trailing spaces
[tests.git] / qaapi / qa / PLCs.py
index 2d26bbd..287aac9 100644 (file)
@@ -4,6 +4,7 @@ import utils
 import xmlrpclib       
 from Remote import Remote
 from Table import Table
+from logger import Logfile
 
 class PLC(dict, Remote):
     fields = {
@@ -12,7 +13,7 @@ class PLC(dict, Remote):
        'ip':   '127.0.0.1',                            # IP
        'chroot': None,                                 # Path to the chroot
        'vserver': None,                                # Vserver where this PLC lives
-       'rootkey': None,                                # Root Key
+       'host_rootkey': None,                           # Root Key
        'api_path': '/PLCAPI/',                         # PLCAPI path 
        'port': '443'                                   # PLCAPI port
        
@@ -27,7 +28,12 @@ class PLC(dict, Remote):
        
        # init config
        self.config = config
+       self.__init_logfile__()
 
+    def __init_logfile__(self, filename = None):
+        if not filename:
+            filename = '%s/qaapi.log' % (self.config.logdir)
+        self.logfile = Logfile(filename)
 
     def update_ip(self):
        try:    
@@ -37,7 +43,7 @@ class PLC(dict, Remote):
        except:
            ip = "127.0.0.1"
        self['ip'] = ip.strip() 
-       
+       return self['ip']       
 
     def update_api(self):
        # Set up API acccess
@@ -46,13 +52,24 @@ class PLC(dict, Remote):
        self.update_ip()
        name, ip, port, path = self['name'], self['ip'], self['port'], self['api_path']
        if self.config.verbose:
-           utils.header("Updating %(name)s's api to https://%(ip)s:%(port)s/%(path)s" % locals())   
+           utils.header("Updating %(name)s's api to https://%(ip)s:%(port)s/%(path)s" % locals(), logfile = self.config.logfile)   
        api_server = "https://%(ip)s:%(port)s/%(path)s" % locals()
        self.config.api = xmlrpclib.Server(api_server, allow_none = 1)
         self.config.api_type = 'xmlrpc'        
 
-class PLCs(list, Table):
+    def update_node_images(self):
+       pass
+
+    def scp_to_webroot(self, localfiles, recursive = False):
+       if self.config.verbose:
+           utils.header("Copying %s to %s webroot" % (localfiles, self['name']), logfile = self.config.logfile)
+       self.scp_to("%(localfiles)s" % locals(), "/var/www/html/")
+       url = 'http://%s/%s' % (self['ip'], localfiles) 
+       
+       return url 
+
+class PLCs(Table):
 
     def __init__(self, config, plcs):
        plclist = [PLC(config, plc) for plc in plcs]
-       list.__init__(self, plclist)
+       Table.__init__(self, plclist)