Skip to content

Instantly share code, notes, and snippets.

@j-griffith
Created April 15, 2014 23:35
Show Gist options
  • Save j-griffith/10789104 to your computer and use it in GitHub Desktop.
Save j-griffith/10789104 to your computer and use it in GitHub Desktop.
diff --git a/cinder/api/contrib/admin_actions.py b/cinder/api/contrib/admin_actions.py
index 4dbf736..65a55a6 100644
--- a/cinder/api/contrib/admin_actions.py
+++ b/cinder/api/contrib/admin_actions.py
@@ -43,6 +43,22 @@ class AdminController(wsgi.Controller):
'error_deleting',
])
+ #TODO(jdg): Valid status items
+ valid_attach_status = set([
+ 'attaching',
+ 'attached',
+ 'detached',
+ ])
+
+ #TODO(jdg): Valid status items
+ valid_migration_status = set([
+ 'creating',
+ 'available',
+ 'deleting',
+ 'error',
+ 'error_deleting',
+ ])
+
def __init__(self, *args, **kwargs):
super(AdminController, self).__init__(*args, **kwargs)
# singular name of the resource
@@ -60,12 +76,27 @@ class AdminController(wsgi.Controller):
def validate_update(self, body):
update = {}
- try:
- update['status'] = body['status']
- except (TypeError, KeyError):
- raise exc.HTTPBadRequest("Must specify 'status'")
- if update['status'] not in self.valid_status:
- raise exc.HTTPBadRequest("Must specify a valid status")
+ import pdb;pdb.set_trace()
+
+ status = body.get('status', None)
+ attach_status = body.get('attach_status', None)
+ migration_status = body.get('migration_status', None)
+ if status:
+ update['status'] = status
+ if update['status'] not in self.valid_status:
+ raise exc.HTTPBadRequest("Must specify a valid status")
+ elif attach_status:
+ update['attach_status'] = attach_status
+ if update['attach_status'] not in self.valid_attach_status:
+ raise exc.HTTPBadRequest("Must specify a valid attach status")
+ elif migration_status:
+ update['migration_status'] = migration_status
+ if update['migration_status'] not in self.valid_migration_status:
+ raise exc.HTTPBadRequest("Must specify a valid migration "
+ "status")
+ else:
+ raise exc.HTTPBadRequest("Must specify 'status', 'attach_status' "
+ "or 'migration_status'")
return update
def authorize(self, context, action_name):
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment