pyvmomi icon indicating copy to clipboard operation
pyvmomi copied to clipboard

can use pyvmomi create vvol2.0 vm more than 2 disk ???

Open swuOflei opened this issue 3 years ago • 0 comments

I plan to use pyvmomi to create a vvol VM configured with 2 disks. vim.vm.ConfigSpec().vmProfile and vim.vm.device.VirtualDeviceSpec().profile are set to the VM storage policy profile as prompted. However, the VM fails to be created, and the message "A general system error occurred: Error creating disk The VVol target encountered a vendor specific error" is displayed. The VASA provider does not receive the disk storage profile of the VM.

code like this:

def create_vm_storage_profile_spec(self, vm_storage_policy_profile): """ :param vm_storage_policy_profile: :return: """ storage_profile_specs = [] storage_profile_spec = vim.vm.DefinedProfileSpec() storage_profile_spec.profileId = vm_storage_policy_profile.profileId.uniqueId storage_profile_spec.replicationSpec = vim.vm.replication.ReplicationSpec() replication_group = vim.vm.replication.ReplicationGroupId() device_group_id = vim.vm.replication.DeviceGroupId() device_group_id.id = 'ffffffff-ffff-ffff-ffff-ffffffffffff' fault_domain_id = vim.vm.replication.FaultDomainId() fault_domain_id.id = 'f0fe8c4f-c08b-4a15-ae07-7dca8a436335' # fault_domain_id.id = self.spbm_fault_domain_id replication_group.deviceGroupId = device_group_id replication_group.faultDomainId = fault_domain_id storage_profile_spec.replicationSpec.replicationGroupId = replication_group storage_profile_specs.append(storage_profile_spec) return storage_profile_specs

vm_config_spec = vim.vm.ConfigSpec() if vm_storage_policy_profile: storage_profile_specs = self.create_vm_storage_profile_spec(vm_storage_policy_profile) vm_config_spec.vmProfile = storage_profile_specs

if 1 <= disk_num < 8: for disk_num_tmp in range(1, disk_num + 1): disk_config_spec_tmp = vim.vm.device.VirtualDeviceSpec() disk_config_spec_tmp.fileOperation = 'create' disk_config_spec_tmp.device = vim.vm.device.VirtualDisk() disk_config_spec_tmp.device.capacityInKB = disk_sizeGB * 1024 * 1024 disk_config_spec_tmp.device.controllerKey = scsi_config_sec.device.key disk_config_spec_tmp.device.unitNumber = disk_num_tmp - 1 disk_config_spec_tmp.device.backing =
vim.vm.device.VirtualDisk.FlatVer2BackingInfo() disk_config_spec_tmp.device.backing.fileName = datastore_path if vm_storage_policy_profile: disk_config_spec_tmp.profile = storage_profile_specs

swuOflei avatar Aug 16 '21 07:08 swuOflei