Skip to content
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

Support for importing Netbox's Config Context #42

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion netbox/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@ def get_host_vars(self, host_data, host_vars):
for var_name, var_data in host_vars[category].items():
# This is because "custom_fields" has more than 1 type.
# Values inside "custom_fields" could be a key:value or a dict.
if isinstance(data_dict.get(var_data), dict):
if var_data == "config_context":
var_value = data_dict.get(var_data)
if var_value and var_value.get('configuration'):
var_value = var_value['configuration']
else:
var_value = None
elif isinstance(data_dict.get(var_data), dict):
var_value = self._get_value_by_path(data_dict, [var_data, key_name], ignore_key_error=True)
else:
var_value = data_dict.get(var_data)
Expand Down
1 change: 1 addition & 0 deletions netbox/netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ netbox:
# Any other sections.
general:
rack_name: rack
config: config_context
# Custom sections (custom_fields) could be used as vars too.
#custom:
# env: env