diff options
| author | Eldar Nugaev <enugaev@griddynamics.com> | 2010-12-29 23:30:08 +0300 |
|---|---|---|
| committer | Eldar Nugaev <enugaev@griddynamics.com> | 2010-12-29 23:30:08 +0300 |
| commit | 579d0e1437efb32ef1a1c50ddbfca9093cfa3d18 (patch) | |
| tree | d2729715fa87b904351ab3ea46eef9428b019b5a /nova/api | |
| parent | d30ec2b5814480010d1b42ce2e9bed9fbc441fd1 (diff) | |
added tests for EC2 describe_instances
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 0c20ef329..9fa422301 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -139,7 +139,10 @@ class CloudController(object): "args": {"security_group_id": security_group.id}}) def _get_availability_zone_by_host(self, context, hostname): - return db.service_get_all_compute_by_host(context, hostname)[0]['availability_zone'] + services = db.service_get_all_compute_by_host(context, hostname) + if len(services) > 0: + return services[0]['availability_zone'] + raise Exception(_('No service with hostname: %s' % hostname)) def get_metadata(self, address): ctxt = context.get_admin_context() @@ -675,7 +678,7 @@ class CloudController(object): r['groupSet'] = self._convert_to_set([], 'groups') r['instancesSet'] = [] reservations[instance['reservation_id']] = r - availability_zone = self._get_availability_zone_by_host(ctxt, instance['hostname']) + availability_zone = self._get_availability_zone_by_host(context, instance['hostname']) i['placement'] = {'availabilityZone': availability_zone} reservations[instance['reservation_id']]['instancesSet'].append(i) |
