From 3e7cabc289c03985b564f5afcba9b113a6a888bb Mon Sep 17 00:00:00 2001 From: naveena-maplelabs Date: Mon, 20 Nov 2023 04:08:45 -0800 Subject: [PATCH 1/2] Fixed VM Migration Bug Issue: 1) Module looks for the vm folder with provided name. In case of duplicate folder name available migration fails. Fix: 1) Filter folder name by source and resource pool Id. --- plugins/modules/cohesity_migrate_vm.py | 186 +++++++++++++++++++++---- 1 file changed, 160 insertions(+), 26 deletions(-) diff --git a/plugins/modules/cohesity_migrate_vm.py b/plugins/modules/cohesity_migrate_vm.py index 4a8a366..a3c0cc5 100644 --- a/plugins/modules/cohesity_migrate_vm.py +++ b/plugins/modules/cohesity_migrate_vm.py @@ -289,6 +289,55 @@ def get_source_details(module): raise__cohesity_exception__handler(error, module) +def get_vm_folder_id(module, source_id, resource_pool_id): + """ + Check VM folder name exists in the source. + + :param module: Source Id of the Vcenter source. + :return vm folder id. + """ + folder_id = None + folder_name = module.params.get("vm_folder_name") + server = module.params.get("cluster") + validate_certs = module.params.get("validate_certs") + token = get__cohesity_auth__token(module) + try: + uri = ( + "https://" + + server + + "/irisservices/api/v1/vmwareFolders?vCenterId=%s&resourcePoolId=%s" % ( + source_id, resource_pool_id) + ) + headers = { + "Accept": "application/json", + "Authorization": "Bearer " + token, + "user-agent": "cohesity-ansible/v1.1.4", + } + response = open_url( + url=uri, + headers=headers, + validate_certs=validate_certs, + method="GET", + timeout=REQUEST_TIMEOUT, + ) + response = json.loads(response.read()) + for obj in response.get("vmFolders", []): + if obj.get("displayName") == folder_name: + folder_id = obj["id"] + break + if not folder_id: + module.fail_json( + changed=False, + msg="Couldn't find VM folder with name %s" % folder_name, + ) + return folder_id + except urllib_error.URLError as e: + # => Capture and report any error messages. + raise__cohesity_exception__handler(e.read(), module) + except Exception as error: + raise__cohesity_exception__handler(error, module) + + def get_resource_pool_id(module, source_id): """ Check resource pool name exists in the source. @@ -298,7 +347,7 @@ def get_resource_pool_id(module, source_id): are used to uniquely identify the resourcepool. :param module: Source Id of the Vcenter source. - :return reosurce pool id. + :return resource pool id. """ server = module.params.get("cluster") validate_certs = module.params.get("validate_certs") @@ -351,6 +400,104 @@ def get_resource_pool_id(module, source_id): raise__cohesity_exception__handler(error, module) +def get_datastore_id(module, source_id, resource_pool_id): + """ + Check datastore exists in the source. + + :param module: Source Id and resource pool id of the Vcenter source. + :return datastore id. + """ + data_store_id = None + data_store_name = module.params.get("datastore_name") + server = module.params.get("cluster") + validate_certs = module.params.get("validate_certs") + token = get__cohesity_auth__token(module) + try: + uri = ( + "https://" + + server + + "/irisservices/api/v1/datastores?vCenterId=%s&resourcePoolId=%s" % ( + source_id, resource_pool_id) + ) + headers = { + "Accept": "application/json", + "Authorization": "Bearer " + token, + "user-agent": "cohesity-ansible/v1.1.4", + } + response = open_url( + url=uri, + headers=headers, + validate_certs=validate_certs, + method="GET", + timeout=REQUEST_TIMEOUT, + ) + response = json.loads(response.read()) + for obj in response: + if obj.get("displayName") == data_store_name: + data_store_id = obj["id"] + break + if not data_store_id: + module.fail_json( + changed=False, + msg="Couldn't find datastore with name %s" % data_store_name, + ) + return data_store_id + except urllib_error.URLError as e: + # => Capture and report any error messages. + raise__cohesity_exception__handler(e.read(), module) + except Exception as error: + raise__cohesity_exception__handler(error, module) + + +def get_network_id(module, source_id, resource_pool_id): + """ + Check network exists in the source. + + :param module: Source Id and resource pool id of the Vcenter source. + :return network id. + """ + network_id = None + network_name = module.params.get("network_name") + server = module.params.get("cluster") + validate_certs = module.params.get("validate_certs") + token = get__cohesity_auth__token(module) + try: + uri = ( + "https://" + + server + + "/irisservices/api/v1/networkEntities?vCenterId=%s&resourcePoolId=%s" % ( + source_id, resource_pool_id) + ) + headers = { + "Accept": "application/json", + "Authorization": "Bearer " + token, + "user-agent": "cohesity-ansible/v1.1.4", + } + response = open_url( + url=uri, + headers=headers, + validate_certs=validate_certs, + method="GET", + timeout=REQUEST_TIMEOUT, + ) + response = json.loads(response.read()) + for obj in response: + if obj.get("displayName") == network_name: + network_id = obj["id"] + break + if not network_id: + module.fail_json( + changed=False, + msg="Couldn't find network with name %s" % network_name, + ) + return network_id + except urllib_error.URLError as e: + # => Capture and report any error messages. + raise__cohesity_exception__handler(e.read(), module) + except Exception as error: + raise__cohesity_exception__handler(error, module) + + def get_backup_job_run_id(module, job_id): """ Get Backup job run Id. @@ -747,6 +894,7 @@ def main(): check_mode_results[ "msg" ] = "Check Mode: Cohesity Migrate Job is not currently registered. This action would register the Cohesity Migrate Job." + resource_pool_id = None check_mode_results["id"] = job_exists restore_to_source_objects = get_vmware_source_objects(module, source_id) if module.params.get("resource_pool_name"): @@ -768,31 +916,24 @@ def main(): if cluster_resource else "" ) - if module.params.get("datastore_name"): - datastore_id = get_vmware_object_id( - restore_to_source_objects, - module.params.get("datastore_name"), - "kDatastore", - ) + if module.params.get("datastore_name") and resource_pool_id: + datastore_id = get_datastore_id(module, source_id, resource_pool_id) if not datastore_id: error_list += ( "Datastore '%s' is not available in the source." % module.params.get("datastore_name") ) - if module.params.get("network_name"): + if module.params.get("network_name") and resource_pool_id: network_name = module.params.get("network_name") - network_id = get_vmware_object_id( - restore_to_source_objects, network_name, "kNetwork" - ) + network_id = get_network_id(module, source_id, resource_pool_id) if not network_id: error_list += ( "Failed to find network with name '%s'." % network_name ) - if module.params.get("vm_folder_name"): + if module.params.get("vm_folder_name") and resource_pool_id: vm_folder_name = module.params.get("vm_folder_name") - vm_folder_id = get_vmware_object_id( - restore_to_source_objects, vm_folder_name, "kFolder" - ) + vm_folder_id = get_vm_folder_id( + module, source_id, resource_pool_id) if not vm_folder_id: error_list += ( "Failed to find folder with name '%s'." % vm_folder_name @@ -884,11 +1025,7 @@ def main(): ) module.fail_json(error_list) if module.params.get("datastore_name"): - datastore_id = get_vmware_object_id( - restore_to_source_objects, - module.params.get("datastore_name"), - "kDatastore", - ) + datastore_id = get_datastore_id(module, source_id, resource_pool_id) if not datastore_id: module.fail_json( "Datastore '%s' is not available in the source" @@ -901,9 +1038,7 @@ def main(): ) if module.params.get("network_name"): network_name = module.params.get("network_name") - network_id = get_vmware_object_id( - restore_to_source_objects, network_name, "kNetwork" - ) + network_id = get_network_id(module, source_id, resource_pool_id) if not network_id: module.fail_json( msg="Failed to find network with name '%s'" % network_name, @@ -921,9 +1056,8 @@ def main(): ) if module.params.get("vm_folder_name"): vm_folder_name = module.params.get("vm_folder_name") - vm_folder_id = get_vmware_object_id( - restore_to_source_objects, vm_folder_name, "kFolder" - ) + vm_folder_id = get_vm_folder_id( + module, source_id, resource_pool_id) if not vm_folder_id: module.fail_json( msg="Failed to find folder with name '%s'" % vm_folder_name, From c78be85e851a6edd1bb127ff92135e23b8bff538 Mon Sep 17 00:00:00 2001 From: naveena-maplelabs Date: Mon, 20 Nov 2023 04:08:45 -0800 Subject: [PATCH 2/2] Fixed VM Migration Bug Issue: 1) Module looks for the vm folder with provided name. In case of duplicate folder name available migration fails. Fix: 1) Filter folder name by source and resource pool Id. --- galaxy.yml | 2 +- plugins/module_utils/cohesity_auth.py | 2 +- plugins/module_utils/cohesity_hints.py | 8 ++--- plugins/module_utils/cohesity_utilities.py | 2 +- plugins/modules/cohesity_agent.py | 10 +++--- plugins/modules/cohesity_cancel_migration.py | 6 ++-- plugins/modules/cohesity_clone_vm.py | 4 +-- plugins/modules/cohesity_facts.py | 2 +- .../modules/cohesity_finalize_migration.py | 4 +-- plugins/modules/cohesity_job.py | 20 ++++++------ plugins/modules/cohesity_migrate_vm.py | 31 +++++++++---------- plugins/modules/cohesity_migration_status.py | 6 ++-- plugins/modules/cohesity_oracle_job.py | 2 +- plugins/modules/cohesity_oracle_restore.py | 2 +- plugins/modules/cohesity_oracle_source.py | 2 +- plugins/modules/cohesity_plugin.py | 6 ++-- plugins/modules/cohesity_policy.py | 4 +-- plugins/modules/cohesity_restore_file.py | 6 ++-- plugins/modules/cohesity_restore_vm.py | 12 +++---- .../modules/cohesity_restore_vmware_file.py | 8 ++--- plugins/modules/cohesity_source.py | 8 ++--- plugins/modules/cohesity_sync_objects.py | 4 +-- .../modules/cohesity_uda_protection_group.py | 4 +-- plugins/modules/cohesity_uda_source.py | 4 +-- plugins/modules/cohesity_view.py | 4 +-- plugins/modules/cohesity_win_agent.py | 2 +- 26 files changed, 82 insertions(+), 83 deletions(-) diff --git a/galaxy.yml b/galaxy.yml index 976c5e5..4c09c19 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: cohesity name: dataprotect # The version of the collection. Must be compatible with semantic versioning -version: 1.1.4 +version: 1.1.5 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/module_utils/cohesity_auth.py b/plugins/module_utils/cohesity_auth.py index 7bba059..3ca50da 100644 --- a/plugins/module_utils/cohesity_auth.py +++ b/plugins/module_utils/cohesity_auth.py @@ -13,7 +13,7 @@ module_utils: cohesity_auth short_description: The **CohesityAuth** utils module provides the authentication token manage for Cohesity Platforms. -version_added: 1.1.4 +version_added: 1.1.5 description: - The **CohesityAuth** utils module provides the authentication token manage for Cohesity Platforms. diff --git a/plugins/module_utils/cohesity_hints.py b/plugins/module_utils/cohesity_hints.py index d72f97d..6967f31 100644 --- a/plugins/module_utils/cohesity_hints.py +++ b/plugins/module_utils/cohesity_hints.py @@ -14,7 +14,7 @@ module_utils: cohesity_hints short_description: The **CohesityHints** utils module provides standard methods for returning query data from Cohesity Platforms. -version_added: 1.1.4 +version_added: 1.1.5 description: - The **CohesityHints** utils module provides standard methods for returning query data from Cohesity Platforms. @@ -627,7 +627,7 @@ def unregister_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( @@ -701,7 +701,7 @@ def check__protection_group__exists(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + self["token"], - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -760,7 +760,7 @@ def get_resource_pool_id(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, diff --git a/plugins/module_utils/cohesity_utilities.py b/plugins/module_utils/cohesity_utilities.py index cd6b7d0..09a4c6b 100644 --- a/plugins/module_utils/cohesity_utilities.py +++ b/plugins/module_utils/cohesity_utilities.py @@ -13,7 +13,7 @@ module_utils: cohesity_utilities short_description: The **CohesityUtilities** utils module provides the authentication token manage for Cohesity Platforms. -version_added: 1.1.4 +version_added: 1.1.5 description: - The **CohesityUtilities** utils module provides the authentication token manage for Cohesity Platforms. diff --git a/plugins/modules/cohesity_agent.py b/plugins/modules/cohesity_agent.py index bae6de8..25844d8 100644 --- a/plugins/modules/cohesity_agent.py +++ b/plugins/modules/cohesity_agent.py @@ -305,7 +305,7 @@ def download_agent(module, path): headers = { "Accept": "application/octet-stream", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } elif not module.params.get("download_uri"): os_type = "Linux" @@ -334,13 +334,13 @@ def download_agent(module, path): headers = { "Accept": "application/octet-stream", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } else: uri = module.params.get("download_uri") headers = { "Accept": "application/octet-stream", - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } agent = open_url( @@ -612,7 +612,7 @@ def get_source_details(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -664,7 +664,7 @@ def update_agent(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = {"agentIds": [source_details["agent"]["id"]]} open_url( diff --git a/plugins/modules/cohesity_cancel_migration.py b/plugins/modules/cohesity_cancel_migration.py index 0b6c64a..7a7afb6 100644 --- a/plugins/modules/cohesity_cancel_migration.py +++ b/plugins/modules/cohesity_cancel_migration.py @@ -64,7 +64,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Cancel the VM migration -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -129,7 +129,7 @@ def check__protection_restore__exists(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -176,7 +176,7 @@ def cancel_migration(module, task_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_clone_vm.py b/plugins/modules/cohesity_clone_vm.py index 454dc42..a77e29d 100644 --- a/plugins/modules/cohesity_clone_vm.py +++ b/plugins/modules/cohesity_clone_vm.py @@ -127,7 +127,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of Cohesity VM Clone" -version_added: 1.1.4 +version_added: 1.1.5 """ @@ -506,7 +506,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.4" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.5" cohesity_client = get_cohesity_client(module) clone_exists, clone_details = get_clone_task(module, False) diff --git a/plugins/modules/cohesity_facts.py b/plugins/modules/cohesity_facts.py index cf09a82..29456ca 100644 --- a/plugins/modules/cohesity_facts.py +++ b/plugins/modules/cohesity_facts.py @@ -15,7 +15,7 @@ short_description: Gather facts about a Cohesity Cluster. description: - Gather facts about Cohesity Clusters. -version_added: 1.1.4 +version_added: 1.1.5 author: "Naveena (@naveena-maplelabs)" options: cluster: diff --git a/plugins/modules/cohesity_finalize_migration.py b/plugins/modules/cohesity_finalize_migration.py index 9f01f5a..9f56aa0 100644 --- a/plugins/modules/cohesity_finalize_migration.py +++ b/plugins/modules/cohesity_finalize_migration.py @@ -65,7 +65,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Finalize the VM migration -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -154,7 +154,7 @@ def finalize_migration(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } body = { "restoreTaskId": self["task_id"], diff --git a/plugins/modules/cohesity_job.py b/plugins/modules/cohesity_job.py index 6b5180d..ac29fc0 100644 --- a/plugins/modules/cohesity_job.py +++ b/plugins/modules/cohesity_job.py @@ -227,7 +227,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of Cohesity Protection Jobs" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -586,7 +586,7 @@ def get_vmware_ids(module, job_meta_data, job_details, vm_names): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -624,7 +624,7 @@ def get_vmware_vm_ids(module, job_meta_data, job_details, vm_names): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -670,7 +670,7 @@ def get_view_storage_domain_id(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -735,7 +735,7 @@ def register_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -840,7 +840,7 @@ def start_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } source_ids = payload.get("sourceIds", []) payload = dict() @@ -899,7 +899,7 @@ def update_job(module, job_details, update_source_ids=None): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = job_details.copy() del payload["token"] @@ -961,7 +961,7 @@ def get_prot_job_details(self, module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -1022,7 +1022,7 @@ def stop_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -1086,7 +1086,7 @@ def unregister_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = dict(deleteSnapshots=self["deleteSnapshots"]) diff --git a/plugins/modules/cohesity_migrate_vm.py b/plugins/modules/cohesity_migrate_vm.py index 87b3bee..eb7ed4a 100644 --- a/plugins/modules/cohesity_migrate_vm.py +++ b/plugins/modules/cohesity_migrate_vm.py @@ -165,7 +165,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Migrate one or more Virtual Machines from Cohesity Migrate Jobs -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -236,7 +236,6 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get__restore_job__by_type, get_cohesity_client, - get_resource_pool_id, ) except ImportError: pass @@ -249,7 +248,7 @@ class ParameterViolation(Exception): def check__protection_restore__exists(module, self): payload = self.copy() payload["restore_type"] = "kRecoverVMs" - payload["count"] = 1 + # payload["count"] = 1 restore_tasks = get__restore_job__by_type(module, payload) @@ -279,7 +278,7 @@ def get_source_details(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -329,7 +328,7 @@ def get_vm_folder_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -379,7 +378,7 @@ def get_resource_pool_id(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -440,7 +439,7 @@ def get_datastore_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -489,7 +488,7 @@ def get_network_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -536,7 +535,7 @@ def get_backup_job_run_id(module, job_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -576,7 +575,7 @@ def get_backup_job_ids(module, job_names): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -620,7 +619,7 @@ def get_vmware_source_objects(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( @@ -682,7 +681,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -724,7 +723,7 @@ def create_migration_task(module, body): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } # module.fail_json(msg=body) response = open_url( @@ -814,7 +813,7 @@ def get_protection_groups(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -918,7 +917,7 @@ def main(): restore_to_source_objects = get_vmware_source_objects(module, source_id) if module.params.get("resource_pool_name"): job_details["sourceId"] = source_id - resource_pool_id = get_resource_pool_id(module, job_details) + resource_pool_id = get_resource_pool_id(module, source_id) if not resource_pool_id: error_list += ( "Failed to find Resource Pool '%s'" @@ -1028,7 +1027,7 @@ def main(): module.fail_json(errors) if module.params.get("resource_pool_name"): job_details["sourceId"] = source_id - resource_pool_id = get_resource_pool_id(module, job_details) + resource_pool_id = get_resource_pool_id(module, source_id) if not resource_pool_id: error_list = ( "Failed to find Resource Pool '%s'" diff --git a/plugins/modules/cohesity_migration_status.py b/plugins/modules/cohesity_migration_status.py index f2558de..4bd834a 100644 --- a/plugins/modules/cohesity_migration_status.py +++ b/plugins/modules/cohesity_migration_status.py @@ -61,7 +61,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Check Sync status of objects available in the VM migration task -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -148,7 +148,7 @@ def get_migration_status(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -180,7 +180,7 @@ def get_task_status(module, task_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_oracle_job.py b/plugins/modules/cohesity_oracle_job.py index 242785b..d484d9b 100644 --- a/plugins/modules/cohesity_oracle_job.py +++ b/plugins/modules/cohesity_oracle_job.py @@ -131,7 +131,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of Cohesity Protection Jobs" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ diff --git a/plugins/modules/cohesity_oracle_restore.py b/plugins/modules/cohesity_oracle_restore.py index 4de38f4..2bd9801 100644 --- a/plugins/modules/cohesity_oracle_restore.py +++ b/plugins/modules/cohesity_oracle_restore.py @@ -135,7 +135,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Restore one or more Virtual Machines from Cohesity Protection Jobs" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ diff --git a/plugins/modules/cohesity_oracle_source.py b/plugins/modules/cohesity_oracle_source.py index 5660abe..6cd79fe 100644 --- a/plugins/modules/cohesity_oracle_source.py +++ b/plugins/modules/cohesity_oracle_source.py @@ -82,7 +82,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of Cohesity Protection Sources" -version_added: 1.1.4 +version_added: 1.1.5 """ diff --git a/plugins/modules/cohesity_plugin.py b/plugins/modules/cohesity_plugin.py index 90251e3..229174c 100644 --- a/plugins/modules/cohesity_plugin.py +++ b/plugins/modules/cohesity_plugin.py @@ -92,7 +92,7 @@ - "Determines whether to upgrade the connector plugin if already installed." type: bool short_description: "Management of Cohesity Datastore Plugin" -version_added: "1.1.4" +version_added: "1.1.5" """ EXAMPLES = """ @@ -205,7 +205,7 @@ def download_datastore_plugin(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-plugin": "cohesity-ansible/v1.1.4", + "user-plugin": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -252,7 +252,7 @@ def update_global_allow_lists(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-plugin": "cohesity-ansible/v1.1.4", + "user-plugin": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_policy.py b/plugins/modules/cohesity_policy.py index 4ad0c21..d93e646 100644 --- a/plugins/modules/cohesity_policy.py +++ b/plugins/modules/cohesity_policy.py @@ -103,7 +103,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Cohesity Protection Policy" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -506,7 +506,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.4" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.5" cohesity_client = get_cohesity_client(module) policy_exists, policy_details = get_policy_details(module) diff --git a/plugins/modules/cohesity_restore_file.py b/plugins/modules/cohesity_restore_file.py index da41ac9..b01956e 100644 --- a/plugins/modules/cohesity_restore_file.py +++ b/plugins/modules/cohesity_restore_file.py @@ -15,7 +15,7 @@ - Ansible Module used to start a Cohesity Recovery Job on a Cohesity Cluster. - When executed in a playbook, the Cohesity Recovery Job will be validated and the appropriate state action - will be applied. -version_added: 1.1.4 +version_added: 1.1.5 author: "Naveena (@naveena-maplelabs)" options: cluster: @@ -379,7 +379,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -428,7 +428,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } attempts = 0 # => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds. diff --git a/plugins/modules/cohesity_restore_vm.py b/plugins/modules/cohesity_restore_vm.py index eaa2ba6..62d56bc 100644 --- a/plugins/modules/cohesity_restore_vm.py +++ b/plugins/modules/cohesity_restore_vm.py @@ -190,7 +190,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Restore one or more Virtual Machines from Cohesity Protection Jobs" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -305,7 +305,7 @@ def get_source_details(module, restore_to_source): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, @@ -354,7 +354,7 @@ def get_vmware_source_objects(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( @@ -432,7 +432,7 @@ def get__vmware_snapshot_information__by_source(module, self, source_details): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } objects = open_url( url=uri, @@ -580,7 +580,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -629,7 +629,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } attempts = 0 # => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds. diff --git a/plugins/modules/cohesity_restore_vmware_file.py b/plugins/modules/cohesity_restore_vmware_file.py index 768b44e..4f37ea9 100644 --- a/plugins/modules/cohesity_restore_vmware_file.py +++ b/plugins/modules/cohesity_restore_vmware_file.py @@ -14,7 +14,7 @@ - Ansible Module used to start a Cohesity Recovery Job on a Cohesity Cluster. - When executed in a playbook, the Cohesity Recovery Job will be validated and the appropriate state action - will be applied. -version_added: 1.1.4 +version_added: 1.1.5 author: "Naveena (@naveena-maplelabs)" options: @@ -265,7 +265,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() @@ -353,7 +353,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } attempts = 0 # => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds. @@ -452,7 +452,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "Ansible-v1.1.4" + base_controller.global_headers["user-agent"] = "Ansible-v1.1.5" cohesity_client = get_cohesity_client(module) if module.params.get("backup_id"): diff --git a/plugins/modules/cohesity_source.py b/plugins/modules/cohesity_source.py index e7f0e22..3c61914 100644 --- a/plugins/modules/cohesity_source.py +++ b/plugins/modules/cohesity_source.py @@ -187,7 +187,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of Cohesity Protection Sources" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -375,7 +375,7 @@ def refresh_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } uri = ( "https://" @@ -420,7 +420,7 @@ def register_sql_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } sql_payload = dict( applications=["kSQL"], @@ -468,7 +468,7 @@ def register_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = self.copy() payload["environment"] = "k" + self["environment"] diff --git a/plugins/modules/cohesity_sync_objects.py b/plugins/modules/cohesity_sync_objects.py index 5fe1052..b317594 100644 --- a/plugins/modules/cohesity_sync_objects.py +++ b/plugins/modules/cohesity_sync_objects.py @@ -66,7 +66,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Sync objects available in the VM migration task -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -154,7 +154,7 @@ def sync_objects(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } body = { "restoreTaskId": self["task_id"], diff --git a/plugins/modules/cohesity_uda_protection_group.py b/plugins/modules/cohesity_uda_protection_group.py index 66e66fa..28c1129 100644 --- a/plugins/modules/cohesity_uda_protection_group.py +++ b/plugins/modules/cohesity_uda_protection_group.py @@ -199,7 +199,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: Management of Cohesity UDA Protection Groups -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -455,7 +455,7 @@ def create_group(module, self, body): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_uda_source.py b/plugins/modules/cohesity_uda_source.py index 3279fa8..bec2d11 100644 --- a/plugins/modules/cohesity_uda_source.py +++ b/plugins/modules/cohesity_uda_source.py @@ -128,7 +128,7 @@ extends_documentation_fragment: - cohesity.dataprotect.cohesity short_description: "Management of UDA Protection Sources" -version_added: 1.1.4 +version_added: 1.1.5 """ EXAMPLES = """ @@ -218,7 +218,7 @@ def register_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.1.4", + "user-agent": "cohesity-ansible/v1.1.5", } payload = dict( environment="kUDA", diff --git a/plugins/modules/cohesity_view.py b/plugins/modules/cohesity_view.py index f1e966d..fe93770 100644 --- a/plugins/modules/cohesity_view.py +++ b/plugins/modules/cohesity_view.py @@ -14,7 +14,7 @@ short_description: Management of Cohesity View description: - Ansible Module to create View. -version_added: 1.1.4 +version_added: 1.1.5 author: "Naveena (@naveena-maplelabs)" options: case_insensitive: @@ -460,7 +460,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.4" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.1.5" cohesity_client = get_cohesity_client(module) view_exists, view_details = get_view_details(module) diff --git a/plugins/modules/cohesity_win_agent.py b/plugins/modules/cohesity_win_agent.py index 23483d6..30a40d6 100644 --- a/plugins/modules/cohesity_win_agent.py +++ b/plugins/modules/cohesity_win_agent.py @@ -17,7 +17,7 @@ - When executed in a playbook, the Cohesity Agent installation will be validated and the appropriate - state action will be applied. The most recent version of the Cohesity Agent will be automatically - downloaded to the host. -version_added: 1.1.4 +version_added: 1.1.5 author: "Naveena (@naveena-maplelabs)" options: cluster: