git://git.onelab.eu
/
tests.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
no more lxc-enter-namespace - use ssh
[tests.git]
/
system
/
TestKey.py
diff --git
a/system/TestKey.py
b/system/TestKey.py
index
8284609
..
ddef527
100644
(file)
--- a/
system/TestKey.py
+++ b/
system/TestKey.py
@@
-1,33
+1,36
@@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA
+#
import utils
import os, os.path
import utils
import os, os.path
+from TestSsh import TestSsh
class TestKey:
class TestKey:
- def __init__ (self,test_plc,key_spec):
- self.test_plc=test_plc
- self.key_spec=key_spec
+ 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):
def name(self):
- return self.key_spec['name']
+ return self.key_spec['
key_
name']
def publicpath(self):
def publicpath(self):
- return "
%s/keys/%s.pub"%(self.test_plc.path,
self.name())
+ return "
keys/{}.pub".format(
self.name())
def privatepath(self):
def privatepath(self):
- return "
%s/keys/%s.rsa"%(self.test_plc.path,
self.name())
+ return "
keys/{}.rsa".format(
self.name())
def store_key(self):
def store_key(self):
- pub
=
self.publicpath()
- priv
=
self.privatepath()
- utils.header("Storing key
%s in %s"%(self.name(),
pub))
- dir
=
os.path.dirname(pub)
+ pub
=
self.publicpath()
+ priv
=
self.privatepath()
+ utils.header("Storing key
{} in {}".format(self.name(),
pub))
+ dir
=
os.path.dirname(pub)
if not os.path.isdir(dir):
os.mkdir(dir)
if not os.path.isdir(dir):
os.mkdir(dir)
- f=open(pub,"w")
- f.write(self.key_spec['key_fields']['key'])
- f.close()
- f=open(priv,"w")
- f.write(self.key_spec['private'])
- f.close()
- os.chmod(priv,0400)
- os.chmod(pub,0444)
+ with open(pub,"w") as f:
+ f.write(self.key_spec['key_fields']['key'])
+ with open(priv,"w") as f:
+ f.write(self.key_spec['private'])
+ os.chmod(priv,0o400)
+ os.chmod(pub,0o444)