diff options
| author | John Tran <jtran@attinteractive.com> | 2011-06-07 01:30:59 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-07 01:30:59 +0000 |
| commit | a94992f199edd37ae3efd68c618b19c2ebab1a88 (patch) | |
| tree | c7bd57ce7e4134cb8517cf1fa81b6c78e043fd68 /nova/api | |
| parent | 90d6bf769dba648bb17cb2f6588fc1e65e325f37 (diff) | |
| parent | 81099d63d6ff30b21116f7f0e5c782abadf0ab90 (diff) | |
run_instances will check image for 'available' status before attempting to create a new instance
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index b7a9a8633..ac73cd595 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -895,6 +895,17 @@ class CloudController(object): if kwargs.get('ramdisk_id'): ramdisk = self._get_image(context, kwargs['ramdisk_id']) kwargs['ramdisk_id'] = ramdisk['id'] + image = self._get_image(context, kwargs['image_id']) + if not image: + raise exception.ImageNotFound(image_id=kwargs['image_id']) + try: + available = (image['properties']['image_state'] == 'available') + except KeyError: + available = False + + if not available: + raise exception.ApiError(_('Image must be available')) + instances = self.compute_api.create(context, instance_type=instance_types.get_instance_type_by_name( kwargs.get('instance_type', None)), |
