From b34a3dbfc078ec6802517ed02656330316a15a0d Mon Sep 17 00:00:00 2001 From: Kavin Agrawal <160099728+kavinagrawalcohesity@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:00:26 +0530 Subject: [PATCH] Ansible-Core Minimum Version Bumped to 2.16 (#55) * Python constant introduced for collection release version * Minimum ansible core version bumped to 2.16 --- .github/workflows/ansible-test.yml | 2 +- README.md | 2 +- docs/common/pre-requisites.md | 2 +- galaxy.yml | 2 +- meta/runtime.yml | 2 +- plugins/module_utils/cohesity_constants.py | 3 +++ plugins/module_utils/cohesity_hints.py | 9 ++++--- plugins/modules/cohesity_agent.py | 13 ++++++---- plugins/modules/cohesity_cancel_migration.py | 7 ++++-- plugins/modules/cohesity_clone_vm.py | 5 +++- .../modules/cohesity_finalize_migration.py | 5 +++- plugins/modules/cohesity_job.py | 21 +++++++++------- plugins/modules/cohesity_migrate_vm.py | 25 +++++++++++-------- plugins/modules/cohesity_migration_status.py | 7 ++++-- plugins/modules/cohesity_plugin.py | 7 ++++-- plugins/modules/cohesity_policy.py | 5 +++- plugins/modules/cohesity_restore_file.py | 7 ++++-- plugins/modules/cohesity_restore_vm.py | 13 ++++++---- .../modules/cohesity_restore_vmware_file.py | 9 ++++--- plugins/modules/cohesity_source.py | 9 ++++--- plugins/modules/cohesity_storage_domain.py | 7 ++++-- plugins/modules/cohesity_sync_objects.py | 5 +++- .../modules/cohesity_uda_protection_group.py | 5 +++- plugins/modules/cohesity_uda_source.py | 5 +++- plugins/modules/cohesity_view.py | 5 +++- 25 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 plugins/module_utils/cohesity_constants.py diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 6064744..c8eabab 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -14,5 +14,5 @@ jobs: - name: Perform sanity testing with ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 with: - ansible-core-version: stable-2.15 + ansible-core-version: stable-2.16 testing-type: sanity diff --git a/README.md b/README.md index 6380f95..6d3c84c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ collections: - cohesity.dataprotect ``` # Requirements -- ansible version >= 8.0 +- ansible version >= 9.0 - requests >= 2.31.0 - python version >= '3.6' - cohesity_management_sdk >= 1.6.0 diff --git a/docs/common/pre-requisites.md b/docs/common/pre-requisites.md index 581e781..bc3c19b 100644 --- a/docs/common/pre-requisites.md +++ b/docs/common/pre-requisites.md @@ -4,7 +4,7 @@ The prerequisites for using the Cohesity Ansible Collection are: * Cohesity DataPlatform running version 6.0 or higher (Some Module might have different requirement. Please see individual module for its requirement ) -* [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) version 8.0 or higher +* [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) version 9.0 or higher * The [Ansible Control Machine](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#control-machine-requirements) must be a system running one of the following UNIX operating systems: Linux (Red Hat, Debian, CentOS), macOS, or any of the BSDs. Windows is not supported for the Control Machine. * [Python](https://www.python.org/downloads) version 2.6 or higher * Some Module might also need [Cohesity Management SDK](https://developer.cohesity.com/apidocs-641.html#/python/getting-started). Please see individual module for its requirement diff --git a/galaxy.yml b/galaxy.yml index a5240c7..20a5d7a 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.3.0 +version: 1.4.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/meta/runtime.yml b/meta/runtime.yml index 0e0c8b2..d1a659a 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1 +1 @@ -requires_ansible: ">=2.15" +requires_ansible: ">=2.16" diff --git a/plugins/module_utils/cohesity_constants.py b/plugins/module_utils/cohesity_constants.py new file mode 100644 index 0000000..d3b47c8 --- /dev/null +++ b/plugins/module_utils/cohesity_constants.py @@ -0,0 +1,3 @@ +# Copyright (c) 2024 Cohesity Inc + +RELEASE_VERSION = "1.4.0" diff --git a/plugins/module_utils/cohesity_hints.py b/plugins/module_utils/cohesity_hints.py index ece1c44..f8fd1c6 100644 --- a/plugins/module_utils/cohesity_hints.py +++ b/plugins/module_utils/cohesity_hints.py @@ -45,6 +45,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_utilities import ( raise__cohesity_exception__handler, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except Exception: pass @@ -690,7 +693,7 @@ def unregister_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( @@ -764,7 +767,7 @@ def check__protection_group__exists(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + self["token"], - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -823,7 +826,7 @@ def get_resource_pool_id(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_agent.py b/plugins/modules/cohesity_agent.py index 09e13ad..1f35187 100644 --- a/plugins/modules/cohesity_agent.py +++ b/plugins/modules/cohesity_agent.py @@ -142,6 +142,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_auth import ( get__cohesity_auth__token, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except Exception: pass @@ -307,7 +310,7 @@ def download_agent(module, path): headers = { "Accept": "application/octet-stream", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } elif not module.params.get("download_uri"): os_type = "Linux" @@ -336,13 +339,13 @@ def download_agent(module, path): headers = { "Accept": "application/octet-stream", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } else: uri = module.params.get("download_uri") headers = { "Accept": "application/octet-stream", - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } agent = open_url( @@ -614,7 +617,7 @@ def get_source_details(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -666,7 +669,7 @@ def update_agent(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } 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 e84882d..cf1c490 100644 --- a/plugins/modules/cohesity_cancel_migration.py +++ b/plugins/modules/cohesity_cancel_migration.py @@ -106,6 +106,9 @@ get__restore_task_status__by_id, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -123,7 +126,7 @@ def check__protection_restore__exists(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -170,7 +173,7 @@ def cancel_migration(module, task_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_clone_vm.py b/plugins/modules/cohesity_clone_vm.py index f085d07..055d0b9 100644 --- a/plugins/modules/cohesity_clone_vm.py +++ b/plugins/modules/cohesity_clone_vm.py @@ -188,6 +188,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) from cohesity_management_sdk.controllers.base_controller import BaseController from cohesity_management_sdk.models.clone_task_request import CloneTaskRequest from cohesity_management_sdk.models.vmware_clone_parameters import VmwareCloneParameters @@ -511,7 +514,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.3.0" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v{}".format(RELEASE_VERSION) cohesity_client = get_cohesity_client(module) clone_exists, clone_details = get_clone_task(module, False) diff --git a/plugins/modules/cohesity_finalize_migration.py b/plugins/modules/cohesity_finalize_migration.py index 23e7dc9..47216be 100644 --- a/plugins/modules/cohesity_finalize_migration.py +++ b/plugins/modules/cohesity_finalize_migration.py @@ -118,6 +118,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -159,7 +162,7 @@ def finalize_migration(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } body = { "restoreTaskId": self["task_id"], diff --git a/plugins/modules/cohesity_job.py b/plugins/modules/cohesity_job.py index a92a052..c74e60a 100644 --- a/plugins/modules/cohesity_job.py +++ b/plugins/modules/cohesity_job.py @@ -336,6 +336,9 @@ get__protection_run__all__by_id, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except Exception: pass @@ -595,7 +598,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.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -633,7 +636,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.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -678,7 +681,7 @@ def get_view_storage_domain_id(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -743,7 +746,7 @@ def register_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -848,7 +851,7 @@ def start_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } source_ids = payload.get("sourceIds", []) payload = dict() @@ -907,7 +910,7 @@ def update_job(module, job_details, update_source_ids=None): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = job_details.copy() del payload["token"] @@ -969,7 +972,7 @@ def get_prot_job_details(self, module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -1030,7 +1033,7 @@ def stop_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -1094,7 +1097,7 @@ def unregister_job(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = dict(deleteSnapshots=self["deleteSnapshots"]) diff --git a/plugins/modules/cohesity_migrate_vm.py b/plugins/modules/cohesity_migrate_vm.py index 5715dff..2d51c29 100644 --- a/plugins/modules/cohesity_migrate_vm.py +++ b/plugins/modules/cohesity_migrate_vm.py @@ -245,6 +245,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -286,7 +289,7 @@ def get_source_details(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -336,7 +339,7 @@ def get_vm_folder_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -386,7 +389,7 @@ def get_resource_pool_id(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -447,7 +450,7 @@ def get_datastore_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -496,7 +499,7 @@ def get_network_id(module, source_id, resource_pool_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -543,7 +546,7 @@ def get_backup_job_run_id(module, job_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -583,7 +586,7 @@ def get_backup_job_ids(module, job_names): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -627,7 +630,7 @@ def get_vmware_source_objects(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( @@ -689,7 +692,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -731,7 +734,7 @@ def create_migration_task(module, body): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } # module.fail_json(msg=body) response = open_url( @@ -821,7 +824,7 @@ def get_protection_groups(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_migration_status.py b/plugins/modules/cohesity_migration_status.py index 82bf335..6f0fe7e 100644 --- a/plugins/modules/cohesity_migration_status.py +++ b/plugins/modules/cohesity_migration_status.py @@ -115,6 +115,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -155,7 +158,7 @@ def get_migration_status(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -187,7 +190,7 @@ def get_task_status(module, task_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_plugin.py b/plugins/modules/cohesity_plugin.py index d2e9049..7900852 100644 --- a/plugins/modules/cohesity_plugin.py +++ b/plugins/modules/cohesity_plugin.py @@ -128,6 +128,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get_cohesity_client, ) +from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, +) class InstallError(Exception): @@ -205,7 +208,7 @@ def download_datastore_plugin(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-plugin": "cohesity-ansible/v1.3.0", + "user-plugin": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -252,7 +255,7 @@ def update_global_allow_lists(module): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-plugin": "cohesity-ansible/v1.3.0", + "user-plugin": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_policy.py b/plugins/modules/cohesity_policy.py index 938ea51..60effce 100644 --- a/plugins/modules/cohesity_policy.py +++ b/plugins/modules/cohesity_policy.py @@ -139,6 +139,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) from cohesity_management_sdk.controllers.base_controller import BaseController from cohesity_management_sdk.exceptions.api_exception import APIException from cohesity_management_sdk.models.archival_external_target import ( @@ -578,7 +581,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.3.0" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v{}".format(RELEASE_VERSION) 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 cdf96c0..781cc38 100644 --- a/plugins/modules/cohesity_restore_file.py +++ b/plugins/modules/cohesity_restore_file.py @@ -207,6 +207,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -382,7 +385,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -431,7 +434,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } 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 e033faa..16fdb61 100644 --- a/plugins/modules/cohesity_restore_vm.py +++ b/plugins/modules/cohesity_restore_vm.py @@ -265,6 +265,9 @@ get_resource_pool_id, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -308,7 +311,7 @@ def get_source_details(module, restore_to_source): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, @@ -357,7 +360,7 @@ def get_vmware_source_objects(module, source_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( @@ -435,7 +438,7 @@ def get__vmware_snapshot_information__by_source(module, self, source_details): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } objects = open_url( url=uri, @@ -583,7 +586,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -632,7 +635,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } 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 fdd7452..259c9f5 100644 --- a/plugins/modules/cohesity_restore_vmware_file.py +++ b/plugins/modules/cohesity_restore_vmware_file.py @@ -164,6 +164,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) from cohesity_management_sdk.controllers.base_controller import BaseController from cohesity_management_sdk.exceptions.api_exception import APIException except ImportError: @@ -270,7 +273,7 @@ def start_restore(module, uri, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() @@ -358,7 +361,7 @@ def wait_restore_complete(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } attempts = 0 # => Wait for the restore based on a predetermined number of minutes with checks every 30 seconds. @@ -457,7 +460,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "Ansible-v1.3.0" + base_controller.global_headers["user-agent"] = "Ansible-v{}".format(RELEASE_VERSION) 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 d8b3078..cf236ae 100644 --- a/plugins/modules/cohesity_source.py +++ b/plugins/modules/cohesity_source.py @@ -280,6 +280,9 @@ unregister_source, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except Exception: pass @@ -377,7 +380,7 @@ def refresh_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } uri = ( "https://" @@ -422,7 +425,7 @@ def register_sql_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } sql_payload = dict( applications=["kSQL"], @@ -470,7 +473,7 @@ def register_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = self.copy() payload["environment"] = "k" + self["environment"] diff --git a/plugins/modules/cohesity_storage_domain.py b/plugins/modules/cohesity_storage_domain.py index 37869f6..4d5b0ee 100644 --- a/plugins/modules/cohesity_storage_domain.py +++ b/plugins/modules/cohesity_storage_domain.py @@ -135,6 +135,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get_cohesity_client, ) +from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, +) from ansible.module_utils.urls import open_url try: @@ -357,7 +360,7 @@ def delete_storage_domain(module, domain_id): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } open_url( url=uri, @@ -410,7 +413,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.3.0" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v{}".format(RELEASE_VERSION) cohesity_client = get_cohesity_client(module) domain_exists, domain_details = get_domain_details(module) diff --git a/plugins/modules/cohesity_sync_objects.py b/plugins/modules/cohesity_sync_objects.py index b4a4361..a0e18dd 100644 --- a/plugins/modules/cohesity_sync_objects.py +++ b/plugins/modules/cohesity_sync_objects.py @@ -108,6 +108,9 @@ get__restore_job__by_type, get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except ImportError: pass @@ -147,7 +150,7 @@ def sync_objects(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } body = { "restoreTaskId": self["task_id"], diff --git a/plugins/modules/cohesity_uda_protection_group.py b/plugins/modules/cohesity_uda_protection_group.py index 35979e3..6993888 100644 --- a/plugins/modules/cohesity_uda_protection_group.py +++ b/plugins/modules/cohesity_uda_protection_group.py @@ -261,6 +261,9 @@ get__prot_policy_id__by_name, get__storage_domain_id__by_name, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) from cohesity_management_sdk.exceptions.api_exception import APIException from cohesity_management_sdk.models.delete_protection_job_param import ( DeleteProtectionJobParam, @@ -458,7 +461,7 @@ def create_group(module, self, body): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } response = open_url( url=uri, diff --git a/plugins/modules/cohesity_uda_source.py b/plugins/modules/cohesity_uda_source.py index 40918bf..c82bf26 100644 --- a/plugins/modules/cohesity_uda_source.py +++ b/plugins/modules/cohesity_uda_source.py @@ -171,6 +171,9 @@ from ansible_collections.cohesity.dataprotect.plugins.modules.cohesity_source import ( unregister_source, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) except Exception: pass @@ -221,7 +224,7 @@ def register_source(module, self): headers = { "Accept": "application/json", "Authorization": "Bearer " + token, - "user-agent": "cohesity-ansible/v1.3.0", + "user-agent": "cohesity-ansible/v{}".format(RELEASE_VERSION), } payload = dict( environment="kUDA", diff --git a/plugins/modules/cohesity_view.py b/plugins/modules/cohesity_view.py index 12d438a..4bd8e85 100644 --- a/plugins/modules/cohesity_view.py +++ b/plugins/modules/cohesity_view.py @@ -141,6 +141,9 @@ from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_hints import ( get_cohesity_client, ) + from ansible_collections.cohesity.dataprotect.plugins.module_utils.cohesity_constants import ( + RELEASE_VERSION, + ) from cohesity_management_sdk.controllers.base_controller import BaseController from cohesity_management_sdk.exceptions.api_exception import APIException from cohesity_management_sdk.models.create_view_request import CreateViewRequest @@ -461,7 +464,7 @@ def main(): global cohesity_client base_controller = BaseController() - base_controller.global_headers["user-agent"] = "cohesity-ansible/v1.3.0" + base_controller.global_headers["user-agent"] = "cohesity-ansible/v{}".format(RELEASE_VERSION) cohesity_client = get_cohesity_client(module) view_exists, view_details = get_view_details(module)