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:
Yaacov Zamir 2017-09-05 17:11:29 +03:00 committed by Sam Doran
parent d8649adf10
commit 534c1b8342

View file

@ -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. default: null
metrics['hostname']: 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. default: null
alerts['hostname']: 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,17 +164,16 @@ 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 verify_ssl: False
verify_ssl: False metrics:
metrics: role: 'hawkular'
role: 'hawkular' hostname: 'example.com'
hostname: 'example.com' port: 443
port: 443 verify_ssl: False
verify_ssl: False
manageiq_connection: manageiq_connection:
url: 'http://127.0.0.1:3000' url: 'http://127.0.0.1:3000'
username: 'admin' username: 'admin'
@ -186,16 +184,15 @@ 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 verify_ssl: False
verify_ssl: False metrics:
metrics: hostname: 'next.example.com'
hostname: 'next.example.com' port: 443
port: 443 verify_ssl: False
verify_ssl: False
manageiq_connection: manageiq_connection:
url: 'http://127.0.0.1:3000' url: 'http://127.0.0.1:3000'
username: 'admin' username: 'admin'
@ -217,11 +214,10 @@ 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'
manageiq_connection: manageiq_connection:
url: 'http://127.0.0.1:3000' url: 'http://127.0.0.1:3000'
token: 'VeryLongToken' token: 'VeryLongToken'
@ -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,26 +459,28 @@ class ManageIQProvider(object):
def main(): def main():
zone_id = None zone_id = None
endpoints = [] endpoints = []
argument_spec = dict(
manageiq_connection=dict(required=True, type='dict',
options=manageiq_argument_spec()),
state=dict(choices=['absent', 'present'], default='present'),
name=dict(required=True),
zone=dict(default='default'),
provider_region=dict(),
type=dict(choices=supported_providers().keys()),
)
# add the endpoint arguments to the arguments
argument_spec.update(endpoint_list_spec())
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=argument_spec,
manageiq_connection=dict(required=True, type='dict',
options=manageiq_argument_spec()),
state=dict(choices=['absent', 'present'], default='present'),
name=dict(required=True),
zone=dict(default='default'),
provider_region=dict(),
type=dict(choices=supported_providers().keys()),
endpoints=dict(type='dict', options=endpoint_list_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