diff options
| author | Jesse Andrews <anotherjesse@gmail.com> | 2010-07-14 18:03:42 -0500 |
|---|---|---|
| committer | Jesse Andrews <anotherjesse@gmail.com> | 2010-07-14 18:03:42 -0500 |
| commit | e2530d85d24fa01518e2f6bf94afe949ee847972 (patch) | |
| tree | 692f0911cf0d8f5ff400372d453510a4783c2b73 /nova | |
| parent | 69104d57f95b8d6609490af8ed981add3fc0a98b (diff) | |
| parent | 5a0d45ed4729bc14078c74af127d238032f43bfc (diff) | |
| download | nova-e2530d85d24fa01518e2f6bf94afe949ee847972.tar.gz nova-e2530d85d24fa01518e2f6bf94afe949ee847972.tar.xz nova-e2530d85d24fa01518e2f6bf94afe949ee847972.zip | |
Merge remote branch 'origin/master'
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/disk.py | 3 | ||||
| -rw-r--r-- | nova/compute/network.py | 4 | ||||
| -rw-r--r-- | nova/crypto.py | 21 | ||||
| -rw-r--r-- | nova/endpoint/cloud.py | 4 |
4 files changed, 20 insertions, 12 deletions
diff --git a/nova/compute/disk.py b/nova/compute/disk.py index bd6a010ee..02768755f 100644 --- a/nova/compute/disk.py +++ b/nova/compute/disk.py @@ -126,8 +126,7 @@ def inject_key(key, image, partition=None, execute=None): yield execute('sudo umount %s' % mapped_device) finally: # remove temporary directory - # TODO(termie): scary, is there any thing we can check here? - yield execute('rm -rf %s' % tmpdir) + yield execute('rmdir %s' % tmpdir) if not partition is None: # remove partitions yield execute('sudo kpartx -d %s' % device) diff --git a/nova/compute/network.py b/nova/compute/network.py index 911d0344a..94fa6c47a 100644 --- a/nova/compute/network.py +++ b/nova/compute/network.py @@ -133,7 +133,7 @@ class BaseNetwork(datastore.RedisModel): @property def hosts(self): - return datastore.Redis.instance().hgetall(self._hosts_key) + return datastore.Redis.instance().hgetall(self._hosts_key) or {} def _add_host(self, _user_id, _project_id, host, target): datastore.Redis.instance().hset(self._hosts_key, host, target) @@ -392,7 +392,7 @@ def _rem_vlan(project_id): def get_assigned_vlans(): """ Returns a dictionary, with keys of project_id and values of vlan_id """ - return datastore.Redis.instance().hgetall(VLANS_KEY) + return datastore.Redis.instance().hgetall(VLANS_KEY) or {} def get_vlan_for_project(project_id): """ diff --git a/nova/crypto.py b/nova/crypto.py index 92a1ab76f..fc6ed714f 100644 --- a/nova/crypto.py +++ b/nova/crypto.py @@ -23,10 +23,12 @@ Wrappers around standard crypto, including root and intermediate CAs, SSH keypairs and x509 certificates. """ +import base64 import hashlib import logging import os import shutil +import struct import tempfile import time import utils @@ -86,14 +88,17 @@ def generate_key_pair(bits=1024): def ssl_pub_to_ssh_pub(ssl_public_key, name='root', suffix='nova'): - """requires lsh-utils""" - convert="sed -e'1d' -e'$d' | pkcs1-conv --public-key-info --base-64 |" \ - + " sexp-conv | sed -e'1s/(rsa-pkcs1/(rsa-pkcs1-sha1/' | sexp-conv -s" \ - + " transport | lsh-export-key --openssh" - (out, err) = utils.execute(convert, ssl_public_key) - if err: - raise exception.Error("Failed to generate key: %s" % err) - return '%s %s@%s\n' %(out.strip(), name, suffix) + rsa_key = M2Crypto.RSA.load_pub_key_bio(M2Crypto.BIO.MemoryBuffer(ssl_public_key)) + e, n = rsa_key.pub() + + key_type = 'ssh-rsa' + + key_data = struct.pack('>I', len(key_type)) + key_data += key_type + key_data += '%s%s' % (e,n) + + b64_blob = base64.b64encode(key_data) + return '%s %s %s@%s\n' %(key_type, b64_blob, name, suffix) def generate_x509_cert(subject, bits=1024): diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py index 19b6db91f..4a3849cb0 100644 --- a/nova/endpoint/cloud.py +++ b/nova/endpoint/cloud.py @@ -523,6 +523,10 @@ class CloudController(object): inst = self.instdir.new() # TODO(ja): add ari, aki inst['image_id'] = kwargs['image_id'] + if 'kernel_id' in kwargs: + inst['kernel_id'] = kwargs['kernel_id'] + if 'ramdisk_id' in kwargs: + inst['ramdisk_id'] = kwargs['ramdisk_id'] inst['user_data'] = kwargs.get('user_data', '') inst['instance_type'] = kwargs.get('instance_type', 'm1.small') inst['reservation_id'] = reservation_id |
