1007 self.destroy(context, instance, network_info, block_device_info) |
1007 self.destroy(context, instance, network_info, block_device_info) |
1008 if root_ci is not None: |
1008 if root_ci is not None: |
1009 self._volume_api.detach(context, root_ci['serial']) |
1009 self._volume_api.detach(context, root_ci['serial']) |
1010 self._volume_api.delete(context, root_ci['serial']) |
1010 self._volume_api.delete(context, root_ci['serial']) |
1011 |
1011 |
|
1012 # Go ahead and remove the root bdm from the bdms so that we do |
|
1013 # not trip up spawn either checking against the use of c1d0 or |
|
1014 # attempting to re-attach the root device. |
|
1015 bdms.objects.remove(bdms.root_bdm()) |
|
1016 rootdevname = block_device_info.get('root_device_name') |
|
1017 if rootdevname is not None: |
|
1018 bdi_bdms = block_device_info.get('block_device_mapping') |
|
1019 for entry in bdi_bdms: |
|
1020 if entry['mount_device'] == rootdevname: |
|
1021 bdi_bdms.remove(entry) |
|
1022 break |
|
1023 |
1012 instance.task_state = task_states.REBUILD_SPAWNING |
1024 instance.task_state = task_states.REBUILD_SPAWNING |
1013 instance.save( |
1025 instance.save( |
1014 expected_task_state=[task_states.REBUILD_BLOCK_DEVICE_MAPPING]) |
1026 expected_task_state=[task_states.REBUILD_BLOCK_DEVICE_MAPPING]) |
1015 |
1027 |
1016 # Instead of using a boolean for 'rebuilding' scratch data, use a |
1028 # Instead of using a boolean for 'rebuilding' scratch data, use a |
1024 instance.save() |
1036 instance.save() |
1025 else: |
1037 else: |
1026 instance.system_metadata['rebuilding'] = 'true' |
1038 instance.system_metadata['rebuilding'] = 'true' |
1027 self.spawn(context, instance, image_meta, injected_files, |
1039 self.spawn(context, instance, image_meta, injected_files, |
1028 admin_password, network_info, block_device_info) |
1040 admin_password, network_info, block_device_info) |
1029 self.power_off(instance) |
|
1030 |
1041 |
1031 del instance.system_metadata['rebuilding'] |
1042 del instance.system_metadata['rebuilding'] |
1032 name = instance['name'] |
1043 name = instance['name'] |
1033 zone = self._get_zone_by_name(name) |
1044 zone = self._get_zone_by_name(name) |
1034 if zone is None: |
1045 if zone is None: |
1035 raise exception.InstanceNotFound(instance_id=name) |
1046 raise exception.InstanceNotFound(instance_id=name) |
1036 |
1047 |
1037 if recreate: |
1048 if recreate: |
1038 zone.attach(['-x', 'initialize-hostdata']) |
1049 zone.attach(['-x', 'initialize-hostdata']) |
1039 |
1050 |
1040 rootmp = instance['root_device_name'] |
1051 rootmp = instance['root_device_name'] |
1041 for entry in bdms: |
1052 for entry in bdms: |
1042 if (entry['connection_info'] is None or |
1053 if (entry['connection_info'] is None or |
1043 rootmp == entry['device_name']): |
1054 rootmp == entry['device_name']): |
1044 continue |
1055 continue |
1045 |
1056 |
1046 connection_info = jsonutils.loads(entry['connection_info']) |
1057 connection_info = jsonutils.loads(entry['connection_info']) |
1047 mount = entry['device_name'] |
1058 mount = entry['device_name'] |
1048 self.attach_volume(context, connection_info, instance, mount) |
1059 self.attach_volume(context, connection_info, instance, mount) |
1049 |
1060 |
1050 self._power_on(instance, network_info) |
1061 self._power_on(instance, network_info) |
1051 |
1062 |
1052 if admin_password is not None: |
1063 if admin_password is not None: |
1053 # Because there is no way to make sure a zone is ready upon |
1064 # Because there is no way to make sure a zone is ready upon |
1054 # returning from a boot request. We must give the zone a few |
1065 # returning from a boot request. We must give the zone a few |
1055 # seconds to boot before attempting to set the admin password. |
1066 # seconds to boot before attempting to set the admin password. |