diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-13 10:22:02 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-13 10:22:02 +0000 |
| commit | 0bf93c05079c6c7c30e28ca1e0fba54b381c36d5 (patch) | |
| tree | 9b9b4191ddaf66c22d0b99a90c3568b39cf001ce /nova/api | |
| parent | 213b087bc9b90070156db50275f969eae4dd75cb (diff) | |
| parent | cce5cf45f738ed95a96a4526253bec01a15277f0 (diff) | |
Merge "Return 400 if create volume snapshot force parameter is invalid"
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 7 | ||||
| -rw-r--r-- | nova/api/openstack/volume/snapshots.py | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 41e168411..7194f64e3 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -27,6 +27,7 @@ from nova import compute from nova import exception from nova import flags from nova.openstack.common import log as logging +from nova import utils from nova import volume from nova.volume import volume_types @@ -595,7 +596,11 @@ class SnapshotController(object): LOG.audit(_("Create snapshot from volume %s"), volume_id, context=context) - if force: + if not utils.is_valid_boolstr(force): + msg = _("Invalid value '%s' for force. ") % force + raise exception.InvalidParameterValue(err=msg) + + if utils.bool_from_str(force): new_snapshot = self.volume_api.create_snapshot_force(context, volume, snapshot.get('display_name'), diff --git a/nova/api/openstack/volume/snapshots.py b/nova/api/openstack/volume/snapshots.py index 91823de79..755398369 100644 --- a/nova/api/openstack/volume/snapshots.py +++ b/nova/api/openstack/volume/snapshots.py @@ -24,6 +24,7 @@ from nova.api.openstack import xmlutil from nova import exception from nova import flags from nova.openstack.common import log as logging +from nova import utils from nova import volume @@ -154,7 +155,11 @@ class SnapshotsController(object): msg = _("Create snapshot from volume %s") LOG.audit(msg, volume_id, context=context) - if force: + if not utils.is_valid_boolstr(force): + msg = _("Invalid value '%s' for force. ") % force + raise exception.InvalidParameterValue(err=msg) + + if utils.bool_from_str(force): new_snapshot = self.volume_api.create_snapshot_force(context, volume, snapshot.get('display_name'), |
