diff options
| author | Sirisha Devineni <sirisha_devineni@persistent.co.in> | 2012-09-13 00:00:32 +0530 |
|---|---|---|
| committer | Sirisha Devineni <sirisha_devineni@persistent.co.in> | 2012-09-13 15:36:58 +0530 |
| commit | 760e59b8632edd8cbf395289e24f380ffd06f047 (patch) | |
| tree | fc994e610e5bdf116e5051d473e303a098c9f407 /nova/api | |
| parent | e72db9fe9345c48f4ea287643306d884c82f04f4 (diff) | |
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
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/keypairs.py | 9 |
1 files changed, 7 insertions, 2 deletions
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: |
