-
Notifications
You must be signed in to change notification settings - Fork 50
Add CM Service Module #194
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2023 Cloudera, Inc. All Rights Reserved. | ||
# Copyright 2024 Cloudera, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -25,13 +25,14 @@ | |
from urllib3.exceptions import InsecureRequestWarning, MaxRetryError, HTTPError | ||
from urllib3.util import Url | ||
from urllib.parse import urljoin | ||
|
||
from time import sleep | ||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible.module_utils.common.text.converters import to_text | ||
|
||
from cm_client import ApiClient, Configuration | ||
from cm_client.rest import ApiException, RESTClientObject | ||
from cm_client.apis.cloudera_manager_resource_api import ClouderaManagerResourceApi | ||
from cm_client.apis.commands_resource_api import CommandsResourceApi | ||
|
||
|
||
__credits__ = ["[email protected]"] | ||
|
@@ -207,6 +208,16 @@ def set_session_cookie(self): | |
api_instance.get_version() | ||
self.api_client.cookie = self.api_client.last_response.getheader("Set-Cookie") | ||
|
||
def wait_for_command_state(self,command_id, polling_interval): | ||
command_api_instance = CommandsResourceApi(self.api_client) | ||
while True: | ||
get_command_state = command_api_instance.read_command_with_http_info(command_id=command_id) | ||
state = get_command_state[0].active | ||
if not state: | ||
break | ||
sleep(polling_interval) | ||
return True | ||
|
||
def call_api(self, path, method, query=None, field="items", body=None): | ||
"""Wrapper to call a CM API endpoint path directly.""" | ||
path_params = [] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.