Exemplo n.º 1
0
def allgateways(request):
    '''
    View to look at all RG's in a tabular format, with owners and attached volumes.
    '''
    session = request.session
    username = session['login_email']

    # Get gateways
    try:
        qry = db.list_replica_gateways()
    except:
        qry = []
    gateways = []
    for g in qry:
        gateways.append(g)

    # Get volumes and owners
    vols = []
    g_owners = []
    for g in gateways:
        volset = []
        for v in g.volume_ids:
            volset.append(db.get_volume(v))
        vols.append(volset)
        attrs = {"SyndicateUser.owner_id ==": g.owner_id}
        g_owners.append(db.get_user(attrs))

    gateway_vols_owners = zip(gateways, vols, g_owners)
    t = loader.get_template('gateway_templates/allreplicagateways.html')
    c = RequestContext(request, {
        'username': username,
        'gateway_vols_owners': gateway_vols_owners
    })
    return HttpResponse(t.render(c))
Exemplo n.º 2
0
def allgateways(request):
    '''
    View to look at all RG's in a tabular format, with owners and attached volumes.
    '''
    session = request.session
    username = session['login_email']

    # Get gateways
    try:
        qry = db.list_replica_gateways()
    except:
        qry = []
    gateways = []
    for g in qry:
        gateways.append(g)

    # Get volumes and owners
    vols = []
    g_owners = []
    for g in gateways:
        volset = []
        for v in g.volume_ids:
            volset.append(db.get_volume(v))
        vols.append(volset)
        attrs = {"SyndicateUser.owner_id ==":g.owner_id}
        g_owners.append(db.get_user(attrs))

    gateway_vols_owners = zip(gateways, vols, g_owners)
    t = loader.get_template('gateway_templates/allreplicagateways.html')
    c = RequestContext(request, {'username':username, 'gateway_vols_owners':gateway_vols_owners})
    return HttpResponse(t.render(c))
Exemplo n.º 3
0
def urldelete(request, g_name, g_password):
    '''
    For debugging purposes only, allows deletion of RG via pure URL
    '''
    session = request.session
    username = session['login_email']

    attrs = {"ReplicaGateway.ms_username ==": g_name}
    rgs = db.list_replica_gateways(attrs, limit=1)
    if ags:
        rg = rgs[0]
    else:
        return HttpResponse("RG %s does not exist." % g_name)
    if not rg.authenticate(rg, g_password):
        return HttpResponse("Incorrect RG password.")
    db.delete_replica_gateway(g_name)
    return HttpResponse("Gateway succesfully deleted.")
Exemplo n.º 4
0
def urldelete(request, g_name, g_password):
    '''
    For debugging purposes only, allows deletion of RG via pure URL
    '''
    session = request.session
    username = session['login_email']

    attrs = {"ReplicaGateway.ms_username ==":g_name}
    rgs = db.list_replica_gateways(attrs, limit=1)
    if ags:
        rg = rgs[0]
    else:
        return HttpResponse("RG %s does not exist." % g_name)
    if not rg.authenticate(rg, g_password):
        return HttpResponse("Incorrect RG password.")
    db.delete_replica_gateway(g_name)
    return HttpResponse("Gateway succesfully deleted.")