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.
9
# Licensed under the Apache License, Version 2.0 (the "License"); you may
10
# not use this file except in compliance with the License. You may obtain
11
# a copy of the License at
13
# http://www.apache.org/licenses/LICENSE-2.0
15
# Unless required by applicable law or agreed to in writing, software
16
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
# License for the specific language governing permissions and limitations
22
Views for managing Nova instances.
26
from django.contrib import messages
27
from django.contrib.auth.decorators import login_required
28
from django import shortcuts
29
from django.utils.translation import ugettext as _
30
from novaclient import exceptions as novaclient_exceptions
32
from horizon import api
33
from horizon.dashboards.nova.security_groups.forms import (CreateGroup,
34
DeleteGroup, AddRule, DeleteRule)
37
LOG = logging.getLogger(__name__)
42
tenant_id = request.user.tenant_id
43
delete_form, handled = DeleteGroup.maybe_handle(request,
44
initial={'tenant_id': tenant_id})
50
security_groups = api.security_group_list(request)
51
except novaclient_exceptions.ClientException, e:
53
LOG.exception("ClientException in security_groups index")
54
messages.error(request, _('Error fetching security_groups: %s')
57
return shortcuts.render(request,
58
'nova/security_groups/index.html', {
59
'security_groups': security_groups,
60
'delete_form': delete_form})
64
def edit_rules(request, security_group_id):
65
tenant_id = request.user.tenant_id
66
add_form, handled = AddRule.maybe_handle(request,
67
initial={'tenant_id': tenant_id,
68
'security_group_id': security_group_id})
72
delete_form, handled = DeleteRule.maybe_handle(request,
73
initial={'tenant_id': tenant_id,
74
'security_group_id': security_group_id})
79
security_group = api.security_group_get(request, security_group_id)
80
except novaclient_exceptions.ClientException, e:
81
LOG.exception("ClientException in security_groups rules edit")
82
messages.error(request, _('Error getting security_group: %s')
84
return shortcuts.redirect('horizon:nova:security_groups:index')
86
return shortcuts.render(request,
87
'nova/security_groups/edit_rules.html', {
88
'security_group': security_group,
89
'delete_form': delete_form,
95
tenant_id = request.user.tenant_id
96
form, handled = CreateGroup.maybe_handle(request,
97
initial={'tenant_id': tenant_id})
101
return shortcuts.render(request,
102
'nova/security_groups/create.html', {