def list_hosts_by_cluster(kwargs=None, call=None):
 if (call != 'function'):
  raise SaltCloudSystemExit('The list_hosts_by_cluster function must be called with -f or --function.')
 ret = {}
 cluster_name = (kwargs.get('cluster') if (kwargs and ('cluster' in kwargs)) else None)
 cluster_properties = ['name']
 cluster_list = salt.utils.vmware.get_mors_with_properties(_get_si(), vim.ClusterComputeResource, cluster_properties)
 for cluster in cluster_list:
  ret[cluster['name']] = []
  for host in cluster['object'].host:
   if isinstance(host, vim.HostSystem):
    ret[cluster['name']].append(host.name)
  if (cluster_name and (cluster_name == cluster['name'])):
   return {'Hosts by Cluster': {cluster_name: ret[cluster_name]}}
 return {'Hosts by Cluster': ret}

def list_hosts_by_cluster ( kwargs = None , call = None ) : if ( call != 'function' ) : raise SaltCloudSystemExit ( 'The list_hosts_by_cluster function must be called with -f or --function.' ) ret = { } cluster_name = ( kwargs . get ( 'cluster' ) if ( kwargs and ( 'cluster' in kwargs ) ) else None ) cluster_properties = [ 'name' ] cluster_list = salt . utils . vmware . get_mors_with_properties ( _get_si ( ) , vim . ClusterComputeResource , cluster_properties ) for cluster in cluster_list : ret [ cluster [ 'name' ] ] = [ ] for host in cluster [ 'object' ] . host : if isinstance ( host , vim . HostSystem ) : ret [ cluster [ 'name' ] ] . append ( host . name ) if ( cluster_name and ( cluster_name == cluster [ 'name' ] ) ) : return { 'Hosts by Cluster' : { cluster_name : ret [ cluster_name ] } } return { 'Hosts by Cluster' : ret }
list hosts for each cluster; or hosts for a specified cluster in this vmware environment to list hosts for each cluster: cli example: .