@@ -433,6 +433,36 @@ def getHostsFromCluster(self, clusterID):
433433 # Call CloudStack API
434434 return self ._callAPI (apicall )
435435
436+ # Find enabled hosts in a given cluster excluding it's hosts which have been marked dedicated
437+ def getSharedHostsFromCluster (self , clusterID ):
438+ apicall = listHosts .listHostsCmd ()
439+ apicall .clusterid = str (clusterID )
440+ apicall .resourcestate = "Enabled"
441+ apicall .listAll = "true"
442+
443+ # Call CloudStack API
444+ clusterhostdetails = self ._callAPI (apicall )
445+
446+ # Remove dedicated hosts from the results
447+ dedicatedhosts = self .getDedicatedHosts ()
448+ clusterhostdetails_orig = list (clusterhostdetails )
449+ if dedicatedhosts :
450+ for h in clusterhostdetails_orig :
451+ for d in dedicatedhosts :
452+ if h .name == d .name :
453+ if self .DEBUG == 1 :
454+ print "Remove dedicated host from the list: " + str (d .name )
455+ clusterhostdetails .remove (h )
456+ return clusterhostdetails
457+
458+ # Find dedicated hosts
459+ def getDedicatedHosts (self ):
460+ apicall = listDedicatedHosts .listDedicatedHostsCmd ()
461+ apicall .listAll = "true"
462+
463+ # Call CloudStack API
464+ return self ._callAPI (apicall )
465+
436466 # Generic listVirtualMachines function
437467 def listVirtualmachines (self , args ):
438468 args = self .remove_empty_values (args )
0 commit comments