From 25dcbc1932497250c448136aecc41d764c243468 Mon Sep 17 00:00:00 2001 From: Riccardo Murri Date: Sun, 27 Aug 2017 16:13:28 +0200 Subject: [PATCH] OpenStackLrms: do not require that key pair names are alphanumeric. Allow alphanumeric plus underscore, dash, and dot. It's still (likely) more restrictive than the actual OpenStack API (which documents no limits on the names), but should be OK for most people to live with. --- gc3libs/backends/openstack.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gc3libs/backends/openstack.py b/gc3libs/backends/openstack.py index 1b33b924..68a2615c 100755 --- a/gc3libs/backends/openstack.py +++ b/gc3libs/backends/openstack.py @@ -165,15 +165,13 @@ def __init__(self, name, self.os_password = auth.os_password self.os_tenant_name = auth.os_project_name self.os_region_name = os_region - if self.os_auth_url is None: - raise gc3libs.exceptions.InvalidArgument( - "Cannot connect to the OpenStack API:" - " No 'os_auth_url' argument passed to the OpenStack backend.") # Keypair names can only contain alphanumeric chars! - if not set(keypair_name).issubset(set(ascii_letters + digits + '_')): + if not set(keypair_name).issubset(set(ascii_letters + digits + '_-.')): raise ConfigurationError( - "Keypair name `%s` is invalid: keypair names can only contain " - "alphanumeric chars: [a-zA-Z0-9_]" % keypair_name) + "Keypair name `{0}` is invalid:" + " keypair names can only consist of" + " alphanumeric chars, plus `_`, `-`, and `.`" + .format(keypair_name)) self.keypair_name = keypair_name self.public_key = os.path.expanduser( os.path.expandvars(public_key.strip()))