Skip to content

Commit

Permalink
Add Requested changes
Browse files Browse the repository at this point in the history
Signed-off-by: rsuplina <[email protected]>
  • Loading branch information
rsuplina committed Jan 17, 2024
1 parent c695513 commit 81554a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
36 changes: 18 additions & 18 deletions plugins/modules/cm_trial.py → plugins/modules/cm_trial_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

DOCUMENTATION = r"""
---
module: cm_trial
module: cm_trial_license
short_description: Activate the trial license of Cloudera Manager
description:
- Checking if the trial license is already activated.
Expand All @@ -41,7 +41,7 @@
EXAMPLES = r"""
---
- name: Activate the trial license of Cloudera Manager
cloudera.cluster.cm_trial:
cloudera.cluster.cm_trial_license:
host: example.cloudera.com
port: "7180"
username: "jane_smith"
Expand Down Expand Up @@ -88,22 +88,22 @@ def __init__(self, module):

@ClouderaManagerModule.handle_process
def process(self):

api_instance = ClouderaManagerResourceApi(self.api_client)

try:
get_trial_state_request = api_instance.read_license().to_dict()

if get_trial_state_request:
self.cm_trial_output = get_trial_state_request
self.changed = False

except ApiException as e:
if e.status == 404:
api_instance.begin_trial()
get_trial_state_request = api_instance.read_license().to_dict()
self.cm_trial_output = get_trial_state_request
self.changed = True
if not self.module.check_mode:
api_instance = ClouderaManagerResourceApi(self.api_client)

try:
get_trial_state_request = api_instance.read_license().to_dict()

if get_trial_state_request:
self.cm_trial_output = get_trial_state_request
self.changed = False
except ApiException as e:
if e.status == 404:
api_instance.begin_trial()
get_trial_state_request = api_instance.read_license().to_dict()
self.cm_trial_output = get_trial_state_request
self.changed = True

def main():
module = ClouderaManagerModule.ansible_module(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
# Copyright 2023 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.
Expand All @@ -21,25 +21,25 @@
import logging
import pytest

from ansible_collections.cloudera.cluster.plugins.modules import cm_trial
from ansible_collections.cloudera.cluster.plugins.modules import cm_trial_license
from ansible_collections.cloudera.cluster.tests.unit import AnsibleExitJson, AnsibleFailJson

LOG = logging.getLogger(__name__)

def test_pytest_cm_trial(module_args):
def test_pytest_cm_trial_license(module_args):
module_args(
{
"username": os.getenv('CM_USERNAME'),
"password": os.getenv('CM_PASSWORD'),
"host": os.getenv('CM_HOST'),
"port": os.getenv('CM_PORT'),
"port": "7180",
"verify_tls": "no",
"debug": "no",
}
)

with pytest.raises(AnsibleExitJson) as e:
cm_trial.main()
cm_trial_license.main()

# LOG.info(str(e.value))
LOG.info(str(e.value.cloudera_manager))

0 comments on commit 81554a4

Please sign in to comment.