From 760e59b8632edd8cbf395289e24f380ffd06f047 Mon Sep 17 00:00:00 2001 From: Sirisha Devineni Date: Thu, 13 Sep 2012 00:00:32 +0530 Subject: Validate keypair create request body Check if keypair create request body has manditory keys like keypair, name and raise HTTPBadRequest if the required keys are missing. Fixes bug 1049619 Change-Id: Ia6129e1b04e910fbea81b62b921a228aafa32f64 --- nova/api/openstack/compute/contrib/keypairs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/keypairs.py b/nova/api/openstack/compute/contrib/keypairs.py index dc0c74b11..e5e1e37fd 100644 --- a/nova/api/openstack/compute/contrib/keypairs.py +++ b/nova/api/openstack/compute/contrib/keypairs.py @@ -70,8 +70,13 @@ class KeypairController(object): context = req.environ['nova.context'] authorize(context) - params = body['keypair'] - name = params['name'] + + try: + params = body['keypair'] + name = params['name'] + except KeyError: + msg = _("Invalid request body") + raise webob.exc.HTTPBadRequest(explanation=msg) try: if 'public_key' in params: -- cgit