diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-02 14:20:50 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-02 14:20:50 +0000 |
| commit | c2853c48166cb8d0f1d7b4307c96bba27345419c (patch) | |
| tree | 8a711e7507ef89a5a0d76f74555743e6a4652773 | |
| parent | bb15e269fb020d633830d7fa2ae69774fffaffd2 (diff) | |
| parent | ea711b229789d9db54b7e10fe4c67ee1bf1db8c6 (diff) | |
Merge "Create instance in DB before block device mapping"
| -rw-r--r-- | nova/compute/api.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 557dbb930..3fbaf12df 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -587,7 +587,6 @@ class API(base.Base): instance_uuid = instance['uuid'] mappings = image['properties'].get('mappings', []) if mappings: - instance['shutdown_terminate'] = False self._update_image_block_device_mapping(elevated, instance_type, instance_uuid, mappings) @@ -595,10 +594,17 @@ class API(base.Base): for mapping in (image_bdm, block_device_mapping): if not mapping: continue - instance['shutdown_terminate'] = False self._update_block_device_mapping(elevated, instance_type, instance_uuid, mapping) + def _populate_instance_shutdown_terminate(self, instance, image, + block_device_mapping): + """Populate instance shutdown_terminate information.""" + if (block_device_mapping or + image['properties'].get('mappings') or + image['properties'].get('block_device_mapping')): + instance['shutdown_terminate'] = False + def _populate_instance_names(self, instance): """Populate instance display_name and hostname.""" display_name = instance.get('display_name') @@ -662,11 +668,14 @@ class API(base.Base): self._populate_instance_names(instance) - self._populate_instance_for_bdm(context, instance, - instance_type, image, block_device_mapping) + self._populate_instance_shutdown_terminate(instance, image, + block_device_mapping) instance = self.db.instance_create(context, instance) + self._populate_instance_for_bdm(context, instance, + instance_type, image, block_device_mapping) + # send a state update notification for the initial create to # show it going from non-existent to BUILDING notifications.send_update_with_states(context, instance, None, |
