예제 #1
0
def server_list_json():
    servers = aws.get_instance_list(owner=session['username'], terminated=False)
    serverlist = []
    for server in servers:
        serverdata = get_server_information(server)
        serverlist.append(serverdata)
    return jsonify(serverlist)
예제 #2
0
def get_total_costs():
    """Return a dictionary of total instance uptime and costs by user."""
    prices = aws.get_updated_prices()
    servers = aws.get_instance_list(terminated=False)

    user_bill = {}
    for server in servers:
        tags = aws.get_tags_from_aws_object(server)
        if 'Status' in tags and tags['Status'] == 'Live':
            user = tags['User']
            cost_of_instance = (prices[server.instance_type] /
                                3600) * aws.seconds_billed(server)

            if user not in user_bill:
                user_bill[user] = {
                    'num_instances': 1,
                    'total_uptime': aws.seconds_billed(server) / 3600,
                    'total_cost': cost_of_instance
                }
            else:
                user_bill[user]['num_instances'] += 1
                user_bill[user]['total_uptime'] += aws.seconds_billed(
                    server) / 3600
                user_bill[user]['total_cost'] += cost_of_instance

    return user_bill
예제 #3
0
def admin_server_list_json():
    servers = aws.get_instance_list(terminated=False)
    serverlist = []
    for server in servers:
        tags = aws.get_tags_from_aws_object(server)
        serverdata = {
            'launch': server.launch_time,
            'cost': aws.get_cost(server),
            'group': tags.get('Group', False),
            'label': tags.get('Label', False),
            'instance_id': server.instance_id,
            'private_ip_address': server.private_ip_address,
            'instance_type': server.instance_type,
            'disk_space': tags.get('Disk_Space', False),
            'profile': tags.get('Profile', False),
            'status': tags.get('Status', False),
            'shutdown': tags.get('Shutdown', False),
            'name': tags.get('Name', False),
            'state': server.state['Name'],
            'user': tags.get('User', False),
            'image_id': server.image_id
        }
        serverlist.append(serverdata)
    return jsonify(serverlist)
예제 #4
0
def server_list():
    servers = aws.get_instance_list(owner=session['username'],
                                    terminated=False)
    return render_template("servers.html", servers=servers)
예제 #5
0
def admin_dashboard():
    servers = aws.get_instance_list(terminated=False)
    ssh_key_list = ssh_keys.list_all_ssh_keys()
    return render_template("admin.html", servers=servers, ssh_keys=ssh_key_list)
예제 #6
0
def admin_server_listing_state(state):
    servers = aws.get_instance_list(state=state)
    return render_template("admin.html", servers=servers)
예제 #7
0
def admin_server_listing_owner_state(owner, state):
    servers = aws.get_instance_list(owner=owner, state=state)
    return render_template("admin.html", servers=servers, owner=owner)
예제 #8
0
def admin_server_listing_owner(owner):
    servers = aws.get_instance_list(owner=owner, terminated=False)
    ssh_key_list = ssh_keys.list_ssh_keys(owner)
    return render_template("admin.html", servers=servers, owner=owner,
                           ssh_keys=ssh_key_list)