Просмотр исходного кода

Set the DomainName or DomainID in the OpenStack cloud provider

Whereas with the OpenStack keystone v2 authentication API, the username and
the password are enough, the keystone v3 API requires an additional domain
parameter.

Fixes #2515
Lénaïc Huard 8 лет назад
Родитель
Сommit
4d90cd08d8

+ 10 - 3
bin/cluster

@@ -73,9 +73,16 @@ class Cluster(object):
             cluster['openshift_cloudprovider_openstack_auth_url']    = os.getenv('OS_AUTH_URL')
             cluster['openshift_cloudprovider_openstack_username']    = os.getenv('OS_USERNAME')
             cluster['openshift_cloudprovider_openstack_password']    = os.getenv('OS_PASSWORD')
-            cluster['openshift_cloudprovider_openstack_tenant_id']   = os.getenv('OS_PROJECT_ID',os.getenv('OS_TENANT_ID'))
-            cluster['openshift_cloudprovider_openstack_tenant_name'] = os.getenv('OS_PROJECT_NAME',os.getenv('OS_TENANT_NAME'))
-            cluster['openshift_cloudprovider_openstack_region']      = os.getenv('OS_REGION_NAME')
+            if 'OS_USER_DOMAIN_ID' in os.environ:
+                cluster['openshift_cloudprovider_openstack_domain_id']   = os.getenv('OS_USER_DOMAIN_ID')
+            if 'OS_USER_DOMAIN_NAME' in os.environ:
+                cluster['openshift_cloudprovider_openstack_domain_name'] = os.getenv('OS_USER_DOMAIN_NAME')
+            if 'OS_PROJECT_ID' in os.environ or 'OS_TENANT_ID' in os.environ:
+                cluster['openshift_cloudprovider_openstack_tenant_id']   = os.getenv('OS_PROJECT_ID',os.getenv('OS_TENANT_ID'))
+            if 'OS_PROJECT_NAME' is os.environ or 'OS_TENANT_NAME' in os.environ:
+                cluster['openshift_cloudprovider_openstack_tenant_name'] = os.getenv('OS_PROJECT_NAME',os.getenv('OS_TENANT_NAME'))
+            if 'OS_REGION_NAME' in os.environ:
+                cluster['openshift_cloudprovider_openstack_region']      = os.getenv('OS_REGION_NAME')
 
         self.action(args, inventory, cluster, playbook)
 

+ 2 - 0
inventory/byo/hosts.origin.example

@@ -145,6 +145,8 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
 #openshift_cloudprovider_openstack_auth_url=http://openstack.example.com:35357/v2.0/
 #openshift_cloudprovider_openstack_username=username
 #openshift_cloudprovider_openstack_password=password
+#openshift_cloudprovider_openstack_domain_id=domain_id
+#openshift_cloudprovider_openstack_domain_name=domain_name
 #openshift_cloudprovider_openstack_tenant_id=tenant_id
 #openshift_cloudprovider_openstack_tenant_name=tenant_name
 #openshift_cloudprovider_openstack_region=region

+ 2 - 0
inventory/byo/hosts.ose.example

@@ -144,6 +144,8 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
 #openshift_cloudprovider_openstack_auth_url=http://openstack.example.com:35357/v2.0/
 #openshift_cloudprovider_openstack_username=username
 #openshift_cloudprovider_openstack_password=password
+#openshift_cloudprovider_openstack_domain_id=domain_id
+#openshift_cloudprovider_openstack_domain_name=domain_name
 #openshift_cloudprovider_openstack_tenant_id=tenant_id
 #openshift_cloudprovider_openstack_tenant_name=tenant_name
 #openshift_cloudprovider_openstack_region=region

+ 5 - 0
roles/openshift_cloud_provider/templates/openstack.conf.j2

@@ -2,6 +2,11 @@
 auth-url = {{ openshift_cloudprovider_openstack_auth_url }}
 username = {{ openshift_cloudprovider_openstack_username }}
 password = {{ openshift_cloudprovider_openstack_password }}
+{% if openshift_cloudprovider_openstack_domain_id is defined %}
+domain-id = {{ openshift_cloudprovider_openstack_domain_id }}
+{% elif openshift_cloudprovider_openstack_domain_name is defined %}
+domain-name = {{ openshift_cloudprovider_openstack_domain_name }}
+{% endif %}
 {% if openshift_cloudprovider_openstack_tenant_id is defined %}
 tenant-id = {{ openshift_cloudprovider_openstack_tenant_id }}
 {% else %}