Пример #1
0
def index(request):
    tenant_id = request.user.tenant_id
    delete_form, handled = DeleteGroup.maybe_handle(request, initial={"tenant_id": tenant_id})
    form = CreateGroup(initial={"tenant_id": tenant_id})
    if handled:
        return handled

    try:
        security_groups = api.security_group_list(request)
    except novaclient_exceptions.ClientException, e:
        security_groups = []
        LOG.exception("ClientException in security_groups index")
        messages.error(request, _("Error fetching security_groups: %s") % e.message)
Пример #2
0
def index(request):
    tenant_id = request.user.tenant_id
    delete_form, handled = DeleteGroup.maybe_handle(
        request, initial={'tenant_id': tenant_id})
    form = CreateGroup(initial={'tenant_id': tenant_id})
    if handled:
        return handled

    try:
        security_groups = api.security_group_list(request)
    except novaclient_exceptions.ClientException, e:
        security_groups = []
        LOG.exception("ClientException in security_groups index")
        messages.error(request,
                       _('Error fetching security_groups: %s') % e.message)
Пример #3
0
        LOG.exception("ClientException in floating ip index")
        messages.error(request,
                    _('Error fetching floating ips: %s') % e.message)
    try:
        keypairs = api.keypair_list(request)
    except novaclient_exceptions.ClientException, e:
        keypairs = []
        LOG.exception("ClientException in keypair index")
        messages.error(request, _('Error fetching keypairs: %s') % e.message)

    context = {'keypairs': keypairs,
               'floating_ips': floating_ips,
               'security_groups': security_groups,
               'keypair_delete_form': DeleteKeypair(),
               'disassociate_form': FloatingIpDisassociate(),
               'release_form': ReleaseFloatingIp(),
               'allocate_form': FloatingIpAllocate(initial={
                                        'tenant_id': request.user.tenant_id}),
               'sec_group_create_form': CreateGroup(
                                            initial={'tenant_id': tenant_id}),
               'sec_group_delete_form': DeleteGroup.maybe_handle(request,
                                            initial={'tenant_id': tenant_id})}

    if request.is_ajax():
        template = 'nova/access_and_security/index_ajax.html'
        context['hide'] = True
    else:
        template = 'nova/access_and_security/index.html'

    return shortcuts.render(request, template, context)