Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manageiq_provider: don't send top-level null fields on creation #38448

Merged
merged 3 commits into from
Apr 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 19 additions & 20 deletions lib/ansible/modules/remote_management/manageiq/manageiq_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def delete_provider(self, provider):
def edit_provider(self, provider, name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end,
subscription, project, uid_ems, tenant_mapping_enabled, api_version):
""" Edit a user from manageiq.
""" Edit a provider from manageiq.

Returns:
a short message describing the operation executed.
Expand Down Expand Up @@ -737,33 +737,32 @@ def edit_provider(self, provider, name, provider_type, endpoints, zone_id, provi
def create_provider(self, name, provider_type, endpoints, zone_id, provider_region,
host_default_vnc_port_start, host_default_vnc_port_end,
subscription, project, uid_ems, tenant_mapping_enabled, api_version):
""" Creates the user in manageiq.
""" Creates the provider in manageiq.

Returns:
the created user id, name, created_on timestamp,
updated_on timestamp, userid and current_group_id.
a short message describing the operation executed.
"""
resource = dict(
name=name,
zone={'id': zone_id},
provider_region=provider_region,
host_default_vnc_port_start=host_default_vnc_port_start,
host_default_vnc_port_end=host_default_vnc_port_end,
subscription=subscription,
project=project,
uid_ems=uid_ems,
tenant_mapping_enabled=tenant_mapping_enabled,
api_version=api_version,
connection_configurations=endpoints,
)

# clean nulls, we do not send nulls to the api
endpoints = delete_nulls(endpoints)
resource = delete_nulls(resource)

# try to create a new provider
try:
url = '%s/providers' % (self.api_url)
result = self.client.post(
url,
name=name,
type=supported_providers()[provider_type]['class_name'],
zone={'id': zone_id},
provider_region=provider_region,
host_default_vnc_port_start=host_default_vnc_port_start,
host_default_vnc_port_end=host_default_vnc_port_end,
subscription=subscription,
project=project,
uid_ems=uid_ems,
tenant_mapping_enabled=tenant_mapping_enabled,
api_version=api_version,
connection_configurations=endpoints,
)
result = self.client.post(url, type=supported_providers()[provider_type]['class_name'], **resource)
except Exception as e:
self.module.fail_json(msg="failed to create provider %s: %s" % (name, str(e)))

Expand Down