diff options
| author | Scott Moser <smoser@ubuntu.com> | 2011-09-08 16:02:10 -0700 |
|---|---|---|
| committer | Scott Moser <smoser@ubuntu.com> | 2011-09-08 16:02:10 -0700 |
| commit | a8acd5fbd55ad4cd2cd502e95b2399657fbd162f (patch) | |
| tree | 40af48f3eec68674207fcdca1bd45983af50435c | |
| parent | 67534d897896c2b3ebddcac9be86f669c431a7c2 (diff) | |
| download | nova-a8acd5fbd55ad4cd2cd502e95b2399657fbd162f.tar.gz nova-a8acd5fbd55ad4cd2cd502e95b2399657fbd162f.tar.xz nova-a8acd5fbd55ad4cd2cd502e95b2399657fbd162f.zip | |
if no public-key is given (--key), do not show public-keys in metadata service
| -rw-r--r-- | nova/api/ec2/cloud.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 049ca6f93..c6f24858a 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -304,11 +304,6 @@ class CloudController(object): instance_ref = db.instance_get(ctxt, instance_ref[0]['id']) mpi = self._get_mpi_data(ctxt, instance_ref['project_id']) - if instance_ref['key_name']: - keys = {'0': {'_name': instance_ref['key_name'], - 'openssh-key': instance_ref['key_data']}} - else: - keys = '' hostname = instance_ref['hostname'] host = instance_ref['host'] availability_zone = self._get_availability_zone_by_host(ctxt, host) @@ -336,11 +331,15 @@ class CloudController(object): 'placement': {'availability-zone': availability_zone}, 'public-hostname': hostname, 'public-ipv4': floating_ip or '', - 'public-keys': keys, 'reservation-id': instance_ref['reservation_id'], 'security-groups': security_groups, 'mpi': mpi}} + # public-keys should only show up if it is non-empty (if user specified one) + if instance_ref['key_name']: + data['keys'] = {'0': {'_name': instance_ref['key_name'], + 'openssh-key': instance_ref['key_data']}} + for image_type in ['kernel', 'ramdisk']: if instance_ref.get('%s_id' % image_type): ec2_id = self.image_ec2_id(instance_ref['%s_id' % image_type], |
