Exemple #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
Exemple #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 = IPAddressHistory.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
Exemple #3
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
Exemple #4
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 #5
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 = IPAddressLog.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 #6
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified network."""
    actions = get_permitted_actions(cached_actions, request.user)

    if op == "contact":
        user = get_user_or_404(id)
        actions[op].apply(user, request)
    else:
        credentials = Credentials("admin-app", is_admin=True)
        actions[op].apply(id, credentials=credentials)
Exemple #7
0
def catalog(request):
    """List view for Cyclades VMs."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = VMFilterSet().filters.values()
    context['columns'] = ["ID", "Owner UUID", "Name", "State", "Suspended", ""]
    context['item_type'] = 'vm'

    return context
Exemple #8
0
def catalog(request):
    """List view for Cyclades networks."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = NetworkFilterSet().filters.values()
    context['columns'] = ["ID", "Name", "Status", "Public", "Drained", ""]
    context['item_type'] = 'network'

    return context
Exemple #9
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified ip."""
    actions = get_permitted_actions(cached_actions, request.user)

    if op == "contact":
        user = get_user_or_404(id)
        actions[op].apply(user, request)
    else:
        credentials = Credentials("admin-app", is_admin=True)
        actions[op].apply(id, credentials=credentials)
Exemple #10
0
def do_action(request, op, id):
    """Apply the requested action on the specified user."""
    user = get_user_or_404(id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'reject':
        actions[op].apply(user, 'Rejected by the admin')
    elif op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(user)
Exemple #11
0
def catalog(request):
    """List view for Cyclades networks."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = NetworkFilterSet().filters.values()
    context['columns'] = ["ID", "Owner UUID", "Name", "Status", "Public",
                          "Drained", ""]
    context['item_type'] = 'network'

    return context
Exemple #12
0
def catalog(request):
    """List view for Cyclades volumes."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = VolumeFilterSet().filters.values()
    context['columns'] = ["ID", "Name", "Status", "Size (GB)", "Disk template",
                          "VM ID", "Created at", "Updated at", ""]
    context['item_type'] = 'volume'

    return context
Exemple #13
0
def catalog(request):
    """List view for Cyclades ips."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = IPFilterSet().filters.values()
    context['columns'] = ["ID", "Address", "Floating",
                          "Creation date", "User ID", ""]
    context['item_type'] = 'ip'

    return context
Exemple #14
0
def catalog(request):
    """List view for Astakos users."""

    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = UserFilterSet().filters.values()
    context['columns'] = ["ID", "E-mail", "First Name", "Last Name", "Active",
                          "Rejected", "Moderated", "Verified", ""]
    context['item_type'] = 'user'

    return context
Exemple #15
0
def do_action(request, op, id):
    """Apply the requested action on the specified network."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        network = Network.objects.get(pk=id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(network)
Exemple #16
0
def do_action(request, op, id):
    """Apply the requested action on the specified user."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        project = get_project_or_404(id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(project)
Exemple #17
0
def catalog(request):
    """List view for Cyclades projects."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = ProjectFilterSet().filters.values()
    context['columns'] = ["ID", "Owner UUID", "Name", "Project Status",
                          "Application Status", "Creation date", "End date",
                          ""]
    context['item_type'] = 'project'

    return context
Exemple #18
0
def catalog(request):
    """List view for Cyclades ips."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = IPFilterSet().filters.values()
    context['columns'] = [
        "ID", "Owner UUID", "Address", "Floating", "Creation date", ""
    ]
    context['item_type'] = 'ip'

    return context
Exemple #19
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified user."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        project = get_project_or_404(id, for_update=True)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(project)
Exemple #20
0
def catalog(request):
    """List view for Astakos users."""

    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = UserFilterSet().filters.values()
    context['columns'] = ["ID", "E-mail", "First Name", "Last Name", "Active",
                          "Rejected", "Moderated", "Verified", ""]
    context['item_type'] = 'user'

    return context
Exemple #21
0
def do_action(request, op, id):
    """Apply the requested action on the specified volume."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        volume = Volume.objects.get(id=id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(volume)
Exemple #22
0
def do_action(request, op, id):
    """Apply the requested action on the specified ip."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        ip = IPAddress.objects.get(id=id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(ip)
Exemple #23
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified ip."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        ip = get_ip_or_404(id, for_update=True)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(ip)
Exemple #24
0
def catalog(request):
    """List view for Cyclades projects."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = ProjectFilterSet().filters.values()
    context['columns'] = [
        "ID", "Owner UUID", "Name", "Project Status", "Application Status",
        "Creation date", "End date", ""
    ]
    context['item_type'] = 'project'

    return context
Exemple #25
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified user."""
    actions = get_permitted_actions(cached_actions, request.user)

    if op == "contact":
        user = get_user_or_404(id)
        actions[op].apply(user, request)
    else:
        credentials = Credentials("admin-app", is_admin=True)
        kwargs = {"credentials": credentials}
        if op == 'reboot':
            kwargs["reboot_type"] = "SOFT"
        actions[op].apply(id, **kwargs)
Exemple #26
0
def catalog(request):
    """List view for Cyclades volumes."""
    context = {}
    context['action_dict'] = get_permitted_actions(cached_actions,
                                                   request.user)
    context['filter_dict'] = VolumeFilterSet().filters.values()
    context['columns'] = [
        "ID", "Owner UUID", "Name", "Status", "Size (GB)", "Disk template",
        "VM ID", "Created at", "Updated at", ""
    ]
    context['item_type'] = 'volume'

    return context
Exemple #27
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified user."""
    user = get_user_or_404(id, for_update=True)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'reject':
        actions[op].apply(user, 'Rejected by the admin')
    elif op == 'contact':
        actions[op].apply(user, request)
    elif op == 'modify_email':
        if isinstance(data, dict):
            actions[op].apply(user, data.get('new_email'))
    else:
        actions[op].apply(user)
Exemple #28
0
def do_action(request, op, id, data):
    """Apply the requested action on the specified user."""
    user = get_user_or_404(id, for_update=True)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'reject':
        actions[op].apply(user, 'Rejected by the admin')
    elif op == 'contact':
        actions[op].apply(user, request)
    elif op == 'modify_email' or op == 'set_email':
        if isinstance(data, dict):
            actions[op].apply(user, data.get('new_email'))
    else:
        actions[op].apply(user)
Exemple #29
0
def do_action(request, op, id):
    """Apply the requested action on the specified user."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        vm = get_vm_or_404(id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'reboot':
        actions[op].apply(vm, "SOFT")
    elif op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(vm)
Exemple #30
0
def do_action(request, op, id):
    """Apply the requested action on the specified user."""
    if op == "contact":
        user = get_user_or_404(id)
    else:
        vm = get_vm_or_404(id)
    actions = get_permitted_actions(cached_actions, request.user)

    if op == 'reboot':
        actions[op].apply(vm, "SOFT")
    elif op == 'contact':
        actions[op].apply(user, request)
    else:
        actions[op].apply(vm)
Exemple #31
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 #32
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
Exemple #33
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
Exemple #34
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
Exemple #35
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
Exemple #36
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