diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-01-17 19:08:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-01-17 19:08:11 +0000 |
| commit | 8c1e0022028a454f536ff211aa200cab9b0111aa (patch) | |
| tree | 92765824da15865893a50c43ae2bd86689bbd958 /nova/api | |
| parent | 61b0c08b7cfe68ca3d567e05dd0bc333658cdc77 (diff) | |
| parent | 006fea117307460544492a3548203a9ef31f34ba (diff) | |
Merge "Clean up generate fingerprint."
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 17 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/keypairs.py | 7 |
2 files changed, 2 insertions, 22 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index bdeb7dc2e..b082d0598 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -399,21 +399,6 @@ class CloudController(object): 'keyMaterial': data['private_key']} # TODO(vish): when context is no longer an object, pass it here - def _get_fingerprint(self, public_key): - tmpdir = tempfile.mkdtemp() - pubfile = os.path.join(tmpdir, 'temp.pub') - fh = open(pubfile, 'w') - fh.write(public_key) - fh.close() - try: - (out, err) = utils.execute('ssh-keygen', '-l', '-f', - '%s' % (pubfile)) - return out.split(' ')[1] - except Exception: - raise - finally: - shutil.rmtree(tmpdir) - def import_key_pair(self, context, key_name, public_key_material, **kwargs): LOG.audit(_("Import key %s"), key_name, context=context) @@ -423,7 +408,7 @@ class CloudController(object): except exception.NotFound: pass public_key = base64.b64decode(public_key_material) - fingerprint = self._get_fingerprint(public_key) + fingerprint = crypto.generate_fingerprint(public_key) key = {} key['user_id'] = context.user_id key['name'] = key_name diff --git a/nova/api/openstack/compute/contrib/keypairs.py b/nova/api/openstack/compute/contrib/keypairs.py index c97fab0f4..c09ca555f 100644 --- a/nova/api/openstack/compute/contrib/keypairs.py +++ b/nova/api/openstack/compute/contrib/keypairs.py @@ -92,12 +92,7 @@ class KeypairController(object): # import if public_key is sent if 'public_key' in params: - tmpdir = tempfile.mkdtemp() - fn = os.path.join(tmpdir, 'import.pub') - with open(fn, 'w') as pub: - pub.write(params['public_key']) - fingerprint = crypto.generate_fingerprint(fn) - shutil.rmtree(tmpdir) + fingerprint = crypto.generate_fingerprint(params['public_key']) keypair['public_key'] = params['public_key'] keypair['fingerprint'] = fingerprint else: |
