From 8938222029550c53f49c880d8ea2fc9f1b259d8a Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 2 Aug 2014 15:15:18 -0700 Subject: [PATCH] Pass through nova region name If the region name is specified in the config, we need to pass it in to the nova client constructor. Since key_name is similarly optional, go ahead and handle both parameters the same. --- library/cloud/nova_compute | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/cloud/nova_compute b/library/cloud/nova_compute index f7fd55123ed..e87ec8af12e 100644 --- a/library/cloud/nova_compute +++ b/library/cloud/nova_compute @@ -308,13 +308,14 @@ def _create_server(module, nova): bootkwargs = { 'nics' : module.params['nics'], 'meta' : module.params['meta'], - 'key_name': module.params['key_name'], 'security_groups': module.params['security_groups'].split(','), #userdata is unhyphenated in novaclient, but hyphenated here for consistency with the ec2 module: 'userdata': module.params['user_data'], } - if not module.params['key_name']: - del bootkwargs['key_name'] + + for optional_param in ('region_name', 'key_name'): + if module.params[optional_param]: + bootkwargs[optional_param] = module.params[optional_param] try: server = nova.servers.create(*bootargs, **bootkwargs) server = nova.servers.get(server.id)