~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/api/openstack/compute/contrib/volumes.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-02-22 09:27:29 UTC
  • mfrom: (1.1.68)
  • Revision ID: package-import@ubuntu.com-20130222092729-nn3gt8rf97uvts77
Tags: 2013.1.g3-0ubuntu1
[ Chuck Short ]
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.

[ Adam Gandelman ]
* debian/control: Fix typo (websocikfy -> websockify).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import webob
19
19
from webob import exc
20
 
from xml.dom import minidom
21
20
 
22
21
from nova.api.openstack import common
23
22
from nova.api.openstack import extensions
33
32
LOG = logging.getLogger(__name__)
34
33
authorize = extensions.extension_authorizer('compute', 'volumes')
35
34
 
 
35
authorize_attach = extensions.extension_authorizer('compute',
 
36
                                                   'volume_attachments')
 
37
 
36
38
 
37
39
def _translate_volume_detail_view(context, vol):
38
40
    """Maps keys for volumes details view."""
152
154
 
153
155
    def default(self, string):
154
156
        """Deserialize an xml-formatted volume create request."""
155
 
        dom = minidom.parseString(string)
 
157
        dom = utils.safe_minidom_parse_string(string)
156
158
        vol = self._extract_volume(dom)
157
159
        return {'body': {'volume': vol}}
158
160
 
329
331
    @wsgi.serializers(xml=VolumeAttachmentsTemplate)
330
332
    def index(self, req, server_id):
331
333
        """Returns the list of volume attachments for a given instance."""
 
334
        context = req.environ['nova.context']
 
335
        authorize_attach(context, action='index')
332
336
        return self._items(req, server_id,
333
337
                           entity_maker=_translate_attachment_summary_view)
334
338
 
337
341
        """Return data about the given volume attachment."""
338
342
        context = req.environ['nova.context']
339
343
        authorize(context)
 
344
        authorize_attach(context, action='show')
340
345
 
341
346
        volume_id = id
342
347
        try:
377
382
        """Attach a volume to an instance."""
378
383
        context = req.environ['nova.context']
379
384
        authorize(context)
 
385
        authorize_attach(context, action='create')
380
386
 
381
387
        if not self.is_valid_body(body, 'volumeAttachment'):
382
388
            raise exc.HTTPUnprocessableEntity()
423
429
        """Detach a volume from an instance."""
424
430
        context = req.environ['nova.context']
425
431
        authorize(context)
 
432
        authorize_attach(context, action='delete')
426
433
 
427
434
        volume_id = id
428
435
        LOG.audit(_("Detach volume %s"), volume_id, context=context)
616
623
 
617
624
 
618
625
class Volumes(extensions.ExtensionDescriptor):
619
 
    """Volumes support"""
 
626
    """Volumes support."""
620
627
 
621
628
    name = "Volumes"
622
629
    alias = "os-volumes"