summaryrefslogtreecommitdiffstats
path: root/nova/crypto.py
diff options
context:
space:
mode:
authorEric Windisch <eric@cloudscaling.com>2011-02-27 20:53:53 -0500
committerEric Windisch <eric@cloudscaling.com>2011-02-27 20:53:53 -0500
commit953efce36b74c18a32ef9c42e6b1a57190e3ff6e (patch)
tree646ebd947d36336007e99f9b395b6025178c6f7f /nova/crypto.py
parent4f90783224025618661bf8814e016843ec237875 (diff)
downloadnova-953efce36b74c18a32ef9c42e6b1a57190e3ff6e.tar.gz
nova-953efce36b74c18a32ef9c42e6b1a57190e3ff6e.tar.xz
nova-953efce36b74c18a32ef9c42e6b1a57190e3ff6e.zip
execvp
Diffstat (limited to 'nova/crypto.py')
-rw-r--r--nova/crypto.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/nova/crypto.py b/nova/crypto.py
index a34b940f5..b240a3958 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -105,8 +105,8 @@ def generate_key_pair(bits=1024):
tmpdir = tempfile.mkdtemp()
keyfile = os.path.join(tmpdir, 'temp')
- utils.execute('ssh-keygen -q -b %d -N "" -f %s' % (bits, keyfile))
- (out, err) = utils.execute('ssh-keygen -q -l -f %s.pub' % (keyfile))
+ utils.execute('ssh-keygen','-q','-b',"%d" % bits,'-N','""','-f',keyfile)
+ (out, err) = utils.execute('ssh-keygen','-q','-l','-f',"%s.pub" % (keyfile))
fingerprint = out.split(' ')[1]
private_key = open(keyfile).read()
public_key = open(keyfile + '.pub').read()
@@ -118,7 +118,7 @@ def generate_key_pair(bits=1024):
# bio = M2Crypto.BIO.MemoryBuffer()
# key.save_pub_key_bio(bio)
# public_key = bio.read()
- # public_key, err = execute('ssh-keygen -y -f /dev/stdin', private_key)
+ # public_key, err = execute('ssh-keygen','-y','-f','/dev/stdin', private_key)
return (private_key, public_key, fingerprint)
@@ -143,8 +143,8 @@ def revoke_cert(project_id, file_name):
start = os.getcwd()
os.chdir(ca_folder(project_id))
# NOTE(vish): potential race condition here
- utils.execute("openssl ca -config ./openssl.cnf -revoke '%s'" % file_name)
- utils.execute("openssl ca -gencrl -config ./openssl.cnf -out '%s'" %
+ utils.execute('openssl','ca','-config','./openssl.cnf','-revoke',"'%s'" % file_name)
+ utils.execute('openssl','ca','-gencrl','-config','./openssl.cnf','-out',"'%s'" %
FLAGS.crl_file)
os.chdir(start)
@@ -193,9 +193,8 @@ def generate_x509_cert(user_id, project_id, bits=1024):
tmpdir = tempfile.mkdtemp()
keyfile = os.path.abspath(os.path.join(tmpdir, 'temp.key'))
csrfile = os.path.join(tmpdir, 'temp.csr')
- utils.execute("openssl genrsa -out %s %s" % (keyfile, bits))
- utils.execute("openssl req -new -key %s -out %s -batch -subj %s" %
- (keyfile, csrfile, subject))
+ utils.execute('openssl','genrsa','-out',keyfile,bits)
+ utils.execute('openssl','req','-new','-key',keyfile,'-out',csrfile,'-batch','-subj',subject)
private_key = open(keyfile).read()
csr = open(csrfile).read()
shutil.rmtree(tmpdir)
@@ -212,8 +211,7 @@ def _ensure_project_folder(project_id):
if not os.path.exists(ca_path(project_id)):
start = os.getcwd()
os.chdir(ca_folder())
- utils.execute("sh geninter.sh %s %s" %
- (project_id, _project_cert_subject(project_id)))
+ utils.execute('sh','geninter.sh',project_id, _project_cert_subject(project_id))
os.chdir(start)
@@ -228,8 +226,8 @@ def generate_vpn_files(project_id):
start = os.getcwd()
os.chdir(ca_folder())
# TODO(vish): the shell scripts could all be done in python
- utils.execute("sh genvpn.sh %s %s" %
- (project_id, _vpn_cert_subject(project_id)))
+ utils.execute('sh','genvpn.sh',
+ project_id, _vpn_cert_subject(project_id))
with open(csr_fn, "r") as csrfile:
csr_text = csrfile.read()
(serial, signed_csr) = sign_csr(csr_text, project_id)
@@ -259,9 +257,9 @@ def _sign_csr(csr_text, ca_folder):
start = os.getcwd()
# Change working dir to CA
os.chdir(ca_folder)
- utils.execute("openssl ca -batch -out %s -config "
- "./openssl.cnf -infiles %s" % (outbound, inbound))
- out, _err = utils.execute("openssl x509 -in %s -serial -noout" % outbound)
+ utils.execute('openssl','ca','-batch','-out',outbound,'-config'
+ './openssl.cnf','-infiles',inbound)
+ out, _err = utils.execute('openssl','x509','-in',outbound','-serial','-noout')
serial = out.rpartition("=")[2]
os.chdir(start)
with open(outbound, "r") as crtfile: