diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-01-25 23:14:48 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-01-25 23:14:48 +0000 |
| commit | 7614c02e9a31bfbdc9cc52e42b438848eec6af58 (patch) | |
| tree | c8814c52794b9787fa2c8a06debde8c55ca2b708 /nova/api | |
| parent | 22fb35771a08e94cb0f48dc3eb92bf6b673c3390 (diff) | |
| parent | 60f992b7fa1d1abf494cc210f7f199414a0538bb (diff) | |
Wraps the NotFound exception at the api layer to print the proper instance id. Does the same for volume. Note that euca-describe-volumes doesn't pass in volume ids properly, so you will get no error messages on euca-describe-volumes with improper ids. We may also need to wrap a few other calls as well.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 3b228bf1a..22b8c19cb 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -529,11 +529,18 @@ class CloudController(object): def describe_volumes(self, context, volume_id=None, **kwargs): if volume_id: - volume_id = [ec2_id_to_id(x) for x in volume_id] - volumes = self.volume_api.get_all(context) - # NOTE(vish): volume_id is an optional list of volume ids to filter by. - volumes = [self._format_volume(context, v) for v in volumes - if volume_id is None or v['id'] in volume_id] + volumes = [] + for ec2_id in volume_id: + internal_id = ec2_id_to_id(ec2_id) + try: + volume = self.volume_api.get(context, internal_id) + volumes.append(volume) + except exception.NotFound: + raise exception.NotFound(_("Volume %s not found") + % ec2_id) + else: + volumes = self.volume_api.get_all(context) + volumes = [self._format_volume(context, v) for v in volumes] return {'volumeSet': volumes} def _format_volume(self, context, volume): @@ -658,8 +665,15 @@ class CloudController(object): reservations = {} # NOTE(vish): instance_id is an optional list of ids to filter by if instance_id: - instance_id = [ec2_id_to_id(x) for x in instance_id] - instances = [self.compute_api.get(context, x) for x in instance_id] + instances = [] + for ec2_id in instance_id: + internal_id = ec2_id_to_id(ec2_id) + try: + instance = self.compute_api.get(context, internal_id) + instances.append(instance) + except exception.NotFound: + raise exception.NotFound(_("Instance %s not found") + % ec2_id) else: instances = self.compute_api.get_all(context, **kwargs) for instance in instances: |
