Skip to content

Commit e40418f

Browse files
committed
approach to handle errors and at every error or missing value return a none type. if value is present return this value.
1 parent 85dfed3 commit e40418f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,10 +945,14 @@ def extract_cluster(self, host):
945945
return
946946

947947
def extract_cluster_device(self, host):
948-
# cluster device does not have a slug
949-
if host.get("device", None) is None:
950-
return ""
951-
return host.get("device", {"name": ""}).get("name", "")
948+
try:
949+
# cluster device does not have a slug
950+
if host.get("device") is None:
951+
return
952+
else:
953+
return host["device"].get("name")
954+
except TypeError:
955+
return
952956

953957
def extract_cluster_group(self, host):
954958
try:

0 commit comments

Comments
 (0)