Skip to content

Commit f7c1398

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 b55cb2f commit f7c1398

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
@@ -781,7 +781,9 @@ def __init__(self, module, endpoint, nb_client=None):
781781
try:
782782
self.version = self.nb.version
783783
try:
784-
self.full_version = self.nb.status().get("netbox-version")
784+
self.full_version = re.match(
785+
r"^([\d.]+)", self.nb.status().get("netbox-version")
786+
).group(1)
785787
except Exception:
786788
# For NetBox versions without /api/status endpoint
787789
self.full_version = f"{self.version}.0"
@@ -857,7 +859,9 @@ def _connect_netbox_api(self, url, token, ssl_verify, cert, headers=None):
857859
try:
858860
self.version = nb.version
859861
try:
860-
self.full_version = nb.status().get("netbox-version")
862+
self.full_version = re.match(
863+
r"^([\d.]+)", nb.status().get("netbox-version")
864+
).group(1)
861865
except Exception:
862866
# For NetBox versions without /api/status endpoint
863867
self.full_version = f"{self.version}.0"

0 commit comments

Comments
 (0)