From 04a70aff8c4f72cd06e39d56d880147b6d2fe14f Mon Sep 17 00:00:00 2001 From: Valentyn Prysiazhniuk Date: Fri, 6 Mar 2026 12:04:24 +0200 Subject: [PATCH 1/4] provided client type for PCL to have proper telemetry --- virl/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/virl/helpers.py b/virl/helpers.py index 9fc346b..3bee3a5 100644 --- a/virl/helpers.py +++ b/virl/helpers.py @@ -279,7 +279,11 @@ def get_cml_client(server, ignore=False): os.environ.pop("VIRL2_PASS", None) os.environ.pop("VIRL2_URL", None) - client = ClientLibrary(server.host, server.user, server.passwd, raise_for_auth_failure=True, ssl_verify=ssl_verify) + client = ClientLibrary(server.host, server.user, server.passwd, + raise_for_auth_failure=True, + ssl_verify=ssl_verify, + client_type="virlutils", + ) logger.setLevel(level) return client From 8dcabd0212f2934605153fbd59c4b022e1b9c82a Mon Sep 17 00:00:00 2001 From: Valentyn Prysiazhniuk Date: Wed, 11 Mar 2026 12:10:09 +0200 Subject: [PATCH 2/4] tag added only when pcl 2.9 or above is used --- virl/helpers.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/virl/helpers.py b/virl/helpers.py index 3bee3a5..b171b4f 100644 --- a/virl/helpers.py +++ b/virl/helpers.py @@ -9,7 +9,7 @@ import click from requests.exceptions import HTTPError -from virl2_client import ClientLibrary +from virl2_client import ClientLibrary, Version # http://code.activestate.com/recipes/578035-disable-file-system-redirector/ @@ -279,11 +279,18 @@ def get_cml_client(server, ignore=False): os.environ.pop("VIRL2_PASS", None) os.environ.pop("VIRL2_URL", None) - client = ClientLibrary(server.host, server.user, server.passwd, - raise_for_auth_failure=True, - ssl_verify=ssl_verify, - client_type="virlutils", - ) + if ClientLibrary.VERSION >= Version("2.9.0"): + client = ClientLibrary(server.host, server.user, server.passwd, + raise_for_auth_failure=True, + ssl_verify=ssl_verify, + client_type="VirlUtils", + ) + else: + client = ClientLibrary(server.host, server.user, server.passwd, + raise_for_auth_failure=True, + ssl_verify=ssl_verify, + ) + logger.setLevel(level) return client From b6fa098261ffe3dc117a112fe2b46dcc8cf316bc Mon Sep 17 00:00:00 2001 From: Valentyn Prysiazhniuk Date: Wed, 11 Mar 2026 13:33:46 +0200 Subject: [PATCH 3/4] updated Version import in helpers --- virl/helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/virl/helpers.py b/virl/helpers.py index b171b4f..d4518df 100644 --- a/virl/helpers.py +++ b/virl/helpers.py @@ -9,7 +9,8 @@ import click from requests.exceptions import HTTPError -from virl2_client import ClientLibrary, Version +from virl2_client import ClientLibrary +from virl2_client.virl2_client import Version # http://code.activestate.com/recipes/578035-disable-file-system-redirector/ @@ -279,7 +280,8 @@ def get_cml_client(server, ignore=False): os.environ.pop("VIRL2_PASS", None) os.environ.pop("VIRL2_URL", None) - if ClientLibrary.VERSION >= Version("2.9.0"): + version = getattr(ClientLibrary, "VERSION", None) + if version is not None and version >= Version("2.9.0"): client = ClientLibrary(server.host, server.user, server.passwd, raise_for_auth_failure=True, ssl_verify=ssl_verify, @@ -336,3 +338,4 @@ def get_command(): command = "cml" return command + From 068c2fded22efa81de400772acff534a75077963 Mon Sep 17 00:00:00 2001 From: Valentyn Prysiazhniuk Date: Wed, 11 Mar 2026 15:15:29 +0200 Subject: [PATCH 4/4] updated tag. applied linters --- virl/helpers.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/virl/helpers.py b/virl/helpers.py index d4518df..9a2ebf5 100644 --- a/virl/helpers.py +++ b/virl/helpers.py @@ -282,15 +282,21 @@ def get_cml_client(server, ignore=False): version = getattr(ClientLibrary, "VERSION", None) if version is not None and version >= Version("2.9.0"): - client = ClientLibrary(server.host, server.user, server.passwd, - raise_for_auth_failure=True, - ssl_verify=ssl_verify, - client_type="VirlUtils", + client = ClientLibrary( + server.host, + server.user, + server.passwd, + raise_for_auth_failure=True, + ssl_verify=ssl_verify, + client_type="CmlUtils", ) else: - client = ClientLibrary(server.host, server.user, server.passwd, - raise_for_auth_failure=True, - ssl_verify=ssl_verify, + client = ClientLibrary( + server.host, + server.user, + server.passwd, + raise_for_auth_failure=True, + ssl_verify=ssl_verify, ) logger.setLevel(level) @@ -315,15 +321,9 @@ def get_group_member_ids(all_users, members, add_all_users): def get_group_associations(client, labs, add_all_labs): """Build target lab associations for group create/update payloads.""" if add_all_labs is not None: - return [ - {"id": lab_id, "permissions": convert_permissions(add_all_labs)} - for lab_id in client.get_lab_list() - ] + return [{"id": lab_id, "permissions": convert_permissions(add_all_labs)} for lab_id in client.get_lab_list()] if labs: - return [ - {"id": lab_id, "permissions": convert_permissions(permission)} - for lab_id, permission in labs - ] + return [{"id": lab_id, "permissions": convert_permissions(permission)} for lab_id, permission in labs] return [] @@ -338,4 +338,3 @@ def get_command(): command = "cml" return command -