Пример #1
0
    def test_image_defaults(self):
        image = vmware_images.VMwareImage(image_id='fake-image-id')

        # N.B. We intentially don't use the defined constants here. Amongst
        # other potential failures, we're interested in changes to their
        # values, which would not otherwise be picked up.
        self.assertEqual('otherGuest', image.os_type)
        self.assertEqual('lsiLogic', image.adapter_type)
        self.assertEqual('preallocated', image.disk_type)
        self.assertEqual('e1000', image.vif_model)
Пример #2
0
    def test_build_virtual_machine(self, mock_get_vim_object):
        mock_get_vim_object.return_value = vmwareapi_fake.FakeVim()

        fake_session = driver.VMwareAPISession()
        fake_vmops = vmops.VMwareVCVMOps(fake_session, None, None)

        image_id = nova.tests.image.fake.get_valid_image_id()
        image = vmware_images.VMwareImage(image_id=image_id)

        vm_ref = fake_vmops.build_virtual_machine(self._instance,
                                                  'fake-instance-name', image,
                                                  self._dc_info, self._ds,
                                                  self.network_info)

        vm = vmwareapi_fake._get_object(vm_ref)

        # Test basic VM parameters
        self.assertEqual('fake-instance-name', vm.name)
        # NOTE(mdbooth): The instanceUuid behaviour below is apparently
        # deliberate.
        self.assertEqual('fake-instance-name',
                         vm.get('summary.config.instanceUuid'))
        self.assertEqual(self._instance_values['vcpus'],
                         vm.get('summary.config.numCpu'))
        self.assertEqual(self._instance_values['memory_mb'],
                         vm.get('summary.config.memorySizeMB'))

        # Test NSX config
        for optval in vm.get('config.extraConfig').OptionValue:
            if optval.key == 'nvp.vm-uuid':
                self.assertEqual(self._instance_values['uuid'], optval.value)
                break
        else:
            self.fail('nvp.vm-uuid not found in extraConfig')

        # Test that the VM is associated with the specified datastore
        datastores = vm.datastore.ManagedObjectReference
        self.assertEqual(1, len(datastores))

        datastore = vmwareapi_fake._get_object(datastores[0])
        self.assertEqual(self._ds.name, datastore.get('summary.name'))

        # Test that the VM's network is configured as specified
        devices = vm.get('config.hardware.device').VirtualDevice
        for device in devices:
            if device.obj_name != 'ns0:VirtualE1000':
                continue
            self.assertEqual(self._network_values['address'],
                             device.macAddress)
            break
        else:
            self.fail('NIC not configured')