Ejemplo n.º 1
0
def details(request, query):
    """Details view for Astakos users."""
    vm = get_vm_or_404(query)
    associations = []

    user_list = AstakosUser.objects.filter(uuid=vm.userid)
    associations.append(UserAssociation(request, user_list,))

    project_list = Project.objects.filter(uuid=vm.project)
    associations.append(ProjectAssociation(request, project_list,))

    volume_list = vm.volumes.all()
    associations.append(VolumeAssociation(request, volume_list,))

    network_list = Network.objects.filter(machines__pk=vm.pk)
    associations.append(NetworkAssociation(request, network_list,))

    nic_list = vm.nics.all()
    associations.append(NicAssociation(request, nic_list,))

    ip_list = IPAddress.objects.filter(nic__in=vm.nics.all())
    associations.append(IPAssociation(request, ip_list,))

    ip_log_list = IPAddressHistory.objects.filter(server_id=vm.pk)
    associations.append(IPLogAssociation(request, ip_log_list))

    context = {
        'main_item': vm,
        'main_type': 'vm',
        'action_dict': get_permitted_actions(cached_actions, request.user),
        'associations_list': associations,
    }

    return context
Ejemplo n.º 2
0
def details(request, query):
    """Details view for Astakos users."""
    network = get_network_or_404(query)
    associations = []

    vm_list = network.machines.all()
    associations.append(VMAssociation(
        request,
        vm_list,
    ))

    nic_list = NetworkInterface.objects.filter(network=network)
    associations.append(NicAssociation(
        request,
        nic_list,
    ))

    ip_list = IPAddress.objects.filter(network=network)
    associations.append(IPAssociation(
        request,
        ip_list,
    ))

    user_list = AstakosUser.objects.filter(uuid=network.userid)
    associations.append(UserAssociation(
        request,
        user_list,
    ))

    project_list = Project.objects.filter(uuid=network.project)
    associations.append(ProjectAssociation(
        request,
        project_list,
    ))

    ip_log_list = IPAddressLog.objects.filter(network_id=network.pk)
    associations.append(IPLogAssociation(request, ip_log_list))

    context = {
        'main_item': network,
        'main_type': 'network',
        'action_dict': get_permitted_actions(cached_actions, request.user),
        'associations_list': associations,
    }

    return context
Ejemplo n.º 3
0
def details(request, query):
    """Details view for Astakos users."""
    user = get_user_or_404(query)
    associations = []
    lim = admin_settings.ADMIN_LIMIT_ASSOCIATED_ITEMS_PER_CATEGORY

    quota_list = get_quotas(user)
    total = len(quota_list)
    quota_list = quota_list[:lim]
    associations.append(QuotaAssociation(request, quota_list, total=total))

    qor = Q(members=user) | Q(last_application__applicant=user)
    project_list = Project.objects.filter(qor)
    associations.append(ProjectAssociation(request, project_list))

    vm_list = VirtualMachine.objects.filter(userid=user.uuid)
    associations.append(VMAssociation(request, vm_list))

    volume_list = Volume.objects.filter(userid=user.uuid)
    associations.append(VolumeAssociation(request, volume_list))

    qor = Q(public=True, nics__machine__userid=user.uuid) | Q(userid=user.uuid)
    network_list = Network.objects.filter(qor)
    associations.append(NetworkAssociation(request, network_list))

    nic_list = NetworkInterface.objects.filter(userid=user.uuid)
    associations.append(NicAssociation(request, nic_list))

    ip_list = IPAddress.objects.filter(userid=user.uuid)
    associations.append(IPAssociation(request, ip_list))

    vm_ids = VirtualMachine.objects.filter(userid=user.uuid).values('id')
    ip_log_list = IPAddressLog.objects.filter(server_id__in=vm_ids)
    associations.append(IPLogAssociation(request, ip_log_list))

    context = {
        'main_item': user,
        'main_type': 'user',
        'action_dict': get_permitted_actions(cached_actions, request.user),
        'associations_list': associations,
    }

    return context
Ejemplo n.º 4
0
def details(request, query):
    """Details view for Astakos projects."""
    project = get_project_or_404(query)
    associations = []

    associations.append(custom_user_association(request, project))

    vm_list = VirtualMachine.objects.filter(project=project.uuid)
    associations.append(VMAssociation(
        request,
        vm_list,
    ))

    volume_list = Volume.objects.filter(project=project.uuid)
    associations.append(VolumeAssociation(
        request,
        volume_list,
    ))

    network_list = Network.objects.filter(project=project.uuid)
    associations.append(NetworkAssociation(
        request,
        network_list,
    ))

    ip_list = IPAddress.objects.filter(project=project.uuid)
    associations.append(IPAssociation(
        request,
        ip_list,
    ))

    context = {
        'main_item': project,
        'main_type': 'project',
        'action_dict': get_permitted_actions(cached_actions, request.user),
        'associations_list': associations,
        'last_app': project.last_pending_modification(),
    }

    return context