Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_resource_pool: cluster_name should not be required #492

Closed
dmelha opened this issue Nov 11, 2020 · 11 comments · Fixed by #524
Closed

vmware_resource_pool: cluster_name should not be required #492

dmelha opened this issue Nov 11, 2020 · 11 comments · Fixed by #524
Assignees
Labels
feature_request New feature or request needs_info This issue requires further information. Please answer any outstanding questions question Further information is requested

Comments

@dmelha
Copy link

dmelha commented Nov 11, 2020

SUMMARY

when creating a resource pool using module vmware_resource_pool it should not be required to specify cluster when instead an esxi-host is specified (e.g. esxi_hostname: foobarhost ) - this problem was part of this issue here but was not resolved - see: ansible/ansible#38300 (comment)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_resource_pool

ANSIBLE VERSION
ansible 2.9.15
  config file = /home/user/gitrepos/therepo/ansible_roles/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/gitrepos/therepo/autopytoolchain/venvp3/lib/python3.6/site-packages/ansible
  executable location = /home/user/gitrepos/therepo/autopytoolchain/venvp3/bin/ansible
  python version = 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
CONFIGURATION
DEFAULT_FORCE_HANDLERS(/home/user/gitrepos/therepo/ansible_roles/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/home/user/gitrepos/therepo/ansible_roles/ansible.cfg) = debug
DEFAULT_TIMEOUT(/home/user/gitrepos/therepo/ansible_roles/ansible.cfg) = 30
HOST_KEY_CHECKING(/home/user/gitrepos/therepo/ansible_roles/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/user/gitrepos/therepo/ansible_roles/ansible.cfg) = False
OS / ENVIRONMENT
  • ansible host OS: Ubuntu 1804 LTS
STEPS TO REPRODUCE
  • setup 1-n esxi hosts in a vmware-datacenter
  • do not create a vmware-cluster
  • try to create a resource_pool via module vmware_resource_pool
    - name: ensure resourcepool exists
      vmware_resource_pool:
        hostname: "{{ _host.vcenter.hostname }}"
        username: "{{ vmware_vcenter_username }}"
        password: "{{ vmware_vcenter_password }}"
        validate_certs: "{{ _host.vcenter.validate_certs }}"
        datacenter: '{{ _host.vmware.datacenter }}'
        esxi_hostname: "{{ _host.vmware.esxi_hostname }}"
        resource_pool: "{{ _host.vmware.resource_pool }}"
        state: present
      delegate_to: localhost
EXPECTED RESULTS
  • the specified resource_pool is created on the esxi host if it does not exist
ACTUAL RESULTS
  • module errors out saying that cluster is required / esxi_hostname is not supported
...
Unsupported parameters for (vmware_resource_pool) module: esxi_hostname Supported parameters include: cluster, cpu_expandable_reservations, cpu_limit, cpu_reservation, cpu_shares, datacenter, hostname, mem_expandable_reservations, mem_limit, mem_reservation, mem_shares, password, port, proxy_host, proxy_port, resource_pool, state, username, validate_certs
...
@Akasurde
Copy link
Member

@dmelha Thanks for reporting this issue. resource_pool is associated with the cluster and not with esxi (correct me if I am wrong). So it makes sense to specify the cluster name.

Also, while creating a new resource pool, we need to specify the parent resource pool under which new resource pool will be created. To get the value of the parent resource pool, cluster is required value.

We can add support esxi_hostname in the module, but AFAIK there is no VMware API to know parent cluster from the given ESXi host system. We will need to implement some logic to gather parent cluster when ESXi name is specified.

I hope this makes sense. Thanks.

@sky-joker @goneri @mariolenz What do you think about this?

@Akasurde Akasurde added feature_request New feature or request needs_info This issue requires further information. Please answer any outstanding questions question Further information is requested waiting_on_contributor Needs help. Feel free to engage to get things unblocked labels Nov 12, 2020
@dmelha
Copy link
Author

dmelha commented Nov 12, 2020

@Akasurde

@dmelha Thanks for reporting this issue. resource_pool is associated with the cluster and not with esxi (correct me if I am wrong). So it makes sense to specify the cluster name.

I'm working with multiple vcenters/datacenters/esxi hosts, that are not organized in clusters but having separate resource_pools defined per host. vmware does in no way require a cluster to be defined for a resourcepool to be created on an esxi host.

Also, while creating a new resource pool, we need to specify the parent resource pool under which new resource pool will be created. To get the value of the parent resource pool, cluster is required value.

We can add support esxi_hostname in the module, but AFAIK there is no VMware API to know parent cluster from the given ESXi host system. We will need to implement some logic to gather parent cluster when ESXi name is specified.

while i don't know the details of the vmware API(s) + pyvmomi (yet), looking at govc/govmomi maybe helps, as govc can create a resource_pool on an esxi host without specifying any cluster or parent resource pool - i just need to specify datacenter & esxi host there via govc pool.create -dc foodc "myesxi/Resources/barpool"

@Akasurde
Copy link
Member

@dmelha Thanks for providing information.

I tried -

$ govc pool.create -dc Asia-Datacenter1 "10.65.201.106/Resources/nested"
govc: cannot create resource pool 'nested': parent not found

Where 10.65.201.106 is esxi. Do you know what is wrong here?

@dmelha
Copy link
Author

dmelha commented Nov 12, 2020

@dmelha Thanks for providing information.

I tried -

$ govc pool.create -dc Asia-Datacenter1 "10.65.201.106/Resources/nested"
govc: cannot create resource pool 'nested': parent not found

Where 10.65.201.106 is esxi. Do you know what is wrong here?

@Akasurde I can only guess that the parent folder(?) (maybe of type vim.ComputeResource) named "Resources" is missing on that host!?
On my vmware infra some resourcepools are always manually created on the hosts via web-vsphere-client. only afterwards I interact via govc +pyvmomi with vcenters & hosts. I guess creating a resourec pool manually could create the folder(?) "Resources" on that esxi host.

@mariolenz
Copy link
Collaborator

@Akasurde

resource_pool is associated with the cluster and not with esxi

Nope, a ResourcePool is associated with a ComputeResource. In most cases, I should say this will be a cluster (there might be use cases for stand-alone ESXi hosts but HA and DRS are something I don't want to miss) but it doesn't have to be. A ClusterComputeResource is just sub-type of ComputeResource.

I'll try to have closer look at his.

@mariolenz
Copy link
Collaborator

@dmelha
I'm sorry, but this feature request (I don't consider it a bug) isn't 100% clear to me.

As far as I understand, you connect to a vCenter and want to configure a resource pool on an ESXi host instead of a cluster. You do not want to connect to the ESXi host directly and configure a resource pool. Is this correct?

@dmelha
Copy link
Author

dmelha commented Nov 16, 2020

@dmelha
I'm sorry, but this feature request (I don't consider it a bug) isn't 100% clear to me.

As far as I understand, you connect to a vCenter and want to configure a resource pool on an ESXi host instead of a cluster. You do not want to connect to the ESXi host directly and configure a resource pool. Is this correct?

@mariolenz yes, I connect to a vcenter, and want to create resource pool on a specific esxi host. I do not want to directly connect to the esxi host for resource pool creation.

sidenote: While I understand this seems like a feature request to you, to me it seems like a bug, as the vsphere api supports this use case, but the resource_pool module inhibits this use case.

@mariolenz
Copy link
Collaborator

yes, I connect to a vcenter, and want to create resource pool on a specific esxi host. I do not want to directly connect to the esxi host for resource pool creation.

Great! I hope this'll be easier to implement :-)

@sky-joker @Tomorrow9
As far as I can see, an ESXi host has two representations in vCenter. It's a HostSystem (which is what we're using in our modules to configure firewall rules and similar), but it's also a ComputeResource (which we would need for this issue).

Do you, by any chance, know how to get the ComputeResource object of an ESXi host? Does it, possibly, have the same name? Unfortunately, I'm away on leave at the moment and don't have access to our environment to check this myself.

@mariolenz
Copy link
Collaborator

For the record:

import ssl
from pyVim import connect
from pyVmomi import vim
context = ssl._create_unverified_context()
si = connect.SmartConnect(host="vcenter.example.com", user="[email protected]", pwd="T0pS3cret!", port=443, sslContext=context)
content = si.content
container = content.viewManager.CreateContainerView(content.rootFolder, [vim.ComputeResource], True)
for managed_object_ref in container.view:
    print(managed_object_ref.name)

This finds all clusters (ClusterComputeResource is a sub-type of ComputeResource) and all hosts (ComputeResource) that are not part of a cluster. I've removed one host from a cluster (esx1.example.com) and now there's a ComputeResource with this name.

@dmelha
Copy link
Author

dmelha commented Nov 25, 2020

jfyi i used this hacky custom module as a (temporary) workaround for now: https://gist.github.com/dmelha/9b25d757e9f075c045b82dce784b8cd6

@mariolenz mariolenz self-assigned this Nov 26, 2020
@mariolenz mariolenz removed the waiting_on_contributor Needs help. Feel free to engage to get things unblocked label Nov 27, 2020
@mariolenz
Copy link
Collaborator

@dmelha Can you please have a look at PR #524 and tell we if this fixes your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature_request New feature or request needs_info This issue requires further information. Please answer any outstanding questions question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants