Skip to content

Commit 351c1d3

Browse files
committed
sanitize get netbox-version in netbox_utils
- netbox-version can sometimes be 4.2.9-Docker-3.2.1 but expecting full_version is just 4.2.9 do not see any purpose Docker-3.2.1
1 parent 60d7bfe commit 351c1d3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,9 @@ def __init__(self, module, endpoint, nb_client=None):
783783
try:
784784
self.version = self.nb.version
785785
try:
786-
self.full_version = self.nb.status().get("netbox-version")
786+
self.full_version = re.match(
787+
r"^([\d.]+)", self.nb.status().get("netbox-version")
788+
).group(1)
787789
except Exception:
788790
# For NetBox versions without /api/status endpoint
789791
self.full_version = f"{self.version}.0"
@@ -859,7 +861,9 @@ def _connect_netbox_api(self, url, token, ssl_verify, cert, headers=None):
859861
try:
860862
self.version = nb.version
861863
try:
862-
self.full_version = nb.status().get("netbox-version")
864+
self.full_version = re.match(
865+
r"^([\d.]+)", nb.status().get("netbox-version")
866+
).group(1)
863867
except Exception:
864868
# For NetBox versions without /api/status endpoint
865869
self.full_version = f"{self.version}.0"

0 commit comments

Comments
 (0)