0

I am working with python to try and create a VM using pyvmomi, but I am constantly getting a fail when running the example with the proper arguments set.

This is the code I'm using

pyvmomi community samples create vm

And this is the command I'm sending:

python3 create_vm.py -s vcenter.address.something -u my_svc_account -p 'my-svc-account-pass' -v test --datacenter-name 'dc-01' --datastore-name 'ds-11' --esx-ip {ip of vcenter}

and this is the error I'm getting in output :

Traceback (most recent call last):
  File "create_vm.py", line 79, in <module>
    main()
  File "create_vm.py", line 74, in main
    create_vm(si, args.vm_name, args.datacenter_name, args.esx_ip, args.datastore_name)
  File "create_vm.py", line 31, in create_vm
    destination_host = pchelper.get_obj(content, [vim.HostSystem], host_ip)
  File "/home/timpo/pyvmomi-community-samples/samples/tools/pchelper.py", line 157, in get_obj
    raise RuntimeError("Managed Object " + name + " not found.")
RuntimeError: Managed Object {ip of vcenter} not found.

The esxi-ip I found using nslookup on the vcenter address. I believe this may be the problem, but from what I can see the esxi ip is not a mandatory information, and when I keep it out it returns the same error but there is nothing between "managed object" and "not found".

If that is indeed the problem how can I find the host ip ? I don't have admin access to vcenter and the service account I'm using does not either.

The folks that manage vcenter told me the following:

Not sure what you're trying to do, but the vcenter server does not have one esxi ip. You authenticate to vCenter and that tells you what access you have. With powercli, you do not authenticate directly to an esxi host.

Danilo Patrucco
  • 110
  • 3
  • 10

0 Answers0