Add OpenStack Director provider (#35043)

Adds the ability to create an OpenStack Director provider in
ManageIQ.
pull/35265/head
Christopher Brown 7 years ago committed by ansibot
parent 669a86174f
commit b8e8fb48a8

@ -37,7 +37,7 @@ options:
type: type:
description: The provider's type. description: The provider's type.
required: true required: true
choices: ['Openshift', 'Amazon', 'oVirt', 'VMware', 'Azure'] choices: ['Openshift', 'Amazon', 'oVirt', 'VMware', 'Azure', 'Director']
zone: zone:
description: The ManageIQ zone name that will manage the provider. description: The ManageIQ zone name that will manage the provider.
required: false required: false
@ -66,6 +66,12 @@ options:
default: null default: null
description: Tenant ID. defaults to None. description: Tenant ID. defaults to None.
version_added: "2.5" version_added: "2.5"
api_version:
required: false
default: null
description: The OpenStack Keystone API version. defaults to None.
choices: ['v2', 'v3']
version_added: "2.5"
provider: provider:
required: false required: false
@ -97,7 +103,7 @@ options:
security_protocol: security_protocol:
required: false required: false
default: None default: None
choices: ['ssl-with-validation','ssl-with-validation-custom-ca','ssl-without-validation'] choices: ['ssl-with-validation','ssl-with-validation-custom-ca','ssl-without-validation','non-ssl']
description: How SSL certificates should be used for HTTPS requests. defaults to None. description: How SSL certificates should be used for HTTPS requests. defaults to None.
certificate_authority: certificate_authority:
required: false required: false
@ -134,7 +140,7 @@ options:
security_protocol: security_protocol:
required: false required: false
default: None default: None
choices: ['ssl-with-validation','ssl-with-validation-custom-ca','ssl-without-validation'] choices: ['ssl-with-validation','ssl-with-validation-custom-ca','ssl-without-validation','non-ssl']
description: How SSL certificates should be used for HTTPS requests. defaults to None. description: How SSL certificates should be used for HTTPS requests. defaults to None.
certificate_authority: certificate_authority:
required: false required: false
@ -181,6 +187,22 @@ options:
required: false required: false
default: null default: null
description: The CA bundle string with custom certificates. defaults to None. description: The CA bundle string with custom certificates. defaults to None.
ssh_keypair:
required: false
description: SSH key pair used for SSH connections to all hosts in this provider.
default: null
version_added: "2.5"
suboptions:
hostname:
description: Director hostname.
required: true
userid:
description: SSH username.
required: false
auth_key:
description: SSH private key.
required: false
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -429,6 +451,42 @@ EXAMPLES = '''
username: 'admin' username: 'admin'
password: 'password' password: 'password'
verify_ssl: false verify_ssl: false
- name: Create a new OpenStack Director provider in ManageIQ with rsa keypair
manageiq_provider:
name: 'EngDirector'
type: 'Director'
api_version: 'v3'
state: 'present'
provider:
hostname: 'director.example.com'
userid: 'admin'
password: 'password'
security_protocol: 'ssl-with-validation'
verify_ssl: 'true'
certificate_authority: |
-----BEGIN CERTIFICATE-----
FAKECERTsdKgAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBtvcGVu
c2hpZnQtc2lnbmVyQDE1MDMzMjAxMTkwHhcNMTcwODIxMTI1NTE5WhcNMjIwODIw
MTI1NTIwWjAmMSQwIgYDVQQDDBtvcGVuc2hpZnQtc2lnbmVyQDE1MDMzMjAxMTkw
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDUDnL2tQ2xf/zO7F7hmZ4S
ZuwKENdI4IYuWSxye4i3hPhKg6eKPzGzmDNWkIMDOrDAj1EgVSNPtPwsOL8OWvJm
AaTjr070D7ZGWWnrrDrWEClBx9Rx/6JAM38RT8Pu7c1hXBm0J81KufSLLYiZ/gOw
Znks5v5RUSGcAXvLkBJeATbsbh6fKX0RgQ3fFTvqQaE/r8LxcTN1uehPX1g5AaRa
z/SNDHaFtQlE3XcqAAukyMn4N5kdNcuwF3GlQ+tJnJv8SstPkfQcZbTMUQ7I2KpJ
ajXnMxmBhV5fCN4rb0QUNCrk2/B+EUMBY4MnxIakqNxnN1kvgI7FBbFgrHUe6QvJ
AgMBAAGjIzAhMA4GA1UdDwEB/wQEAwICpDAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
SIb3DQEBCwUAA4IBAQAYRV57LUsqznSLZHA77o9+0fQetIE115DYP7wea42PODJI
QJ+JETEfoCr0+YOMAbVmznP9GH5cMTKEWHExcIpbMBU7nMZp6A3htcJgF2fgPzOA
aTUtzkuVCSrV//mbbYVxoFOc6sR3Br0wBs5+5iz3dBSt7xmgpMzZvqsQl655i051
gGSTIY3z5EJmBZBjwuTjal9mMoPGA4eoTPqlITJDHQ2bdCV2oDbc7zqupGrUfZFA
qzgieEyGzdCSRwjr1/PibA3bpwHyhD9CGD0PRVVTLhw6h6L5kuN1jA20OfzWxf/o
XUsdmRaWiF+l4s6Dcd56SuRp5SGNa2+vP9Of/FX5
-----END CERTIFICATE-----
ssh_keypair:
hostname: director.example.com
userid: heat-admin
auth_key: 'SecretSSHPrivateKey'
''' '''
RETURN = ''' RETURN = '''
@ -461,6 +519,10 @@ def supported_providers():
Azure=dict( Azure=dict(
class_name='ManageIQ::Providers::Azure::CloudManager', class_name='ManageIQ::Providers::Azure::CloudManager',
), ),
Director=dict(
class_name='ManageIQ::Providers::Openstack::InfraManager',
ssh_keypair_role="ssh_keypair"
),
) )
@ -469,6 +531,7 @@ def endpoint_list_spec():
provider=dict(type='dict', options=endpoint_argument_spec()), provider=dict(type='dict', options=endpoint_argument_spec()),
metrics=dict(type='dict', options=endpoint_argument_spec()), metrics=dict(type='dict', options=endpoint_argument_spec()),
alerts=dict(type='dict', options=endpoint_argument_spec()), alerts=dict(type='dict', options=endpoint_argument_spec()),
ssh_keypair=dict(type='dict', options=endpoint_argument_spec()),
) )
@ -484,6 +547,7 @@ def endpoint_argument_spec():
'ssl-with-validation', 'ssl-with-validation',
'ssl-with-validation-custom-ca', 'ssl-with-validation-custom-ca',
'ssl-without-validation', 'ssl-without-validation',
'non-ssl',
], ],
), ),
userid=dict(), userid=dict(),
@ -617,7 +681,7 @@ class ManageIQProvider(object):
def edit_provider(self, provider, name, provider_type, endpoints, zone_id, provider_region, def edit_provider(self, provider, name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end, host_default_vnc_port_start, host_default_vnc_port_end,
subscription, uid_ems): subscription, uid_ems, api_version):
""" Edit a user from manageiq. """ Edit a user from manageiq.
Returns: Returns:
@ -634,6 +698,7 @@ class ManageIQProvider(object):
host_default_vnc_port_end=host_default_vnc_port_end, host_default_vnc_port_end=host_default_vnc_port_end,
subscription=subscription, subscription=subscription,
uid_ems=uid_ems, uid_ems=uid_ems,
api_version=api_version,
) )
# NOTE: we do not check for diff's between requested and current # NOTE: we do not check for diff's between requested and current
@ -657,7 +722,7 @@ class ManageIQProvider(object):
def create_provider(self, name, provider_type, endpoints, zone_id, provider_region, def create_provider(self, name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end, host_default_vnc_port_start, host_default_vnc_port_end,
subscription, uid_ems): subscription, uid_ems, api_version):
""" Creates the user in manageiq. """ Creates the user in manageiq.
Returns: Returns:
@ -680,6 +745,7 @@ class ManageIQProvider(object):
host_default_vnc_port_end=host_default_vnc_port_end, host_default_vnc_port_end=host_default_vnc_port_end,
subscription=subscription, subscription=subscription,
uid_ems=uid_ems, uid_ems=uid_ems,
api_version=api_version,
connection_configurations=endpoints, connection_configurations=endpoints,
) )
except Exception as e: except Exception as e:
@ -702,6 +768,7 @@ def main():
host_default_vnc_port_end=dict(), host_default_vnc_port_end=dict(),
subscription=dict(), subscription=dict(),
azure_tenant_id=dict(), azure_tenant_id=dict(),
api_version=dict(),
type=dict(choices=supported_providers().keys()), type=dict(choices=supported_providers().keys()),
) )
# add the manageiq connection arguments to the arguments # add the manageiq connection arguments to the arguments
@ -727,6 +794,7 @@ def main():
host_default_vnc_port_end = module.params['host_default_vnc_port_end'] host_default_vnc_port_end = module.params['host_default_vnc_port_end']
subscription = module.params['subscription'] subscription = module.params['subscription']
uid_ems = module.params['azure_tenant_id'] uid_ems = module.params['azure_tenant_id']
api_version = module.params['api_version']
state = module.params['state'] state = module.params['state']
manageiq = ManageIQ(module) manageiq = ManageIQ(module)
@ -774,12 +842,12 @@ def main():
if provider: if provider:
res_args = manageiq_provider.edit_provider(provider, name, provider_type, endpoints, zone_id, provider_region, res_args = manageiq_provider.edit_provider(provider, name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end, host_default_vnc_port_start, host_default_vnc_port_end,
subscription, uid_ems) subscription, uid_ems, api_version)
# if we do not have a provider, create it # if we do not have a provider, create it
else: else:
res_args = manageiq_provider.create_provider(name, provider_type, endpoints, zone_id, provider_region, res_args = manageiq_provider.create_provider(name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end, host_default_vnc_port_start, host_default_vnc_port_end,
subscription, uid_ems) subscription, uid_ems, api_version)
module.exit_json(**res_args) module.exit_json(**res_args)

Loading…
Cancel
Save