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/{}.pub".format(self.name())
20 def privatepath(self):
21 return "keys/{}.rsa".format(self.name())
24 pub = self.publicpath()
25 priv = self.privatepath()
26 utils.header("Storing key {} in {}".format(self.name(), pub))
27 dir = os.path.dirname(pub)
28 if not os.path.isdir(dir):
30 with open(pub,"w") as f:
31 f.write(self.key_spec['key_fields']['key'])
32 with open(priv,"w") as f:
33 f.write(self.key_spec['private'])