From 2dce00299e6cfa0d09f61375cc5e38103a2d43ba Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 18 Aug 2015 17:59:19 -0700 Subject: [PATCH] Add support for project-name parameter Some clouds give you an ID. Some give a name. We need to pass names to names and IDs to IDs. Change-Id: If493c0103281a50b863a2b1babb3521307480e61 --- devstack/plugin.sh | 2 +- doc/source/configuration.rst | 5 +++-- nodepool/cmd/config_validator.py | 1 + nodepool/nodepool.py | 3 ++- nodepool/tests/fixtures/config_validate/good.yaml | 10 +++++----- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index b7d5afc02..9b0664ef0 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -105,7 +105,7 @@ providers: region-name: '$REGION_NAME' service-type: 'compute' username: 'demo' - project-id: 'demo' + project-name: 'demo' password: '$ADMIN_PASSWORD' auth-url: '$KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION' api-timeout: 60 diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 6b7e34abe..920b4c201 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -276,7 +276,7 @@ provider, the Nodepool image types are also defined (see username: 'username' password: 'password' auth-url: 'http://auth.provider2.example.com/' - project-id: 'project' + project-name: 'project' service-type: 'compute' service-name: 'compute' region-name: 'region1' @@ -303,8 +303,9 @@ provider, the Nodepool image types are also defined (see ``password`` - ``project-id`` + ``project-id`` OR ``project-name`` Some clouds may refer to the ``project-id`` as ``tenant-id``. + Some clouds may refer to the ``project-name`` as ``tenant-name``. ``auth-url`` Keystone URL. diff --git a/nodepool/cmd/config_validator.py b/nodepool/cmd/config_validator.py index d88a69737..1a08cf14f 100644 --- a/nodepool/cmd/config_validator.py +++ b/nodepool/cmd/config_validator.py @@ -55,6 +55,7 @@ class ConfigValidator: 'password': str, 'auth-url': str, 'project-id': str, + 'project-name': str, 'max-servers': int, 'pool': str, 'image-type': str, diff --git a/nodepool/nodepool.py b/nodepool/nodepool.py index 52458e03d..3f0808a93 100644 --- a/nodepool/nodepool.py +++ b/nodepool/nodepool.py @@ -75,7 +75,8 @@ def _cloudKwargsFromProvider(provider): cloud_kwargs['compute-service-name'] = provider['service-name'] auth_kwargs = {} - for auth_key in ('username', 'password', 'auth-url', 'project-id'): + for auth_key in ( + 'username', 'password', 'auth-url', 'project-id', 'project-name'): if auth_key in provider: auth_kwargs[auth_key] = provider[auth_key] diff --git a/nodepool/tests/fixtures/config_validate/good.yaml b/nodepool/tests/fixtures/config_validate/good.yaml index 19b9cf9e6..4943f7897 100644 --- a/nodepool/tests/fixtures/config_validate/good.yaml +++ b/nodepool/tests/fixtures/config_validate/good.yaml @@ -428,7 +428,7 @@ providers: service-name: 'Compute' username: '<%= hpcloud_username %>' password: '<%= hpcloud_password %>' - project-id: '<%= hpcloud_project %>' + project-name: '<%= hpcloud_project %>' auth-url: 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0' boot-timeout: 120 max-servers: 0 @@ -531,7 +531,7 @@ providers: service-name: 'Compute' username: '<%= hpcloud_username %>' password: '<%= hpcloud_password %>' - project-id: '<%= hpcloud_project %>' + project-name: '<%= hpcloud_project %>' auth-url: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0' api-timeout: 60 boot-timeout: 120 @@ -620,7 +620,7 @@ providers: service-name: 'Compute' username: '<%= hpcloud_username %>' password: '<%= hpcloud_password %>' - project-id: '<%= hpcloud_project %>' + project-name: '<%= hpcloud_project %>' auth-url: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0' api-timeout: 60 boot-timeout: 120 @@ -709,7 +709,7 @@ providers: service-name: 'Compute' username: '<%= hpcloud_username %>' password: '<%= hpcloud_password %>' - project-id: '<%= hpcloud_project %>' + project-name: '<%= hpcloud_project %>' auth-url: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0' api-timeout: 60 boot-timeout: 120 @@ -799,7 +799,7 @@ providers: service-name: 'Compute' username: '<%= hpcloud_username %>' password: '<%= hpcloud_password %>' - project-id: '<%= hpcloud_project %>' + project-name: '<%= hpcloud_project %>' auth-url: 'https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0' api-timeout: 60 boot-timeout: 120