diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-06-14 19:08:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-06-14 19:08:29 +0000 |
| commit | 049bfbcc29d1a5ff45446d88a068990600505bed (patch) | |
| tree | 32f6ae4069d6fd2c2a391234327d3283654c94cf | |
| parent | 75ece85aec3ca794e34bcd03ef90b463528318fe (diff) | |
| parent | 088995fc2c792d6d029abd0e45d5c0cf09a5125a (diff) | |
| download | nova-049bfbcc29d1a5ff45446d88a068990600505bed.tar.gz nova-049bfbcc29d1a5ff45446d88a068990600505bed.tar.xz nova-049bfbcc29d1a5ff45446d88a068990600505bed.zip | |
Merge "Fix VMware Hyper can't honor hw_vif_model image property."
| -rw-r--r-- | nova/tests/virt/vmwareapi/test_vmwareapi.py | 3 | ||||
| -rw-r--r-- | nova/virt/vmwareapi/fake.py | 14 | ||||
| -rw-r--r-- | nova/virt/vmwareapi/vm_util.py | 8 | ||||
| -rw-r--r-- | nova/virt/vmwareapi/vmops.py | 8 |
4 files changed, 23 insertions, 10 deletions
diff --git a/nova/tests/virt/vmwareapi/test_vmwareapi.py b/nova/tests/virt/vmwareapi/test_vmwareapi.py index dd1a0e923..23322d88b 100644 --- a/nova/tests/virt/vmwareapi/test_vmwareapi.py +++ b/nova/tests/virt/vmwareapi/test_vmwareapi.py @@ -179,6 +179,9 @@ class VMwareAPIVMTestCase(test.TestCase): self.assertEquals(vm.get("summary.config.memorySizeMB"), self.type_data['memory_mb']) + self.assertEqual( + vm.get("config.hardware.device")[2].device.obj_name, + "ns0:VirtualE1000") # Check that the VM is running according to Nova self.assertEquals(vm_info['state'], power_state.RUNNING) diff --git a/nova/virt/vmwareapi/fake.py b/nova/virt/vmwareapi/fake.py index 65910f745..07eef5d2f 100644 --- a/nova/virt/vmwareapi/fake.py +++ b/nova/virt/vmwareapi/fake.py @@ -136,7 +136,8 @@ class ManagedObject(object): class DataObject(object): """Data object base class.""" - pass + def __init__(self, obj_name=None): + self.obj_name = obj_name class VirtualDisk(DataObject): @@ -202,6 +203,7 @@ class VirtualMachine(ManagedObject): self.set("summary.config.memorySizeMB", kwargs.get("mem", 1)) self.set("config.hardware.device", kwargs.get("virtual_device", None)) self.set("config.extraConfig", kwargs.get("extra_config", None)) + self.device = kwargs.get("virtual_device") def reconfig(self, factory, val): """ @@ -224,9 +226,8 @@ class VirtualMachine(ManagedObject): controller = VirtualLsiLogicController() controller.key = controller_key - nic = VirtualPCNet32() - - self.set("config.hardware.device", [disk, controller, nic]) + self.set("config.hardware.device", [disk, controller, + self.device[0]]) except AttributeError: # Case of Reconfig of VM to set extra params self.set("config.extraConfig", val.extraConfig) @@ -501,7 +502,7 @@ class FakeFactory(object): def create(self, obj_name): """Creates a namespace object.""" - return DataObject() + return DataObject(obj_name) class FakeVim(object): @@ -584,7 +585,8 @@ class FakeVim(object): "vmPathName": config_spec.files.vmPathName, "numCpu": config_spec.numCPUs, "mem": config_spec.memoryMB, - "extra_config": config_spec.extraConfig} + "extra_config": config_spec.extraConfig, + "virtual_device": config_spec.deviceChange} virtual_machine = VirtualMachine(**vm_dict) _create_object("VirtualMachine", virtual_machine) task_mdo = create_task(method, "success") diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index 4287b4eaa..b04f4148b 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -126,8 +126,12 @@ def create_network_spec(client_factory, vif_info): network_spec = client_factory.create('ns0:VirtualDeviceConfigSpec') network_spec.operation = "add" - # Get the recommended card type for the VM based on the guest OS of the VM - net_device = client_factory.create('ns0:VirtualPCNet32') + # Keep compatible with other Hyper vif model parameter. + if vif_info['vif_model'] == "e1000": + vif_info['vif_model'] = "VirtualE1000" + + vif = 'ns0:' + vif_info['vif_model'] + net_device = client_factory.create(vif) # NOTE(asomya): Only works on ESXi if the portgroup binding is set to # ephemeral. Invalid configuration if set to static and the NIC does diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py index 23c85025b..4a86e4316 100644 --- a/nova/virt/vmwareapi/vmops.py +++ b/nova/virt/vmwareapi/vmops.py @@ -155,10 +155,13 @@ class VMwareVMOps(object): "lsiLogic") disk_type = image_properties.get("vmware_disktype", "preallocated") - return vmdk_file_size_in_kb, os_type, adapter_type, disk_type + # Get the network card type from the image properties. + vif_model = image_properties.get("hw_vif_model", "VirtualE1000") + return (vmdk_file_size_in_kb, os_type, adapter_type, disk_type, + vif_model) (vmdk_file_size_in_kb, os_type, adapter_type, - disk_type) = _get_image_properties() + disk_type, vif_model) = _get_image_properties() vm_folder_ref = self._get_vmfolder_ref() res_pool_ref = self._get_res_pool_ref() @@ -183,6 +186,7 @@ class VMwareVMOps(object): 'mac_address': mac_address, 'network_ref': network_ref, 'iface_id': vif['id'], + 'vif_model': vif_model }) return vif_infos |
