Skip to content

Commit

Permalink
OpenStackLrms: do not require that key pair names are alphanumeric.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
riccardomurri committed Aug 27, 2017
1 parent 3b23774 commit 25dcbc1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions gc3libs/backends/openstack.py
Expand Up @@ -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()))
Expand Down

0 comments on commit 25dcbc1

Please sign in to comment.