1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2011 United States Government as represented by the
4
# Administrator of the National Aeronautics and Space Administration.
7
# Copyright 2011 Nebula, Inc.
8
# Copyright 2011 OpenStack LLC
10
# Licensed under the Apache License, Version 2.0 (the "License"); you may
11
# not use this file except in compliance with the License. You may obtain
12
# a copy of the License at
14
# http://www.apache.org/licenses/LICENSE-2.0
16
# Unless required by applicable law or agreed to in writing, software
17
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19
# License for the specific language governing permissions and limitations
23
Views for Instances and Volumes.
28
from django import http
29
from django import shortcuts
30
from django.contrib import messages
31
from django.contrib.auth.decorators import login_required
32
from django.utils.translation import ugettext as _
33
from novaclient import exceptions as novaclient_exceptions
34
import openstackx.api.exceptions as api_exceptions
36
from horizon import api
37
from horizon import forms
38
from horizon import test
39
from horizon.dashboards.nova.access_and_security.keypairs.forms import \
41
from horizon.dashboards.nova.access_and_security.security_groups.forms import \
44
from horizon.dashboards.nova.access_and_security.floating_ips.forms import \
46
FloatingIpDisassociate,
50
LOG = logging.getLogger(__name__)
55
tenant_id = request.user.tenant_id
56
for f in (CreateGroup, DeleteGroup, DeleteKeypair, ReleaseFloatingIp,
57
FloatingIpDisassociate, FloatingIpAllocate):
58
_unused, handled = f.maybe_handle(request)
63
security_groups = api.security_group_list(request)
64
except novaclient_exceptions.ClientException, e:
66
LOG.exception("ClientException in security_groups index")
67
messages.error(request, _('Error fetching security_groups: %s')
70
floating_ips = api.tenant_floating_ip_list(request)
71
except novaclient_exceptions.ClientException, e:
73
LOG.exception("ClientException in floating ip index")
74
messages.error(request,
75
_('Error fetching floating ips: %s') % e.message)
77
keypairs = api.keypair_list(request)
78
except novaclient_exceptions.ClientException, e:
80
LOG.exception("ClientException in keypair index")
81
messages.error(request, _('Error fetching keypairs: %s') % e.message)
83
context = {'keypairs': keypairs,
84
'floating_ips': floating_ips,
85
'security_groups': security_groups,
86
'keypair_delete_form': DeleteKeypair(),
87
'disassociate_form': FloatingIpDisassociate(),
88
'release_form': ReleaseFloatingIp(),
89
'allocate_form': FloatingIpAllocate(initial={
90
'tenant_id': request.user.tenant_id}),
91
'sec_group_create_form': CreateGroup(
92
initial={'tenant_id': tenant_id}),
93
'sec_group_delete_form': DeleteGroup.maybe_handle(request,
94
initial={'tenant_id': tenant_id})}
97
template = 'nova/access_and_security/index_ajax.html'
98
context['hide'] = True
100
template = 'nova/access_and_security/index.html'
102
return shortcuts.render(request, template, context)