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

Update cm_utils discover_endpoint function #253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion plugins/module_utils/cm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from time import sleep
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.common.text.converters import to_text
from ansible.module_utils.common.text.converters import to_native, to_text
from time import sleep
from cm_client import (
ApiClient,
Expand Down Expand Up @@ -434,6 +434,12 @@ def discover_endpoint(self, config):
if not self.version:
pre_versioned = urljoin(rendered_url, "/api/version")
versioned = rest.pool_manager.request("GET", pre_versioned, headers=headers)
if versioned.status != 200:
self.module.fail_json(
"Unable to retrieve API version",
status=to_native(versioned.status),
reason=to_native(versioned.reason),
)
self.version = versioned.data.decode("utf-8")

# Construct the discovered API endpoint
Expand Down
5 changes: 1 addition & 4 deletions plugins/modules/cm_endpoint_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
}

DOCUMENTATION = r"""
---
module: cm_endpoint_info
short_description: Discover the Cloudera Manager API endpoint
description:
Expand All @@ -38,7 +37,6 @@
"""

EXAMPLES = r"""
---
# This will first try 'http://example.cloudera.com:7180' and will
# follow any redirects
- name: Gather details using auto-discovery
Expand All @@ -50,9 +48,8 @@
"""

RETURN = r"""
---
endpoint:
description: The discovered Cloudera Manager API endpoint
description: The discovered Cloudera Manager API endpoint, i.e. the base URL.
type: str
returned: always
"""
Expand Down
Loading