mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Merge pull request #6833 from lewisface/devel
Keystone v3 support for OpenStack Credential
Reviewed-by: Ryan Petrello
https://github.com/ryanpetrello
This commit is contained in:
@@ -799,6 +799,10 @@ ManagedCredentialType(
|
|||||||
'id': 'project',
|
'id': 'project',
|
||||||
'label': ugettext_noop('Project (Tenant Name)'),
|
'label': ugettext_noop('Project (Tenant Name)'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
|
}, {
|
||||||
|
'id': 'project_domain_name',
|
||||||
|
'label': ugettext_noop('Project (Domain Name)'),
|
||||||
|
'type': 'string',
|
||||||
}, {
|
}, {
|
||||||
'id': 'domain',
|
'id': 'domain',
|
||||||
'label': ugettext_noop('Domain Name'),
|
'label': ugettext_noop('Domain Name'),
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ def _openstack_data(cred):
|
|||||||
username=cred.get_input('username', default=''),
|
username=cred.get_input('username', default=''),
|
||||||
password=cred.get_input('password', default=''),
|
password=cred.get_input('password', default=''),
|
||||||
project_name=cred.get_input('project', default=''))
|
project_name=cred.get_input('project', default=''))
|
||||||
|
if cred.has_input('project_domain_name'):
|
||||||
|
openstack_auth['project_domain_name'] = cred.get_input('project_domain_name', default='')
|
||||||
if cred.has_input('domain'):
|
if cred.has_input('domain'):
|
||||||
openstack_auth['domain_name'] = cred.get_input('domain', default='')
|
openstack_auth['domain_name'] = cred.get_input('domain', default='')
|
||||||
verify_state = cred.get_input('verify_ssl', default=True)
|
verify_state = cred.get_input('verify_ssl', default=True)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ clouds:
|
|||||||
auth_url: https://foo.invalid
|
auth_url: https://foo.invalid
|
||||||
domain_name: fooo
|
domain_name: fooo
|
||||||
password: fooo
|
password: fooo
|
||||||
|
project_domain_name: fooo
|
||||||
project_name: fooo
|
project_name: fooo
|
||||||
username: fooo
|
username: fooo
|
||||||
private: false
|
private: false
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ clouds:
|
|||||||
auth_url: https://foo.invalid
|
auth_url: https://foo.invalid
|
||||||
domain_name: fooo
|
domain_name: fooo
|
||||||
password: fooo
|
password: fooo
|
||||||
|
project_domain_name: fooo
|
||||||
project_name: fooo
|
project_name: fooo
|
||||||
username: fooo
|
username: fooo
|
||||||
private: false
|
private: false
|
||||||
|
|||||||
@@ -183,6 +183,51 @@ def test_openstack_client_config_generation(mocker, source, expected, private_da
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("source,expected", [
|
||||||
|
(None, True), (False, False), (True, True)
|
||||||
|
])
|
||||||
|
def test_openstack_client_config_generation_with_project_domain_name(mocker, source, expected, private_data_dir):
|
||||||
|
update = tasks.RunInventoryUpdate()
|
||||||
|
credential_type = CredentialType.defaults['openstack']()
|
||||||
|
inputs = {
|
||||||
|
'host': 'https://keystone.openstack.example.org',
|
||||||
|
'username': 'demo',
|
||||||
|
'password': 'secrete',
|
||||||
|
'project': 'demo-project',
|
||||||
|
'domain': 'my-demo-domain',
|
||||||
|
'project_domain_name': 'project-domain',
|
||||||
|
}
|
||||||
|
if source is not None:
|
||||||
|
inputs['verify_ssl'] = source
|
||||||
|
credential = Credential(pk=1, credential_type=credential_type, inputs=inputs)
|
||||||
|
|
||||||
|
inventory_update = mocker.Mock(**{
|
||||||
|
'source': 'openstack',
|
||||||
|
'source_vars_dict': {},
|
||||||
|
'get_cloud_credential': mocker.Mock(return_value=credential),
|
||||||
|
'get_extra_credentials': lambda x: [],
|
||||||
|
'ansible_virtualenv_path': '/venv/foo'
|
||||||
|
})
|
||||||
|
cloud_config = update.build_private_data(inventory_update, private_data_dir)
|
||||||
|
cloud_credential = yaml.safe_load(
|
||||||
|
cloud_config.get('credentials')[credential]
|
||||||
|
)
|
||||||
|
assert cloud_credential['clouds'] == {
|
||||||
|
'devstack': {
|
||||||
|
'auth': {
|
||||||
|
'auth_url': 'https://keystone.openstack.example.org',
|
||||||
|
'password': 'secrete',
|
||||||
|
'project_name': 'demo-project',
|
||||||
|
'username': 'demo',
|
||||||
|
'domain_name': 'my-demo-domain',
|
||||||
|
'project_domain_name': 'project-domain',
|
||||||
|
},
|
||||||
|
'verify': expected,
|
||||||
|
'private': True,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("source,expected", [
|
@pytest.mark.parametrize("source,expected", [
|
||||||
(False, False), (True, True)
|
(False, False), (True, True)
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user