summaryrefslogtreecommitdiffstats
path: root/ansible_collections/dellemc/powerflex/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
commit67c6a4d1dccb62159b9d9b2dea4e2f487446e276 (patch)
tree9ccbb35137f480bbbdb899accbda52a8135d3416 /ansible_collections/dellemc/powerflex/tests
parentAdding upstream version 9.4.0+dfsg. (diff)
downloadansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.tar.xz
ansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.zip
Adding upstream version 9.5.1+dfsg.upstream/9.5.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/powerflex/tests')
-rw-r--r--ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.14.txt3
-rw-r--r--ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.15.txt3
-rw-r--r--ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.16.txt3
-rw-r--r--ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.17.txt1
-rw-r--r--ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_api.py3
-rw-r--r--ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_resource_group_api.py162
-rw-r--r--ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_info.py21
-rw-r--r--ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_resource_group.py228
8 files changed, 423 insertions, 1 deletions
diff --git a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.14.txt b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.14.txt
index cb6ef4675..571402121 100644
--- a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.14.txt
+++ b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.14.txt
@@ -40,3 +40,6 @@ plugins/modules/replication_consistency_group.py import-2.7
plugins/modules/replication_consistency_group.py import-3.5
plugins/modules/replication_consistency_group.py compile-2.7
plugins/modules/replication_consistency_group.py compile-3.5
+plugins/modules/resource_group.py validate-modules:missing-gplv3-license
+plugins/modules/resource_group.py compile-2.7
+plugins/modules/resource_group.py import-2.7
diff --git a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.15.txt b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.15.txt
index cb6ef4675..571402121 100644
--- a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.15.txt
+++ b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.15.txt
@@ -40,3 +40,6 @@ plugins/modules/replication_consistency_group.py import-2.7
plugins/modules/replication_consistency_group.py import-3.5
plugins/modules/replication_consistency_group.py compile-2.7
plugins/modules/replication_consistency_group.py compile-3.5
+plugins/modules/resource_group.py validate-modules:missing-gplv3-license
+plugins/modules/resource_group.py compile-2.7
+plugins/modules/resource_group.py import-2.7
diff --git a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.16.txt b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.16.txt
index 531796f6c..0dbde689c 100644
--- a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.16.txt
+++ b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.16.txt
@@ -26,3 +26,6 @@ plugins/modules/replication_consistency_group.py import-2.7
plugins/modules/replication_consistency_group.py compile-2.7
plugins/modules/info.py compile-2.7
plugins/modules/info.py import-2.7
+plugins/modules/resource_group.py validate-modules:missing-gplv3-license
+plugins/modules/resource_group.py compile-2.7
+plugins/modules/resource_group.py import-2.7
diff --git a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.17.txt b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.17.txt
index 54067647b..a464e7b26 100644
--- a/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.17.txt
+++ b/ansible_collections/dellemc/powerflex/tests/sanity/ignore-2.17.txt
@@ -11,3 +11,4 @@ plugins/modules/replication_consistency_group.py validate-modules:missing-gplv3-
plugins/modules/replication_pair.py validate-modules:missing-gplv3-license
plugins/modules/snapshot_policy.py validate-modules:missing-gplv3-license
plugins/modules/fault_set.py validate-modules:missing-gplv3-license
+plugins/modules/resource_group.py validate-modules:missing-gplv3-license
diff --git a/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_api.py b/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_api.py
index 20de1c1c9..2682cbdd5 100644
--- a/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_api.py
+++ b/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_info_api.py
@@ -319,7 +319,8 @@ class MockInfoApi:
'system_exception': "Get array details from Powerflex array failed with error",
'managed_device_get_error': "Get managed devices from PowerFlex Manager failed with error",
'service_template_get_error': "Get service templates from PowerFlex Manager failed with error",
- 'deployment_get_error': "Get deployments from PowerFlex Manager failed with error"
+ 'deployment_get_error': "Get deployments from PowerFlex Manager failed with error",
+ 'firmware_repository_get_error': "Get firmware repository from PowerFlex Manager failed with error"
}
@staticmethod
diff --git a/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_resource_group_api.py b/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_resource_group_api.py
new file mode 100644
index 000000000..228443449
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/tests/unit/plugins/module_utils/mock_resource_group_api.py
@@ -0,0 +1,162 @@
+# Copyright: (c) 2024, Dell Technologies
+
+# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+"""Mock ApiException for Dell Technologies (Dell) PowerFlex Test modules"""
+
+from __future__ import (absolute_import, division, print_function)
+
+__metaclass__ = type
+
+
+class MockResourceResourceGroupAPI:
+
+ RG_COMMON_ARGS = {
+ "hostname": "**.***.**.***",
+ "username": "username",
+ "password": "password",
+ "validate_certs": False,
+ "port": "443",
+ "validate": False,
+ "template_name": None,
+ "template_id": None,
+ "firmware_repository_name": None,
+ "firmware_repository_id": None,
+ "resource_group_name": None,
+ "resource_group_id": None,
+ "schedule_date": None
+ }
+
+ RG_RESPONSE = [{
+ "id": "8aaa03a88de961fa018de96a88d80008",
+ "deploymentName": "ans_rg",
+ "deploymentDescription": "ans test rg",
+ "retry": True,
+ "teardown": False,
+ "serviceTemplate": {
+ "id": "8aaa03a88de961fa018de96a88d80008",
+ "templateName": "update-template (8aaa03a88de961fa018de96a88d80008)",
+ "components": [
+ {
+ "id": "a7dafed9-96f2-4a55-9518-57af4f45686e",
+ "componentID": "component-scaleio-gateway-1",
+ "identifier": None,
+ "componentValid": {
+ "valid": True,
+ "messages": []
+ },
+ "puppetCertName": "scaleio-block-legacy-gateway",
+ "osPuppetCertName": None,
+ "name": "block-legacy-gateway",
+ "type": "SERVER",
+ "subType": "COMPUTEONLY",
+ "teardown": False,
+ "helpText": None,
+ "managementIpAddress": None,
+ "configFile": None,
+ "serialNumber": None,
+ "asmGUID": "scaleio-block-legacy-gateway",
+ "relatedComponents": {
+ "fc0f8f08-18c7-4fa8-bae8-67f3e6f9ccd6": "Node (Software Only)"
+ },
+ "resources": [{
+ "id": "asm::server",
+ "parameters": [{
+ "id": "a7dafed9",
+ "guid": None,
+ "value": None}]}],
+ "refId": None,
+ "cloned": False,
+ "clonedFromId": None,
+ "manageFirmware": False,
+ "brownfield": False,
+ "instances": 1,
+ "clonedFromAsmGuid": None,
+ "ip": None
+ }]
+ },
+ "scheduleDate": None,
+ "status": "error",
+ "compliant": True,
+ "deploymentDevice": [{
+ "refId": "scaleio-block-legacy-gateway",
+ "refType": "SCALEIO",
+ "deviceHealth": "GREEN",
+ "compliantState": "COMPLIANT",
+ "deviceType": "scaleio",
+ "currentIpAddress": "1.3.9.2",
+ "componentId": "910bf934-d45a-4fe3-8ea2-dc481e063a81",
+ "statusMessage": "The processing of PowerFlex is unsuccessful.",
+ "model": "PowerFlex Gateway",
+ "brownfield": False}],
+ "updateServerFirmware": True,
+ "useDefaultCatalog": True,
+ "firmwareRepository": {
+ "id": "8aaa80788b5755d1018b576126d51ba3",
+ "name": "PowerFlex 4.5.0.0",
+ "rcmapproved": False},
+ "firmwareRepositoryId": "8aaa80788b5755d1018b576126d51ba3",
+ "deploymentHealthStatusType": "red",
+ "allUsersAllowed": False,
+ "owner": "admin",
+ "numberOfDeployments": 0,
+ "lifecycleMode": False,
+ "vds": False,
+ "scaleUp": False,
+ "brownfield": False,
+ "templateValid": True,
+ "configurationChange": False}]
+
+ RG_FIRMWARE_REPO = [{
+ "id": "8aaa80788b5755d1018b576126d51ba3",
+ "name": "firmware-name",
+ "sourceLocation": "https://100.65.27.72/artifactory/path/pfxmlogs-bvt-pfmp-swo-upgrade-402-to-451-56.tar.gz",
+ "sourceType": None,
+ "diskLocation": "",
+ "filename": "",
+ "md5Hash": None,
+ "username": "",
+ "password": "",
+ "downloadStatus": "error",
+ "createdDate": "2024-02-26T17:07:11.884+00:00",
+ "createdBy": "admin",
+ "updatedDate": "2024-03-01T06:21:10.917+00:00",
+ "updatedBy": "system",
+ "defaultCatalog": False,
+ "embedded": False,
+ "state": "errors",
+ "softwareComponents": [],
+ "softwareBundles": [],
+ "deployments": [],
+ "bundleCount": 0,
+ "componentCount": 0,
+ "userBundleCount": 0,
+ "minimal": True,
+ "downloadProgress": 100,
+ "extractProgress": 0,
+ "fileSizeInGigabytes": 0.0,
+ "signedKeySourceLocation": None,
+ "signature": "Unknown",
+ "custom": False,
+ "needsAttention": False,
+ "jobId": "Job-10d75a23-d801-4fdb-a2d0-7f6389ab75cf",
+ "rcmapproved": False
+ }]
+
+ RG_TEMPLATE_RESPONSE = [{
+ "id": "8aaa03a88de961fa018de96a88d80008",
+ "templateName": "update-template"
+ }]
+
+ @staticmethod
+ def resource_group_error(response_type):
+ return {
+ "get_delete_deploy_exception": "Deleting a resource group deployment failed with error ",
+ "get_validate_deploy_exception": "Validating a resource group deployment failed with error",
+ "get_create_deploy_exception": "Deploying a resource group failed with error",
+ "get_template_validate_error": "Deploying a resource group failed with error Either template_id",
+ "get_template_error": "Service template new-template is not found",
+ "invalid_date_format": "Deploying a resource group failed with error Invalid schedule_date format",
+ "resource_group_name_error": "Specify resource_group_name for resource group deployment",
+ "resource_group_edit_error": "Editing a resource group failed with error",
+ }[response_type]
diff --git a/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_info.py b/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_info.py
index ce5091212..043fcd566 100644
--- a/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_info.py
+++ b/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_info.py
@@ -604,3 +604,24 @@ class TestPowerflexInfo():
info_module_mock.perform_module_operation()
assert info_module_mock.get_param_value('limit') is None
assert info_module_mock.get_param_value('offset') is None
+
+ def test_get_firmware_repository_details(self, info_module_mock):
+ self.get_module_args.update({
+ "gather_subset": ['firmware_repository'],
+ "limit": 20
+ })
+ info_module_mock.module.params = self.get_module_args
+ info_module_mock.powerflex_conn.firmware_repository.get = MagicMock()
+ info_module_mock.perform_module_operation()
+ info_module_mock.powerflex_conn.firmware_repository.get.assert_called()
+
+ def test_get_deployment_details_throws_exception(self, info_module_mock):
+ self.get_module_args.update({
+ "gather_subset": ['firmware_repository']
+ })
+ info_module_mock.module.params = self.get_module_args
+ info_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ side_effect=MockApiException
+ )
+ self.capture_fail_json_call(MockInfoApi.get_exception_response(
+ 'firmware_repository_get_error'), info_module_mock)
diff --git a/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_resource_group.py b/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_resource_group.py
new file mode 100644
index 000000000..1bf57f083
--- /dev/null
+++ b/ansible_collections/dellemc/powerflex/tests/unit/plugins/modules/test_resource_group.py
@@ -0,0 +1,228 @@
+# Copyright: (c) 2024, Dell Technologies
+
+# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+"""Unit Tests for Resource Group module on Dell Technologies (Dell) PowerFlex"""
+
+from __future__ import (absolute_import, division, print_function)
+
+__metaclass__ = type
+import pytest
+# pylint: disable=unused-import
+from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.libraries import initial_mock
+from mock.mock import MagicMock
+from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_api_exception \
+ import MockApiException
+from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.mock_resource_group_api \
+ import MockResourceResourceGroupAPI
+from ansible_collections.dellemc.powerflex.tests.unit.plugins.module_utils.libraries.powerflex_unit_base \
+ import PowerFlexUnitBase
+from ansible_collections.dellemc.powerflex.plugins.modules.resource_group \
+ import PowerFlexResourceGroup
+
+
+class TestResourceGroup(PowerFlexUnitBase):
+
+ get_module_args = MockResourceResourceGroupAPI.RG_COMMON_ARGS
+
+ @pytest.fixture
+ def module_object(self):
+ return PowerFlexResourceGroup
+
+ def test_delete_deploy_check_mode(self, powerflex_module_mock):
+ self.set_module_params(powerflex_module_mock, self.get_module_args,
+ {"resource_group_name": "ans_rg", "state": "absent", "validate": True})
+ powerflex_module_mock.module.check_mode = True
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.powerflex_conn.deployment.delete = MagicMock(return_value=None)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+
+ def test_delete_deploy(self, powerflex_module_mock):
+ self.set_module_params(powerflex_module_mock, self.get_module_args,
+ {"resource_group_name": "ans_rg", "state": "absent", "validate": True})
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(return_value=[MagicMock()])
+ powerflex_module_mock.powerflex_conn.deployment.delete = MagicMock(return_value=None)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+
+ def test_delete_deploy_by_id(self, powerflex_module_mock):
+ self.set_module_params(powerflex_module_mock, self.get_module_args,
+ {"resource_group_id": "8aaa03a88de961fa018de96a88d80008",
+ "state": "absent", "validate": True, "resource_group_name": None})
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE[0])
+ powerflex_module_mock.powerflex_conn.deployment.delete = MagicMock(return_value=None)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+
+ def test_delete_deploy_by_id_exception(self, powerflex_module_mock):
+ self.set_module_params(powerflex_module_mock, self.get_module_args,
+ {"resource_group_id": "8aaa03a88de961fa018de96a88d80008",
+ "state": "absent", "validate": True, "resource_group_name": None})
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(side_effect=MockApiException)
+ powerflex_module_mock.powerflex_conn.deployment.delete = MagicMock(return_value=None)
+ self.capture_fail_json_call("", powerflex_module_mock, invoke_perform_module=True)
+
+ def test_delete_deploy_exception(self, powerflex_module_mock):
+ self.set_module_params(powerflex_module_mock, self.get_module_args,
+ {"resource_group_name": "ans_rg", "state": "absent", "validate": True,
+ "resource_group_id": None})
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE[0])
+ powerflex_module_mock.powerflex_conn.deployment.delete = MagicMock(side_effect=MockApiException)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('get_delete_deploy_exception'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_validate_deploy(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": "c65d0172-8666-48ab-935e-9a0bf69ed66d",
+ "firmware_repository_id": "8aaa80788b5755d1018b576126d51ba3",
+ "validate": True, "resource_group_id": None, "state": "present"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.service_template.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_FIRMWARE_REPO)
+ powerflex_module_mock.powerflex_conn.deployment.validate = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is False
+
+ def test_validate_deploy_exception(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": "c65d0172-8666-48ab-935e-9a0bf69ed66d",
+ "firmware_repository_id": "8aaa80788b5755d1018b576126d51ba3",
+ "validate": True, "resource_group_id": None, "state": "present"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.get_deployment_data = MagicMock(side_effect=MockApiException)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('get_validate_deploy_exception'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_create_deploy(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present", "schedule_date": "2020-01-01"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.service_template.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.service_template.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_FIRMWARE_REPO)
+ powerflex_module_mock.powerflex_conn.deployment.create = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+
+ def test_create_deploy_exception(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.get_deployment_data = MagicMock(side_effect=MockApiException)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('get_create_deploy_exception'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_template_validation(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": None,
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.service_template.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('get_template_validate_error'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_scheduled_data(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present", "schedule_date": "01/01/2024"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(return_value=[])
+ powerflex_module_mock.powerflex_conn.service_template.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.service_template.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_FIRMWARE_REPO)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('invalid_date_format'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_resource_group_name_error(self, powerflex_module_mock):
+ arguments = {"resource_group_name": None, "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present", "schedule_date": None}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(return_value=None)
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(return_value=None)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('resource_group_name_error'),
+ powerflex_module_mock, invoke_perform_module=True)
+
+ def test_resource_group_edit(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present", "schedule_date": "2020-01-01",
+ "scaleup": True, "node_count": 1, "clone_node": "block-legacy-gateway",
+ "new_resource_group_name": "ans_rg1"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE[0])
+ powerflex_module_mock.powerflex_conn.service_template.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.service_template.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_FIRMWARE_REPO)
+ powerflex_module_mock.powerflex_conn.deployment.edit = MagicMock(
+ return_value=None)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+ arguments.update({"clone_node": None})
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.perform_module_operation()
+ assert powerflex_module_mock.module.exit_json.call_args[1]['changed'] is True
+
+ def test_modify_resource_group_exception(self, powerflex_module_mock):
+ arguments = {"resource_group_name": "ans_rg", "description": "ans_rg",
+ "template_id": None, "template_name": "update-template",
+ "firmware_repository_id": None, "firmware_repository_name": "firmware-name",
+ "validate": False, "state": "present", "schedule_date": "2020-01-01",
+ "scaleup": True, "node_count": 1, "clone_node": "block-legacy-gateway"}
+ self.set_module_params(powerflex_module_mock, self.get_module_args, arguments)
+ powerflex_module_mock.powerflex_conn.deployment.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE)
+ powerflex_module_mock.powerflex_conn.deployment.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_RESPONSE[0])
+ powerflex_module_mock.powerflex_conn.service_template.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.service_template.get_by_id = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_TEMPLATE_RESPONSE)
+ powerflex_module_mock.powerflex_conn.firmware_repository.get = MagicMock(
+ return_value=MockResourceResourceGroupAPI.RG_FIRMWARE_REPO)
+ powerflex_module_mock.modify_resource_group_details = MagicMock(side_effect=MockApiException)
+ self.capture_fail_json_call(
+ MockResourceResourceGroupAPI.resource_group_error('resource_group_edit_error'),
+ powerflex_module_mock, invoke_perform_module=True)