Exemple #1
0
def custom_user_association(request, project):
    """Return either all associated project members or only the active ones."""
    if admin_settings.ADMIN_SHOW_ONLY_ACTIVE_PROJECT_MEMBERS:
        total = project.members.all().count()
        user_ids = project.projectmembership_set.actually_accepted().\
            values("person__uuid")
        user_list = AstakosUser.objects.filter(uuid__in=user_ids)
        return UserAssociation(request, user_list, total=total)
    else:
        return UserAssociation(request, project.members.all())
Exemple #2
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
Exemple #3
0
def details(request, query):
    """Details view for Astakos users."""
    volume = get_volume_or_404(query)
    associations = []

    vm_list = VirtualMachine.objects.filter(volumes=volume)
    associations.append(VMAssociation(
        request,
        vm_list,
    ))

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

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

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

    return context
Exemple #4
0
def details(request, query):
    """Details view for Astakos users."""
    ip = get_ip_or_404(query)
    associations = []

    vm_list = [ip.nic.machine] if ip.in_use() else []
    associations.append(SimpleVMAssociation(
        request,
        vm_list,
    ))

    network_list = [ip.nic.network] if ip.in_use() else []
    associations.append(SimpleNetworkAssociation(
        request,
        network_list,
    ))

    nic_list = [ip.nic] if ip.in_use() else []
    associations.append(SimpleNicAssociation(
        request,
        nic_list,
    ))

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

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

    ip_log_list = IPAddressHistory.objects.filter(address=ip.address)
    associations.append(IPLogAssociation(request, ip_log_list))

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

    return context
Exemple #5
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