~ubuntu-branches/ubuntu/quantal/horizon/quantal

« back to all changes in this revision

Viewing changes to horizon/dashboards/nova/instances_and_volumes/instances/forms.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-07-06 11:38:55 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120706113855-js8fsldgtool47yj
Tags: 2012.2~f2-0ubuntu1
New usptream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2012 United States Government as represented by the
4
 
# Administrator of the National Aeronautics and Space Administration.
5
 
# All Rights Reserved.
6
 
#
7
 
# Copyright 2012 Nebula, Inc.
8
 
#
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
12
 
#
13
 
#         http://www.apache.org/licenses/LICENSE-2.0
14
 
#
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
19
 
#    under the License.
20
 
 
21
 
import logging
22
 
 
23
 
from django import shortcuts
24
 
from django.contrib import messages
25
 
from django.utils.translation import ugettext_lazy as _
26
 
 
27
 
from horizon import api
28
 
from horizon import exceptions
29
 
from horizon import forms
30
 
 
31
 
 
32
 
LOG = logging.getLogger(__name__)
33
 
 
34
 
 
35
 
class UpdateInstance(forms.SelfHandlingForm):
36
 
    tenant_id = forms.CharField(widget=forms.HiddenInput)
37
 
    instance = forms.CharField(widget=forms.HiddenInput)
38
 
    name = forms.CharField(required=True)
39
 
 
40
 
    def handle(self, request, data):
41
 
        try:
42
 
            api.server_update(request, data['instance'], data['name'])
43
 
            messages.success(request,
44
 
                             _('Instance "%s" updated.') % data['name'])
45
 
        except:
46
 
            exceptions.handle(request, _('Unable to update instance.'))
47
 
 
48
 
        return shortcuts.redirect(
49
 
                        'horizon:nova:instances_and_volumes:index')