mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
add VMware provider to ManageIQ module (#34112)
Currently the manageiq remote management module only supports OpenShift, AWS and oVirt. This adds the ability to create VMware providers by adding two additional parameters for configuring a host VNC range.
This commit is contained in:
parent
b051fc6067
commit
18e41ca4d9
1 changed files with 46 additions and 5 deletions
|
@ -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']
|
choices: ['Openshift', 'Amazon', 'oVirt', 'VMware']
|
||||||
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
|
||||||
|
@ -46,6 +46,16 @@ options:
|
||||||
description: The provider region name to connect to (e.g. AWS region for Amazon).
|
description: The provider region name to connect to (e.g. AWS region for Amazon).
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
|
host_default_vnc_port_start:
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
description: The first port in the host VNC range. defaults to None.
|
||||||
|
version_added: "2.5"
|
||||||
|
host_default_vnc_port_end:
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
description: The last port in the host VNC range. defaults to None.
|
||||||
|
version_added: "2.5"
|
||||||
|
|
||||||
provider:
|
provider:
|
||||||
required: false
|
required: false
|
||||||
|
@ -375,6 +385,22 @@ EXAMPLES = '''
|
||||||
username: 'admin'
|
username: 'admin'
|
||||||
password: 'password'
|
password: 'password'
|
||||||
verify_ssl: true
|
verify_ssl: true
|
||||||
|
|
||||||
|
- name: Create a new VMware provider in ManageIQ
|
||||||
|
manageiq_provider:
|
||||||
|
name: 'EngVMware'
|
||||||
|
type: 'VMware'
|
||||||
|
state: 'present'
|
||||||
|
provider:
|
||||||
|
hostname: 'vcenter.example.com'
|
||||||
|
host_default_vnc_port_start: 5800
|
||||||
|
host_default_vnc_port_end: 5801
|
||||||
|
userid: 'root'
|
||||||
|
password: 'password'
|
||||||
|
manageiq_connection:
|
||||||
|
url: 'https://127.0.0.1'
|
||||||
|
token: 'VeryLongToken'
|
||||||
|
verify_ssl: true
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
@ -401,6 +427,9 @@ def supported_providers():
|
||||||
default_role='default',
|
default_role='default',
|
||||||
metrics_role='metrics',
|
metrics_role='metrics',
|
||||||
),
|
),
|
||||||
|
VMware=dict(
|
||||||
|
class_name='ManageIQ::Providers::Vmware::InfraManager',
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -553,7 +582,8 @@ class ManageIQProvider(object):
|
||||||
|
|
||||||
return dict(changed=True, msg=result['message'])
|
return dict(changed=True, msg=result['message'])
|
||||||
|
|
||||||
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):
|
||||||
""" Edit a user from manageiq.
|
""" Edit a user from manageiq.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -566,6 +596,8 @@ class ManageIQProvider(object):
|
||||||
zone={'id': zone_id},
|
zone={'id': zone_id},
|
||||||
provider_region=provider_region,
|
provider_region=provider_region,
|
||||||
connection_configurations=endpoints,
|
connection_configurations=endpoints,
|
||||||
|
host_default_vnc_port_start=host_default_vnc_port_start,
|
||||||
|
host_default_vnc_port_end=host_default_vnc_port_end,
|
||||||
)
|
)
|
||||||
|
|
||||||
# NOTE: we do not check for diff's between requested and current
|
# NOTE: we do not check for diff's between requested and current
|
||||||
|
@ -587,7 +619,8 @@ class ManageIQProvider(object):
|
||||||
changed=True,
|
changed=True,
|
||||||
msg="successfully updated the provider %s: %s" % (provider['name'], result))
|
msg="successfully updated the provider %s: %s" % (provider['name'], result))
|
||||||
|
|
||||||
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):
|
||||||
""" Creates the user in manageiq.
|
""" Creates the user in manageiq.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -606,6 +639,8 @@ class ManageIQProvider(object):
|
||||||
type=supported_providers()[provider_type]['class_name'],
|
type=supported_providers()[provider_type]['class_name'],
|
||||||
zone={'id': zone_id},
|
zone={'id': zone_id},
|
||||||
provider_region=provider_region,
|
provider_region=provider_region,
|
||||||
|
host_default_vnc_port_start=host_default_vnc_port_start,
|
||||||
|
host_default_vnc_port_end=host_default_vnc_port_end,
|
||||||
connection_configurations=endpoints,
|
connection_configurations=endpoints,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -624,6 +659,8 @@ def main():
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
zone=dict(default='default'),
|
zone=dict(default='default'),
|
||||||
provider_region=dict(),
|
provider_region=dict(),
|
||||||
|
host_default_vnc_port_start=dict(),
|
||||||
|
host_default_vnc_port_end=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
|
||||||
|
@ -642,6 +679,8 @@ def main():
|
||||||
provider_type = module.params['type']
|
provider_type = module.params['type']
|
||||||
raw_endpoints = module.params
|
raw_endpoints = module.params
|
||||||
provider_region = module.params['provider_region']
|
provider_region = module.params['provider_region']
|
||||||
|
host_default_vnc_port_start = module.params['host_default_vnc_port_start']
|
||||||
|
host_default_vnc_port_end = module.params['host_default_vnc_port_end']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
manageiq = ManageIQ(module)
|
manageiq = ManageIQ(module)
|
||||||
|
@ -687,10 +726,12 @@ def main():
|
||||||
|
|
||||||
# if we have a provider, edit it
|
# if we have a provider, edit it
|
||||||
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)
|
||||||
# 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)
|
||||||
|
|
||||||
module.exit_json(**res_args)
|
module.exit_json(**res_args)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue