Beispiel #1
0
def get_host_status(authTokenId, novaUrl, host_name):
    """Returns the value of the server's state for the given state-type.
    """
    hostStatus = {
        'hypervisor_hostname': None,
        'status': None,
        'state': None,
        'maintenance_migrate_action': None
    }
    for i in range(5):
        try:
            responseTuple = novaUtils.listHypervisorDetails(
                novaUrl, authTokenId)
            if responseTuple and responseTuple[1] and\
                'hypervisors' in responseTuple[1]:
                break
        except ssl.SSLError as e:
            print('SSLError: {0}'.format(e))
            time.sleep(1)
            if i == 4:
                raise
    hypDetail = None
    if responseTuple[1] and 'hypervisors' in responseTuple[1]:
        hypDetail = responseTuple[1]['hypervisors']
    for hdetail in hypDetail:
        if hdetail['hypervisor_hostname'] == host_name:
            hostStatus['hypervisor_hostname'] = hdetail['hypervisor_hostname']
            hostStatus['status'] = hdetail['status']
            hostStatus['state'] = hdetail['state']
            hostStatus['maintenance_migrate_action'] = hdetail[
                'maintenance_migrate_action']
    return hostStatus
Beispiel #2
0
def get_host_list(authTokenId, novaUrl):
    print 'Running novaUtils.listHosts'
    for i in range(5):
        try:
            responseTuple = novaUtils.listHypervisorDetails(novaUrl, authTokenId)
            if responseTuple and responseTuple[1] and\
                'hypervisors' in responseTuple[1]:
                break
        except ssl.SSLError, e:
            print 'SSLError: {0}'.format(e)
            time.sleep(1)
            if i == 4:
                raise
Beispiel #3
0
def get_host_list(authTokenId, novaUrl):
    print('Running novaUtils.listHosts')
    for i in range(5):
        try:
            responseTuple = novaUtils.listHypervisorDetails(novaUrl, authTokenId)
            if responseTuple and responseTuple[1] and\
                'hypervisors' in responseTuple[1]:
                break
        except ssl.SSLError as e:
            print('SSLError: {0}'.format(e))
            time.sleep(1)
            if i == 4:
                raise
    hypDetail = None
    if responseTuple[1] and 'hypervisors' in responseTuple[1]:
        hypDetail = responseTuple[1]['hypervisors']
    return hypDetail