@@ -3060,9 +3060,10 @@ def _get_vm_networking_spec(self, instance, network_info):
30603060 config_spec = client_factory .create ('ns0:VirtualMachineConfigSpec' )
30613061 extra_specs = self ._get_extra_specs (instance .flavor ,
30623062 instance .image_meta )
3063- vif_model = instance .image_meta . properties . get ( 'hw_vif_model' ,
3064- constants . DEFAULT_VIF_MODEL )
3063+ image_meta = instance .image_meta
3064+ image_info = images . VMwareImage . from_image ( None , None , image_meta )
30653065
3066+ vif_model = image_info .vif_model
30663067 vm_util .append_vif_infos_to_config_spec (
30673068 client_factory ,
30683069 config_spec ,
@@ -3073,10 +3074,11 @@ def _get_vm_networking_spec(self, instance, network_info):
30733074 def _relocate_vm (self , vm_ref , context , instance , network_info ,
30743075 image_meta = None ):
30753076 image_meta = image_meta or instance .image_meta
3077+ image_info = images .VMwareImage .from_image (None , None , image_meta )
3078+
30763079 storage_policy = self ._get_storage_policy (instance .flavor )
30773080 allowed_ds_types = ds_util .get_allowed_datastore_types (
3078- image_meta .properties .get ('hw_disk_type' ,
3079- constants .DEFAULT_DISK_TYPE ))
3081+ image_info .disk_type )
30803082 hagroup_re , hagroup = self ._get_hagroup_info (context , instance )
30813083 datastore = ds_util .get_datastore (self ._session , self ._cluster ,
30823084 self ._datastore_regex ,
@@ -3093,18 +3095,17 @@ def _relocate_vm(self, vm_ref, context, instance, network_info,
30933095 res_pool = self ._root_resource_pool ,
30943096 folder = folder , datastore = datastore .ref )
30953097 spec .deviceChange = self ._get_network_device_change (vm_ref ,
3096- image_meta ,
3098+ image_info ,
30973099 network_info )
30983100 vm_util .relocate_vm (self ._session , vm_ref , spec = spec )
30993101
3100- def _get_network_device_change (self , vm_ref , image_meta , network_info ):
3102+ def _get_network_device_change (self , vm_ref , image_info , network_info ):
31013103 device_changes = []
31023104 if not network_info :
31033105 return device_changes
31043106
31053107 # Iterate over the network adapters and update the backing
3106- vif_model = image_meta .properties .get ('hw_vif_model' ,
3107- constants .DEFAULT_VIF_MODEL )
3108+ vif_model = image_info .vif_model
31083109 hardware_devices = vm_util .get_hardware_devices (self ._session , vm_ref )
31093110 vif_infos = vmwarevif .get_vif_info (self ._session ,
31103111 self ._cluster ,
@@ -3526,10 +3527,10 @@ def get_relocate_spec(self, context, instance, flavor,
35263527 service_spec = self ._get_service_locator_spec ()
35273528
35283529 image_meta = instance .image_meta
3530+ image_info = images .VMwareImage .from_image (None , None , image_meta )
35293531 storage_policy = self ._get_storage_policy (flavor )
35303532 allowed_ds_types = ds_util .get_allowed_datastore_types (
3531- image_meta .properties .get ('hw_disk_type' ,
3532- constants .DEFAULT_DISK_TYPE ))
3533+ image_info .disk_type )
35333534 res_pool = vm_util .get_res_pool_ref (session , cluster )
35343535 datastore = ds_util .get_datastore (session , cluster ,
35353536 self ._datastore_regex ,
@@ -4869,9 +4870,12 @@ def update_server_group_hagroup_disk_placement(self, context, sg_uuid):
48694870 "but should be on %s. Trying to remedy." ,
48704871 instance .uuid , sg_uuid , current_hagroup , hagroup )
48714872 storage_policy = self ._get_storage_policy (instance .flavor )
4873+
4874+ image_meta = instance .image_meta
4875+ image_info = images .VMwareImage .from_image (None , None , image_meta )
4876+
48724877 allowed_ds_types = ds_util .get_allowed_datastore_types (
4873- instance .image_meta .properties .get (
4874- 'hw_disk_type' , constants .DEFAULT_DISK_TYPE ))
4878+ image_info .disk_type )
48754879
48764880 datastore = ds_util .get_datastore (self ._session , self ._cluster ,
48774881 self ._datastore_regex ,
0 commit comments