1 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
2 # Copyright (C) 2010 INRIA
6 from TestSsh import TestSsh
10 def __init__ (self,test_plc,key_spec):
11 self.test_plc=test_plc
12 self.key_spec=key_spec
13 self.test_ssh=TestSsh(self.test_plc.test_ssh)
16 return self.key_spec['key_name']
19 return "keys/%s.pub"%(self.name())
20 def privatepath(self):
21 return "keys/%s.rsa"%(self.name())
23 #Not tested yet, don't know if needed
24 # def store_remote_key(self,hostname):
25 # pub=self.publicpath()
26 # priv=self.privatepath()
27 # utils.header("Storing key %s in %s into %s "%(self.name(),pub,hostname))
28 # dir=os.path.dirname(pub)
29 # self.test_ssh.run("mkdir %s"%dir)
30 # self.test_ssh.run("cat %s >> %s"%(self.key_spec['key_fields']['key'],pub))
31 # self.test_ssh.run("cat %s >> %s"%(self.key_spec['private'],priv))
32 # self.test_ssh.run("chmod %s 0400"%priv)
33 # self.test_ssh.run("chmod %s 0444"%pub)
37 priv=self.privatepath()
38 utils.header("Storing key %s in %s"%(self.name(),pub))
39 dir=os.path.dirname(pub)
40 if not os.path.isdir(dir):
43 f.write(self.key_spec['key_fields']['key'])
46 f.write(self.key_spec['private'])