chef / kitchen-vcenter

A test-kitchen driver for vCenter REST API
https://www.chef.io/implementations/vmware
Apache License 2.0
25 stars 26 forks source link

Exclude Disabled Hosts in ESXi Cluster #91

Closed donwlewis closed 3 years ago

donwlewis commented 4 years ago

Describe the Enhancement:

Exclude disabled hosts in cluster when host is not specified.

Describe the Need:

When using ESXi clusters, it would be nice to not have to put in the host incase it is disabled, or in maintenance mode.

Current Alternative

This functionality partly works except that it doesn't exclude hosts in maintenance mode or disabled. The following error will occur randomly:

 Failed to complete #create action: [InvalidHostState: The operation is not allowed in the current state of the host.] on master-rhel7

Can We Help You Implement This?:

I would be happy to try and implement this. I might need some guidance on where to look, and how to test. Thanks.

donwlewis commented 4 years ago

Looking at this more closely, it might just be a flaw in the vCenter API since all you are doing is passing the cluster as a resource pool. Thats lame...

clintoncwolfe commented 3 years ago

The API only allows filtering on connected state, which we already do here. It looks like Maintenance Mode is only settable from the GUI, and is not readable from the API. The only other readable setting is power_state, which for me is always "POWERED_ON". We could filter after the fact for that, but it's still not solving the real problem - hosts in maintenance mode.

marcparadise commented 3 years ago

Closing this based on @clintoncwolfe 's findings above. @donwlewis please re-open if you find that the API can support this.

thheinen commented 3 years ago

Just seen this notification now. The premise isn't entirely correct, @clintoncwolfe just looked at the wrong place :)

We have to use two APIs for this driver, as the newer REST API (which was checked) does not completely replace the old SOAP API yet. There were advanced made with vSphere 7.0 but it's not yet "there". I would love to get rid of SOAP, but... well.

The Host maintenance status can be checked on the SOAP API via the RbVMomi interface, see https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.host.RuntimeInfo.html and the inMaintenanceMode field there.