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
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
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
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