summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJustin Santa Barbara <justin@fathomdb.com>2011-02-19 20:49:49 +0000
committerTarmac <>2011-02-19 20:49:49 +0000
commitf0daba6d37ada6e49229065dc99af8496511ef0f (patch)
tree2be241a103ea58a77b726d3e384b0fcac31e805b /nova
parent39ee83d0d867350f8bd31727ad20b119966b8b2f (diff)
parentb4c67400324df02480b171b84ba73cfe8a6d044e (diff)
downloadnova-f0daba6d37ada6e49229065dc99af8496511ef0f.tar.gz
nova-f0daba6d37ada6e49229065dc99af8496511ef0f.tar.xz
nova-f0daba6d37ada6e49229065dc99af8496511ef0f.zip
If there are no keypairs registered on a create call, output a useful error message rather than an out-of-range exception
Diffstat (limited to 'nova')
-rw-r--r--nova/api/openstack/servers.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 486eca508..ce9601ecb 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -162,8 +162,12 @@ class Controller(wsgi.Controller):
if not env:
return faults.Fault(exc.HTTPUnprocessableEntity())
- key_pair = auth_manager.AuthManager.get_key_pairs(
- req.environ['nova.context'])[0]
+ key_pairs = auth_manager.AuthManager.get_key_pairs(
+ req.environ['nova.context'])
+ if not key_pairs:
+ raise exception.NotFound(_("No keypairs defined"))
+ key_pair = key_pairs[0]
+
image_id = common.get_image_id_from_image_hash(self._image_service,
req.environ['nova.context'], env['server']['imageId'])
kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(