don't create vmware vm on ESX in maintenance mode (#37124)
* don't create vmware vm on ESX in maint mode update vmware_guest not to try to create VM on ESXi host in maintenance mode * update as requested
This commit is contained in:
parent
454096ca59
commit
371317b553
1 changed files with 5 additions and 15 deletions
|
@ -1489,21 +1489,11 @@ class PyVmomiHelper(PyVmomi):
|
||||||
self.change_detected = True
|
self.change_detected = True
|
||||||
|
|
||||||
def select_host(self):
|
def select_host(self):
|
||||||
# if the user wants a cluster, get the list of hosts for the cluster and use the first one
|
hostsystem = self.cache.get_esx_host(self.params['esxi_hostname'])
|
||||||
if self.params['cluster']:
|
if not hostsystem:
|
||||||
cluster = self.cache.get_cluster(self.params['cluster'])
|
self.module.fail_json(msg='Failed to find ESX host "%(esxi_hostname)s"' % self.params)
|
||||||
if not cluster:
|
if hostsystem.runtime.connectionState != 'connected' or hostsystem.runtime.inMaintenanceMode:
|
||||||
self.module.fail_json(msg='Failed to find cluster "%(cluster)s"' % self.params)
|
self.module.fail_json(msg='ESXi "%(esxi_hostname)s" is in invalid state or in maintenance mode.' % self.params)
|
||||||
hostsystems = [x for x in cluster.host]
|
|
||||||
if not hostsystems:
|
|
||||||
self.module.fail_json(msg='No hosts found in cluster "%(cluster)s. Maybe you lack the right privileges ?"' % self.params)
|
|
||||||
# TODO: add a policy to select host
|
|
||||||
hostsystem = hostsystems[0]
|
|
||||||
else:
|
|
||||||
hostsystem = self.cache.get_esx_host(self.params['esxi_hostname'])
|
|
||||||
if not hostsystem:
|
|
||||||
self.module.fail_json(msg='Failed to find ESX host "%(esxi_hostname)s"' % self.params)
|
|
||||||
|
|
||||||
return hostsystem
|
return hostsystem
|
||||||
|
|
||||||
def autoselect_datastore(self):
|
def autoselect_datastore(self):
|
||||||
|
|
Loading…
Reference in a new issue