Flatten manageiq provider UI (#28967)
* flatten the endpoints arguments into first level * flatten the endpoints arguments into first level, update the docs
This commit is contained in:
parent
d8649adf10
commit
534c1b8342
1 changed files with 77 additions and 79 deletions
|
@ -47,114 +47,113 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
|
|
||||||
endpoints:
|
provider:
|
||||||
description: The provider's endpoints in manageiq.
|
|
||||||
required: false
|
required: false
|
||||||
|
description: Default endpoint connection information, required if state is true.
|
||||||
default: null
|
default: null
|
||||||
suboptions:
|
suboptions:
|
||||||
default:
|
hostname:
|
||||||
required: true
|
|
||||||
description: Default endpoint connection information.
|
|
||||||
default['hostname']:
|
|
||||||
description: The provider's api hostname.
|
description: The provider's api hostname.
|
||||||
required: true
|
required: true
|
||||||
default['port']:
|
port:
|
||||||
description: The provider's api port.
|
description: The provider's api port.
|
||||||
required: false
|
required: false
|
||||||
default['userid']:
|
userid:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication userid. defaults to None.
|
description: Provider's api endpoint authentication userid. defaults to None.
|
||||||
default['password']:
|
password:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication password. defaults to None.
|
description: Provider's api endpoint authentication password. defaults to None.
|
||||||
default['auth_key']:
|
auth_key:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication bearer token. defaults to None.
|
description: Provider's api endpoint authentication bearer token. defaults to None.
|
||||||
default['verify_ssl']:
|
verify_ssl:
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
||||||
default['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']
|
||||||
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.
|
||||||
default['certificate_authority']:
|
certificate_authority:
|
||||||
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.
|
||||||
|
|
||||||
metrics:
|
metrics:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
|
||||||
description: Metrics endpoint connection information.
|
description: Metrics endpoint connection information.
|
||||||
metrics['hostname']:
|
default: null
|
||||||
|
suboptions:
|
||||||
|
hostname:
|
||||||
description: The provider's api hostname.
|
description: The provider's api hostname.
|
||||||
required: true
|
required: true
|
||||||
metrics['port']:
|
port:
|
||||||
description: The provider's api port.
|
description: The provider's api port.
|
||||||
required: false
|
required: false
|
||||||
metrics['userid']:
|
userid:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication userid. defaults to None.
|
description: Provider's api endpoint authentication userid. defaults to None.
|
||||||
metrics['password']:
|
password:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication password. defaults to None.
|
description: Provider's api endpoint authentication password. defaults to None.
|
||||||
metrics['auth_key']:
|
auth_key:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication bearer token. defaults to None.
|
description: Provider's api endpoint authentication bearer token. defaults to None.
|
||||||
metrics['verify_ssl']:
|
verify_ssl:
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
||||||
metrics['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']
|
||||||
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.
|
||||||
metrics['certificate_authority']:
|
certificate_authority:
|
||||||
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.
|
||||||
|
|
||||||
alerts:
|
alerts:
|
||||||
required: False
|
required: false
|
||||||
default: null
|
|
||||||
description: Alerts endpoint connection information.
|
description: Alerts endpoint connection information.
|
||||||
alerts['hostname']:
|
default: null
|
||||||
|
suboptions:
|
||||||
|
hostname:
|
||||||
description: The provider's api hostname.
|
description: The provider's api hostname.
|
||||||
required: true
|
required: true
|
||||||
alerts['port']:
|
port:
|
||||||
description: The provider's api port.
|
description: The provider's api port.
|
||||||
required: false
|
required: false
|
||||||
alerts['userid']:
|
userid:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication userid. defaults to None.
|
description: Provider's api endpoint authentication userid. defaults to None.
|
||||||
alerts['password']:
|
password:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication password. defaults to None.
|
description: Provider's api endpoint authentication password. defaults to None.
|
||||||
alerts['auth_key']:
|
auth_key:
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
description: Provider's api endpoint authentication bearer token. defaults to None.
|
description: Provider's api endpoint authentication bearer token. defaults to None.
|
||||||
alerts['verify_ssl']:
|
verify_ssl:
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
description: Whether SSL certificates should be verified for HTTPS requests (deprecated). defaults to True.
|
||||||
alerts['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']
|
||||||
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.
|
||||||
alerts['certificate_authority']:
|
certificate_authority:
|
||||||
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.
|
||||||
|
@ -165,8 +164,7 @@ EXAMPLES = '''
|
||||||
manageiq_provider:
|
manageiq_provider:
|
||||||
name: 'EngLab'
|
name: 'EngLab'
|
||||||
type: 'OpenShift'
|
type: 'OpenShift'
|
||||||
endpoints:
|
provider:
|
||||||
default:
|
|
||||||
auth_key: 'topSecret'
|
auth_key: 'topSecret'
|
||||||
hostname: 'example.com'
|
hostname: 'example.com'
|
||||||
port: 8443
|
port: 8443
|
||||||
|
@ -186,8 +184,7 @@ EXAMPLES = '''
|
||||||
manageiq_provider:
|
manageiq_provider:
|
||||||
name: 'EngLab'
|
name: 'EngLab'
|
||||||
type: 'Openshift'
|
type: 'Openshift'
|
||||||
endpoints:
|
provider:
|
||||||
default:
|
|
||||||
auth_key: 'verySecret'
|
auth_key: 'verySecret'
|
||||||
hostname: 'next.example.com'
|
hostname: 'next.example.com'
|
||||||
port: 8443
|
port: 8443
|
||||||
|
@ -217,8 +214,7 @@ EXAMPLES = '''
|
||||||
name: 'EngAmazon'
|
name: 'EngAmazon'
|
||||||
type: 'Amazon'
|
type: 'Amazon'
|
||||||
provider_region: 'us-east-1'
|
provider_region: 'us-east-1'
|
||||||
endpoints:
|
provider:
|
||||||
default:
|
|
||||||
hostname: 'amazon.example.com'
|
hostname: 'amazon.example.com'
|
||||||
userid: 'hello'
|
userid: 'hello'
|
||||||
password: 'world'
|
password: 'world'
|
||||||
|
@ -252,8 +248,7 @@ def supported_providers():
|
||||||
|
|
||||||
def endpoint_list_spec():
|
def endpoint_list_spec():
|
||||||
return dict(
|
return dict(
|
||||||
default=dict(required=True,
|
provider=dict(type='dict', options=endpoint_argument_spec()),
|
||||||
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()),
|
||||||
)
|
)
|
||||||
|
@ -350,7 +345,7 @@ class ManageIQProvider(object):
|
||||||
provider_defaults = supported_providers().get(provider_type, {})
|
provider_defaults = supported_providers().get(provider_type, {})
|
||||||
|
|
||||||
# get endpoint defaults
|
# get endpoint defaults
|
||||||
endpoint = endpoints.get('default')
|
endpoint = endpoints.get('provider')
|
||||||
default_auth_key = endpoint.get('auth_key')
|
default_auth_key = endpoint.get('auth_key')
|
||||||
|
|
||||||
# build a connection_configuration object for each endpoint
|
# build a connection_configuration object for each endpoint
|
||||||
|
@ -464,8 +459,6 @@ class ManageIQProvider(object):
|
||||||
def main():
|
def main():
|
||||||
zone_id = None
|
zone_id = None
|
||||||
endpoints = []
|
endpoints = []
|
||||||
|
|
||||||
module = AnsibleModule(
|
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
manageiq_connection=dict(required=True, type='dict',
|
manageiq_connection=dict(required=True, type='dict',
|
||||||
options=manageiq_argument_spec()),
|
options=manageiq_argument_spec()),
|
||||||
|
@ -474,16 +467,20 @@ def main():
|
||||||
zone=dict(default='default'),
|
zone=dict(default='default'),
|
||||||
provider_region=dict(),
|
provider_region=dict(),
|
||||||
type=dict(choices=supported_providers().keys()),
|
type=dict(choices=supported_providers().keys()),
|
||||||
endpoints=dict(type='dict', options=endpoint_list_spec()),
|
)
|
||||||
),
|
# add the endpoint arguments to the arguments
|
||||||
|
argument_spec.update(endpoint_list_spec())
|
||||||
|
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=argument_spec,
|
||||||
required_if=[
|
required_if=[
|
||||||
('state', 'present', ['endpoints'])],
|
('state', 'present', ['provider'])],
|
||||||
)
|
)
|
||||||
|
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
zone_name = module.params['zone']
|
zone_name = module.params['zone']
|
||||||
provider_type = module.params['type']
|
provider_type = module.params['type']
|
||||||
raw_endpoints = module.params['endpoints']
|
raw_endpoints = module.params
|
||||||
provider_region = module.params['provider_region']
|
provider_region = module.params['provider_region']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
|
@ -524,7 +521,8 @@ def main():
|
||||||
msg="provider_type %s is not supported" % (provider_type))
|
msg="provider_type %s is not supported" % (provider_type))
|
||||||
|
|
||||||
# build "connection_configurations" objects from user requsted endpoints
|
# build "connection_configurations" objects from user requsted endpoints
|
||||||
if raw_endpoints:
|
# "provider" is a required endpoint, if we have it, we have endpoints
|
||||||
|
if raw_endpoints.get("provider"):
|
||||||
endpoints = manageiq_provider.build_connection_configurations(provider_type, raw_endpoints)
|
endpoints = manageiq_provider.build_connection_configurations(provider_type, raw_endpoints)
|
||||||
|
|
||||||
# if we have a provider, edit it
|
# if we have a provider, edit it
|
||||||
|
|
Loading…
Reference in a new issue