0

I am trying to deploy a ovf image in vcenter using the code in below link:

[https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/deploy_ovf.py][1]

python vm_deploy.py -s ‘vcneter_url’ -u ‘username’ -p ‘password’ -v ‘.vmdk path’ -f ‘.ovf path’

But it is failing with below traceback:

   Traceback (most recent call last):
  File "orig.py", line 218, in <module>
    exit(main())
  File "orig.py", line 185, in main
    objs = get_objects(si, args)
  File "orig.py", line 150, in get_objects
    resource_pool_obj = cluster_obj.resourcePool
AttributeError: 'vim.Folder' object has no attribute 'resourcePool'

Im not able to get much help on this error online other than below link:

[https://github.com/vmware/pyvmomi-community-samples/issues/201][1]

I can see dir(cluster_obj) has no resourcePool in it but not sure how to get this working.

rdm_
  • 67
  • 1
  • 8

1 Answers1

0

This script work only if you have manually created a resource pool in your architecture.

However, with a little modification you can target the default resourcePool of a specific Host.

Replace, in get_objects function, this (~line 140) :

# Get cluster object.
cluster_list = datacenter_obj.hostFolder.childEntity
if args.cluster_name:
    cluster_obj = get_obj_in_list(args.cluster_name, cluster_list)
elif len(cluster_list) > 0:
    cluster_obj = cluster_list[0]
else:
    print "No clusters found in DC (%s)." % datacenter_obj.name
hosts = datacenter_obj.hostFolder.childEntity
resource_pool = hosts[0].resourcePool
# Generate resource pool.
resource_pool_obj = cluster_obj.resourcePool

By this :

for computeResource in datacenter_obj.hostFolder.childEntity :
    if computeResource.name == 'ip or hostname here':
        resource_pool = computeResource.resourcePool
        break

The datacenter_obj is given, in the script that you gave, with something lik this :

datacenter_obj = si.content.rootFolder.childEntity[0]

0 is the first Datacenter found.

I hope it will help you, even if the answer comes a little late

Selenith
  • 1
  • 1