vmware/pyvmomi-community-samples

add_nic_to_vm.py issue: TypeError: For "deviceName" expected type str, but got vim.dvs.DistributedVirtualPortgroup

Open

#647 geöffnet am 21. Juli 2020

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (914 Forks)batch import
help wanted

Repository-Metriken

Stars
 (972 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Traceback (most recent call last): File "./add_nic_to_vm-new.py", line 165, in main() File "./add_nic_to_vm-new.py", line 158, in main add_nic(serviceInstance, vm, args.port_group) File "./add_nic_to_vm-new.py", line 113, in add_nic nic_spec.device.backing.deviceName = network File "/usr/local/lib/python2.7/dist-packages/pyVmomi/VmomiSupport.py", line 537, in setattr CheckField(self._GetPropertyInfo(name), val) File "/usr/local/lib/python2.7/dist-packages/pyVmomi/VmomiSupport.py", line 972, in CheckField % (info.name, info.type.name, valType.name)) TypeError: For "deviceName" expected type str, but got vim.dvs.DistributedVirtualPortgroup

If we change line #113 from: nic_spec.device.backing.deviceName = network to: nic_spec.device.backing.deviceName = network.name

then it works.

Contributor Guide