def get_all_hosts(): hosts = Host.get_all_hosts() hosts_list = [] for host in hosts: hosts_list.append((host.region, host.region)) return hosts_list
def get_all_server_stats(): """ Get server stats for all hosts. """ hosts = Host.get_all_hosts() stats = {'servers_online': 0, 'users_online': 0} for host in hosts: try: s = get_server_stats(host.region) stats['servers_online'] += s.get('servers_online', 0) stats['users_online'] += s.get('users_online', 0) except: pass return stats
def get_host_by_hostname(hostname): """ Searches Hosts and returns tuple of uri for given region. """ hosts = Host.get_all_hosts() for host in hosts: if host.hostname == hostname: return { 'name': host.name, 'region': host.region, 'uri': host.uri, 'active': host.active, 'type': host.type, 'hostname': host.hostname, 'username': host.username, 'password': host.password } else: pass return {}