~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/api/openstack/volume/contrib/types_manage.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright (c) 2011 Zadara Storage Inc.
4
 
# Copyright (c) 2011 OpenStack LLC.
5
 
#
6
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
 
#    not use this file except in compliance with the License. You may obtain
8
 
#    a copy of the License at
9
 
#
10
 
#         http://www.apache.org/licenses/LICENSE-2.0
11
 
#
12
 
#    Unless required by applicable law or agreed to in writing, software
13
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 
#    License for the specific language governing permissions and limitations
16
 
#    under the License.
17
 
 
18
 
"""The volume types manage extension."""
19
 
 
20
 
import webob
21
 
 
22
 
from nova.api.openstack import extensions
23
 
from nova.api.openstack.volume import types
24
 
from nova.api.openstack.volume.views import types as views_types
25
 
from nova.api.openstack import wsgi
26
 
from nova import exception
27
 
from nova.volume import volume_types
28
 
 
29
 
 
30
 
authorize = extensions.extension_authorizer('volume', 'types_manage')
31
 
 
32
 
 
33
 
class VolumeTypesManageController(wsgi.Controller):
34
 
    """ The volume types API controller for the OpenStack API """
35
 
 
36
 
    _view_builder_class = views_types.ViewBuilder
37
 
 
38
 
    @wsgi.action("create")
39
 
    @wsgi.serializers(xml=types.VolumeTypeTemplate)
40
 
    def _create(self, req, body):
41
 
        """Creates a new volume type."""
42
 
        context = req.environ['nova.context']
43
 
        authorize(context)
44
 
 
45
 
        if not self.is_valid_body(body, 'volume_type'):
46
 
            raise webob.exc.HTTPUnprocessableEntity()
47
 
 
48
 
        vol_type = body['volume_type']
49
 
        name = vol_type.get('name', None)
50
 
        specs = vol_type.get('extra_specs', {})
51
 
 
52
 
        if name is None or name == "":
53
 
            raise webob.exc.HTTPUnprocessableEntity()
54
 
 
55
 
        try:
56
 
            volume_types.create(context, name, specs)
57
 
            vol_type = volume_types.get_volume_type_by_name(context, name)
58
 
        except exception.VolumeTypeExists as err:
59
 
            raise webob.exc.HTTPConflict(explanation=str(err))
60
 
        except exception.NotFound:
61
 
            raise webob.exc.HTTPNotFound()
62
 
 
63
 
        return self._view_builder.show(req, vol_type)
64
 
 
65
 
    @wsgi.action("delete")
66
 
    def _delete(self, req, id):
67
 
        """ Deletes an existing volume type """
68
 
        context = req.environ['nova.context']
69
 
        authorize(context)
70
 
 
71
 
        try:
72
 
            vol_type = volume_types.get_volume_type(context, id)
73
 
            volume_types.destroy(context, vol_type['name'])
74
 
        except exception.NotFound:
75
 
            raise webob.exc.HTTPNotFound()
76
 
 
77
 
        return webob.Response(status_int=202)
78
 
 
79
 
 
80
 
class Types_manage(extensions.ExtensionDescriptor):
81
 
    """Types manage support"""
82
 
 
83
 
    name = "TypesManage"
84
 
    alias = "os-types-manage"
85
 
    namespace = "http://docs.openstack.org/volume/ext/types-manage/api/v1"
86
 
    updated = "2011-08-24T00:00:00+00:00"
87
 
 
88
 
    def get_controller_extensions(self):
89
 
        controller = VolumeTypesManageController()
90
 
        extension = extensions.ControllerExtension(self, 'types', controller)
91
 
        return [extension]