def _create_vm(self, method, *args, **kwargs):
        """Creates and registers a VM object with the Host System."""
        config_spec = kwargs.get("config")

        if config_spec.guestId not in constants.VALID_OS_TYPES:
            ex = vexc.VMwareDriverException('A specified parameter was '
                                            'not correct.')
            return create_task(method, "error", error_fault=ex).obj

        pool = kwargs.get('pool')
        version = getattr(config_spec, 'version', None)
        devices = []
        for device_change in config_spec.deviceChange:
            if device_change.operation == 'add':
                devices.append(device_change.device)

        vm_ref = create_vm(config_spec.instanceUuid, config_spec.name,
                           config_spec.numCPUs, config_spec.memoryMB,
                           devices, config_spec.files.vmPathName,
                           config_spec.extraConfig, pool,
                           version=version)

        task_mdo = create_task(method, "success", result=vm_ref)
        return task_mdo.obj
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/virt/vmwareapi/fake.py/FakeVim._create_vm/original