-
Notifications
You must be signed in to change notification settings - Fork 278
add support to fetch cluster device information from netbox. #1169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from 10 commits
273f322
704186b
1f83775
c07f1d2
da1e90a
0d424e6
9c4a786
fb3cdc2
b586d3f
85dfed3
e40418f
66f1381
360d38c
cdec142
a01d37d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| rm netbox-netbox-3.16.0.tar.gz | ||
| ansible-galaxy collection build . | ||
| ansible-galaxy collection install -f netbox-netbox-3.16.0.tar.gz |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,6 +537,7 @@ def group_extractors(self): | |
| "custom_fields": self.extract_custom_fields, | ||
| "region": self.extract_regions, | ||
| "cluster": self.extract_cluster, | ||
| "cluster_device": self.extract_cluster_device, | ||
| "cluster_group": self.extract_cluster_group, | ||
| "cluster_type": self.extract_cluster_type, | ||
| "is_virtual": self.extract_is_virtual, | ||
|
|
@@ -943,6 +944,12 @@ def extract_cluster(self, host): | |
| except Exception: | ||
| return | ||
|
|
||
| def extract_cluster_device(self, host): | ||
| # cluster device does not have a slug | ||
| if host.get("device", None) is None: | ||
| return "" | ||
| return host.get("device", {"name": ""}).get("name", "") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks awful similar to the above return when there is no device key in the dictionary. Overall I think this needs to be improved
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is your opinion should we return, if there is no value assigned. Should it be null/None?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I would follow the pattern set by the other functions in this code. Specifically it appears that most would |
||
|
|
||
| def extract_cluster_group(self, host): | ||
| try: | ||
| return self.clusters_group_lookup[host["cluster"]["id"]] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you certain this is the correct thing to return? This doesn't seem like a good idea to me