-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add ability to inject configurations from a list of commands #160
base: develop
Are you sure you want to change the base?
Conversation
Oddly enough, I don't think the original |
if isinstance(config_context, int): | ||
return config_context | ||
# NautobotInventory (nornir-nautobot) inventory. | ||
if obj.data["pynautobot_dictionary"].get("custom_fields"): |
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.
Should this be a obj.data.get("pynautobot_dictionary", {})
?
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.
Actually, may need to be:
if hasattr(obj, "data") and obj.data.get("pynautobot_dictionary", {}).get("custom_fields"):
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.
my perspective is pynautobot_dictionary (and data for that matter) is guaranteed to be there since the inventory plugin is creating that key. Happy to still add that, but just providing my perspective.
logger.error(error_msg, extra={"object": obj}) | ||
raise NornirNautobotException(error_msg) | ||
except Exception: # pylint:disable=broad-exception-caught | ||
logger.error("Exception occured during config_injection, continuing without it.", extra={"object": obj}) |
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.
Why are we removing this exception handling?
In certain circumstances and at times with certain platforms the not all configurations are in a standard
get configuration
method. Two common examples are:A specific default configuration only visible in the
show run all
version of the configuration needs to be validated. E.g. Cisco IOS you may need to validateservice pad
configurations, so you might want to inject thos by runningshow run all | i service pad
.A specific configuration is not anywhere in the configuration and the ability to inject it would be valuable. E.g. Cisco NXOS doesn't show snmp-user information in the backup. This means an additional show command needs to be run to fully replicate the full configuration.
The config injection will run additional commands that are defined on the following order or precedence.
obj.cf["config_injections"]
if is a valid integerobj.get_config_context()["config_injections"]
if is a valid integerDispatcherMixin
as []