~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« 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, Adam Gandelman, Chuck Short, Vishvananda Ishaya
  • Date: 2012-09-20 07:45:50 UTC
  • mfrom: (1.1.62)
  • Revision ID: package-import@ubuntu.com-20120920074550-fzmmmzqcntnw1vu7
Tags: 2012.2~rc1-0ubuntu1
[ Adam Gandelman ]
* Ensure /etc/nova/rootwrap.d/ is only writable by root, ensure
  those permissions on /etc/nova/rootwrap.conf as well as
  all individual filter configurations.

[ Chuck Short ]
* Fix lintian warnings
* debian/*.lograote: compress logfiles when they are rotated. (LP:
  #1049915)
* debian/control: 
  - Suggest ceph-common for nova-volume.
  - Add python-cinderclient as a build depends.

[Vishvananda Ishaya]
* Split up vncproxy and xvpvncproxy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from nova import exception
28
28
from nova import flags
29
29
from nova.openstack.common import log as logging
 
30
from nova import utils
30
31
from nova import volume
31
32
from nova.volume import volume_types
32
33
 
159
160
        return {'body': {'volume': volume}}
160
161
 
161
162
 
162
 
class VolumeController(object):
 
163
class VolumeController(wsgi.Controller):
163
164
    """The Volumes API controller for the OpenStack API."""
164
165
 
165
166
    def __init__(self):
220
221
        context = req.environ['nova.context']
221
222
        authorize(context)
222
223
 
223
 
        if not body:
 
224
        if not self.is_valid_body(body, 'volume'):
224
225
            raise exc.HTTPUnprocessableEntity()
225
226
 
226
227
        vol = body['volume']
227
 
        size = vol['size']
228
 
        LOG.audit(_("Create volume of %s GB"), size, context=context)
229
228
 
230
229
        vol_type = vol.get('volume_type', None)
231
230
        if vol_type:
244
243
        else:
245
244
            snapshot = None
246
245
 
 
246
        size = vol.get('size', None)
 
247
        if size is None and snapshot is not None:
 
248
            size = snapshot['volume_size']
 
249
 
 
250
        LOG.audit(_("Create volume of %s GB"), size, context=context)
 
251
 
247
252
        availability_zone = vol.get('availability_zone', None)
248
253
 
249
254
        new_volume = self.volume_api.create(context,
318
323
        return xmlutil.MasterTemplate(root, 1)
319
324
 
320
325
 
321
 
class VolumeAttachmentController(object):
 
326
class VolumeAttachmentController(wsgi.Controller):
322
327
    """The volume attachment API controller for the OpenStack API.
323
328
 
324
329
    A child resource of the server.  Note that we use the volume id
376
381
        context = req.environ['nova.context']
377
382
        authorize(context)
378
383
 
379
 
        if not body:
 
384
        if not self.is_valid_body(body, 'volumeAttachment'):
380
385
            raise exc.HTTPUnprocessableEntity()
381
386
 
382
387
        volume_id = body['volumeAttachment']['volumeId']
520
525
        return xmlutil.MasterTemplate(root, 1)
521
526
 
522
527
 
523
 
class SnapshotController(object):
 
528
class SnapshotController(wsgi.Controller):
524
529
    """The Volumes API controller for the OpenStack API."""
525
530
 
526
531
    def __init__(self):
580
585
        context = req.environ['nova.context']
581
586
        authorize(context)
582
587
 
583
 
        if not body:
584
 
            return exc.HTTPUnprocessableEntity()
 
588
        if not self.is_valid_body(body, 'snapshot'):
 
589
            raise exc.HTTPUnprocessableEntity()
585
590
 
586
591
        snapshot = body['snapshot']
587
592
        volume_id = snapshot['volume_id']
591
596
        LOG.audit(_("Create snapshot from volume %s"), volume_id,
592
597
                context=context)
593
598
 
594
 
        if force:
 
599
        if not utils.is_valid_boolstr(force):
 
600
            msg = _("Invalid value '%s' for force. ") % force
 
601
            raise exception.InvalidParameterValue(err=msg)
 
602
 
 
603
        if utils.bool_from_str(force):
595
604
            new_snapshot = self.volume_api.create_snapshot_force(context,
596
605
                                        volume,
597
606
                                        snapshot.get('display_name'),