Пример #1
0
def GetHostInClusters(datacenter, hostName, clusterNames=[]):
    if hostName in hostObjs:
        return hostObjs[hostName]
    else:
        if len(clusterNames) == 0:
            clusterObjs = GetAllClusters(datacenter)
        else:
            clusterObjs = GetClusters(datacenter, clusterNames)
        for cl in clusterObjs:
            for h in cl.host:
                hostObjs[h.name] = h
                if h.name == hostName:
                    return h
Пример #2
0
def GetAllResourcePool(datacenter):

    """
    Return list of resourcePool objects from given datacenter.

    @param datacenter: datacenter object
    @type datacenter: Vim.Datacenter
    """

    clusterListObj = GetAllClusters(datacenter)
    respool = []
    for c in clusterListObj:
        respool.append(c.resourcePool)
        """
        for r in c.resourcePool:
            respool.append(r.resourcePool)
        """
    return respool
Пример #3
0
def GetHostsInClusters(datacenter, clusterNames=[], connectionState=None):
    """
    Return list of host objects from given cluster names.

    @param datacenter: datacenter object
    @type datacenter: Vim.Datacenter
    @param clusterNames: cluster name list
    @type clusterNames: string[]
    @param connectionState: host connection state ("connected", "disconnected", "notResponding"), None means all states.
    @typr connectionState: string
    """

    if len(clusterNames) == 0:
        clusterObjs = GetAllClusters(datacenter)
    else:
        clusterObjs = GetClusters(datacenter, clusterNames)

    hostObjs = []
    if connectionState == None:
        hostObjs = [h for cl in clusterObjs for h in cl.host]
    else:
        hostObjs = [h for cl in clusterObjs for h in cl.host if h.runtime.connectionState == connectionState]

    return hostObjs