remote chroot-myplc and remote qemu testbox should almost work
[tests.git] / system / TestKey.py
index 28032f2..4df0b48 100644 (file)
@@ -1,20 +1,34 @@
 import utils
 import os, os.path
+from TestSsh import TestSsh
 
 class TestKey:
 
     def __init__ (self,test_plc,key_spec):
        self.test_plc=test_plc
        self.key_spec=key_spec
+        self.test_ssh=TestSsh(self.test_plc.test_ssh)
         
     def name(self):
         return self.key_spec['name']
 
     def publicpath(self):
-        return "/root/%s/keys/%s.pub"%(self.test_plc.path,self.name())
+        return "keys/%s.pub"%(self.name())
     def privatepath(self):
-        return "/root/%s/keys/%s.rsa"%(self.test_plc.path,self.name())
+        return "keys/%s.rsa"%(self.name())
 
+    def store_remote_key(self,hostname):
+        #Not tested yet, don't know if needed
+        pub=self.publicpath()
+        priv=self.privatepath()
+        utils.header("Storing key %s in %s into %s "%(self.name(),pub,hostname))
+        dir=os.path.dirname(pub)
+        self.test_ssh.run("mkdir %s"%dir)
+        self.test_ssh.run("cat %s >> %s"%(self.key_spec['key_fields']['key'],pub))
+        self.test_ssh.run("cat %s >> %s"%(self.key_spec['private'],priv))
+        self.test_ssh.run("chmod %s 0400"%priv)
+        self.test_ssh.run("chmod %s 0444"%pub)
+            
     def store_key(self):
         pub=self.publicpath()
         priv=self.privatepath()