Esempio n. 1
0
def get_all():
    """
    Get all the information available about registered systems.
    """
    (success, system_data) = ret = get_systems_full()
    if not success:
        return ret

    return (success, dict([(x[0], {'admin_ip': x[1]['admin_ip'],
                                   'hostname': x[1]['hostname'],
                                   'profile': x[1]['profile']}) for x in system_data]))
Esempio n. 2
0
def get_all_systems_with_ping_info(system_type=None):
    """
    get all the registered systems and ping information
    """

    if system_type is None:
        success, system_list = ret = get_systems_full()
    else:
        success, system_list = ret = get_systems_full(system_type=system_type)
    if not success:
        return ret

    systems = dict(system_list)
    for system_id in systems:
        try:
            reachable = ping_system(system_id)
        except APIException:
            reachable = False
        systems[system_id]['reachable'] = reachable

    return True, systems
Esempio n. 3
0
def get_servers():
    ret, server_data = get_systems_full (system_type = 'Server')
    if ret is True:
        server_list = []
        for server in server_data:
            ret, server_id = get_server_id_from_system_id (server[0])
            if ret:
                server_list.append((server_id, {'admin_ip': server[1]['admin_ip'], 'hostname': server[1]['hostname'],'system_id': server[1]['uuid']}))

        return make_ok(servers=dict(server_list))
    current_app.logger.error ("server: get_servers error: " + str(server_data))
    return make_error("Cannot retrieve servers info", 500)
Esempio n. 4
0
def get_all_systems_with_ping_info(system_type=None):
    """
    get all the registered systems and ping information
    """

    if system_type is None:
        success, system_list = ret = get_systems_full()
    else:
        success, system_list = ret = get_systems_full(system_type=system_type)
    if not success:
        return ret

    systems = dict(system_list)
    for system_id in systems:
        try:
            reachable = ping_system(system_id)
        except APIException:
            reachable = False
        systems[system_id]['reachable'] = reachable

    return True, systems
Esempio n. 5
0
def get_servers():
    ret, server_data = get_systems_full(system_type='Server')
    if ret is True:
        server_list = []
        for server in server_data:
            ret, server_id = get_server_id_from_system_id(server[0])
            if ret:
                server_list.append((server_id, {
                    'admin_ip': server[1]['admin_ip'],
                    'hostname': server[1]['hostname'],
                    'system_id': server[1]['uuid']
                }))

        return make_ok(servers=dict(server_list))
    current_app.logger.error("server: get_servers error: " + str(server_data))
    return make_error("Cannot retrieve servers info", 500)
Esempio n. 6
0
def get_all_systems_with_ping_info():
    """
    get all the registered systems and ping information
    """

    success, system_list = ret = get_systems_full()
    if not success:
        return ret

    systems = dict(system_list)
    for system_id, system_data in systems.iteritems():
        system_ip = system_data['admin_ip']
        if system_data['vpn_ip'] != '':
            system_ip = system_data['vpn_ip']

        success, msg = ping_system(system_ip)
        systems[system_id]['reachable'] = success

    return True, systems