diff options
| author | John Tran <jtran@attinteractive.com> | 2011-03-21 14:35:19 -0700 |
|---|---|---|
| committer | John Tran <jtran@attinteractive.com> | 2011-03-21 14:35:19 -0700 |
| commit | a105fd449a0b91cde3ab86cc552705dfe50e3f6d (patch) | |
| tree | ff8ed8fbbfee114e2bea00bf618c0cde8d4dfb56 /nova/api | |
| parent | 15a40f842cb8a4362fbd82e36e3df4af7ab46a84 (diff) | |
| download | nova-a105fd449a0b91cde3ab86cc552705dfe50e3f6d.tar.gz nova-a105fd449a0b91cde3ab86cc552705dfe50e3f6d.tar.xz nova-a105fd449a0b91cde3ab86cc552705dfe50e3f6d.zip | |
if fingerprint data not provided, added logic to calculate it using the pub key.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 6fe01b0e9..8ec74fbe0 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -27,6 +27,8 @@ import datetime import IPy import os import urllib +import tempfile +import shutil from nova import compute from nova import context @@ -309,8 +311,17 @@ class CloudController(object): key['user_id'] = context.user_id key['name'] = key_name key['public_key'] = public_key - if fingerprint: - key['fingerprint'] = fingerprint + if fingerprint is None: + tmpdir = tempfile.mkdtemp() + pubfile = os.path.join(tmpdir, 'temp.pub') + fh = open(pubfile, 'w') + fh.write(public_key) + fh.close() + (out, err) = utils.execute('ssh-keygen', '-q', '-l', '-f', + '%s' % (pubfile)) + fingerprint = out.split(' ')[1] + shutil.rmtree(tmpdir) + key['fingerprint'] = fingerprint db.key_pair_create(context, key) return True |
