From 7c286d0d45de4c34669a742b5b6b156739db86d1 Mon Sep 17 00:00:00 2001 From: Simon Dodsley Date: Wed, 14 Jan 2026 10:17:29 -0800 Subject: [PATCH] Fix transport type issue and mismatched versions failures --- changelogs/fragments/890_transport_fix.yaml | 2 + plugins/modules/purefa_connect.py | 52 +++++++++++++-------- 2 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 changelogs/fragments/890_transport_fix.yaml diff --git a/changelogs/fragments/890_transport_fix.yaml b/changelogs/fragments/890_transport_fix.yaml new file mode 100644 index 00000000..3a5ed228 --- /dev/null +++ b/changelogs/fragments/890_transport_fix.yaml @@ -0,0 +1,2 @@ +bugfixes: + - purefa_connect - Fixed issue where incorrect transport type was passed. diff --git a/plugins/modules/purefa_connect.py b/plugins/modules/purefa_connect.py index 25e0bcdf..36958645 100644 --- a/plugins/modules/purefa_connect.py +++ b/plugins/modules/purefa_connect.py @@ -113,7 +113,11 @@ HAS_PYPURECLIENT = True try: - from pypureclient import flasharray + from pypureclient.flasharray import ( + ArrayConnectionPost, + ArrayConnectionPatch, + Client, + ) except ImportError: HAS_PYPURECLIENT = False @@ -233,14 +237,14 @@ def update_connection(module, array, target_array): res = array.patch_array_connections( names=[target_array.name], renew_encryption_key=True, - array_connection=flasharray.ArrayConnectionPatch(), + array_connection=ArrayConnectionPatch(), context_names=[module.params["context"]], ) else: res = array.patch_array_connections( names=[target_array.name], renew_encryption_key=True, - array_connection=flasharray.ArrayConnectionPatch(), + array_connection=ArrayConnectionPatch(), ) if res.status_code != 200: module.fail_json( @@ -257,14 +261,14 @@ def update_connection(module, array, target_array): res = array.patch_array_connections( names=[target_array.name], refresh=True, - array_connection=flasharray.ArrayConnectionPatch(), + array_connection=ArrayConnectionPatch(), context_names=[module.params["context"]], ) else: res = array.patch_array_connections( names=[target_array.name], refresh=True, - array_connection=flasharray.ArrayConnectionPatch(), + array_connection=ArrayConnectionPatch(), ) if res.status_code != 200: module.fail_json( @@ -283,7 +287,7 @@ def update_connection(module, array, target_array): encrypted = "unencrypted" if target_array.encryption != encrypted: # Changing the encryption type requires the connection key - remote_system = flasharray.Client( + remote_system = Client( target=module.params["target_url"], api_token=module.params["target_api"], user_agent=user_agent, @@ -298,7 +302,7 @@ def update_connection(module, array, target_array): if LooseVersion(CONTEXT_VERSION) <= LooseVersion(api_version): res = array.patch_array_connections( names=[target_array.name], - array_connection=flasharray.ArrayConnectionPatch( + array_connection=ArrayConnectionPatch( encryption=encrypted, connection_key=connection_key ), context_names=[module.params["context"]], @@ -306,7 +310,7 @@ def update_connection(module, array, target_array): else: res = array.patch_array_connections( names=[target_array.name], - array_connection=flasharray.ArrayConnectionPatch( + array_connection=ArrayConnectionPatch( encryption=encrypted, connection_key=connection_key ), ) @@ -322,7 +326,7 @@ def update_connection(module, array, target_array): if LooseVersion(CONTEXT_VERSION) <= LooseVersion(api_version): res = array.patch_array_connections( names=[target_array.name], - array_connection=flasharray.ArrayConnectionPatch( + array_connection=ArrayConnectionPatch( type=module.params["connection"] ), context_names=[module.params["context"]], @@ -330,7 +334,7 @@ def update_connection(module, array, target_array): else: res = array.patch_array_connections( names=[target_array.name], - array_connection=flasharray.ArrayConnectionPatch( + array_connection=ArrayConnectionPatch( type=module.params["connection"] ), ) @@ -361,33 +365,43 @@ def create_connection(module, array): "version": 1.5, "platform": platform.platform(), } - remote_system = flasharray.Client( + remote_system = Client( target=module.params["target_url"], api_token=module.params["target_api"], user_agent=user_agent, ) - connection_key = list( - remote_system.get_array_connections_connection_key( + try: + connections = remote_system.get_array_connections_connection_key( encrypted=module.params["encrypted"] - ).items - )[0].connection_key + ) + except TypeError as exc: + if module.params["encrypted"] == "encrypted": + module.warning( + msg=( + "Remote array version of Purity//FA does not support " + "encryption. Continuing without encryption" + ), + ) + connections = remote_system.get_array_connections_connection_key() + + connection_key = list(connections.items)[0].connection_key if LooseVersion(ENCRYPT_VERSION) >= LooseVersion(api_version): if module.params["encrypted"]: encrypted = "encrypted" else: encrypted = "unencrypted" - array_connection = flasharray.ArrayConnectionPost( + array_connection = ArrayConnectionPost( type=module.params["connection"].lower(), management_address=module.params["target_url"].strip("[]"), - replication_transport=module.params["connection"], + replication_transport=module.params["transport"], connection_key=connection_key, encryption=encrypted, ) else: - array_connection = flasharray.ArrayConnectionPost( + array_connection = ArrayConnectionPost( type=module.params["connection"].lower(), management_address=module.params["target_url"].strip("[]"), - replication_transport=module.params["connection"], + replication_transport=module.params["transport"], connection_key=connection_key, ) if not module.check_mode: