Esempio n. 1
0
File: cluster.py Progetto: bsu/GWM
def virtual_machines(request, cluster_slug):
    """
    Display all virtual machines in a cluster.  Filtered by access the user
    has permissions for
    """
    cluster = get_object_or_404(Cluster, slug=cluster_slug)
    user = request.user
    admin = True if user.is_superuser else user.has_perm('admin', cluster)
    if not admin:
        return render_403(request, "You do not have sufficient privileges")

    vms = cluster.virtual_machines.select_related('cluster').all()
    vms = render_vms(request, vms)

    return render_to_response("virtual_machine/table.html", \
                {'cluster': cluster, 'vms':vms}, \
                context_instance=RequestContext(request))
Esempio n. 2
0
File: node.py Progetto: bsu/GWM
def secondary(request, cluster_slug, host):
    """
    Renders a list of secondary VirtualMachines on the given node
    """
    cluster = get_object_or_404(Cluster, slug=cluster_slug)
    node = get_object_or_404(Node, hostname=host)
    
    user = request.user
    if not (user.is_superuser or user.has_any_perms(cluster, ['admin','migrate'])):
        return render_403(request, "You do not have sufficient privileges")

    vms = node.secondary_vms.all()
    vms = render_vms(request, vms)

    return render_to_response("virtual_machine/table.html", \
                {'node': node, 'vms':vms}, \
                context_instance=RequestContext(request))