-
Notifications
You must be signed in to change notification settings - Fork 48
Fixes onboarding_extensions_map issue #91
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
Conversation
The onboarding_extensions_map setting (specified in netbox_onboarding/__init__.py or overridden in configuration.py) is used to map napalm driver names to a custom class which extends the driver, allowing extensibility. Currently, when a mapping doesn't exist for a napalm driver, the NetdevKeepr class's get_onboarding_facts() method fails. This causes the rq-worker to be unable to run the onbaord_device() function to onboard a device. The changes in this commit fix the issue.
|
Also @PhillSimonds please can check if we need to fix the logger on other files, would be good to do all at once |
Currently, the template_content.py DeviceContent class returns `None` if onboarding is not enabled for an OnboardingDevice object. Likewise, if no OnboardingDevice object exists, the template continues trying to access attributes for an OnboardingDevice object. In the first case, template rendering will fail as an empty string is needed in order to insert nothing into the rendered HTML template presented to the user. In the second case, an AttributeError is raised as you can not access attributes of a NoneType object.
|
Since you're fixing the logging, consider enabling logging for LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {"rq_console": {"format": "%(asctime)s %(message)s", "datefmt": "%H:%M:%S",},},
"handlers": {
"rq_console": {
"level": "DEBUG",
"class": "rq.utils.ColorizingStreamHandler",
"formatter": "rq_console",
"exclude": ["%(asctime)s"],
},
},
"loggers": {"rq.worker": {"handlers": ["rq_console"], "level": "DEBUG",}},
} |
|
Cool! I'll throw something in! |
ddb0b2c to
759487d
Compare
237fd18 to
3ccab16
Compare
8865ab6 to
e992186
Compare
|
@glennmatthews @mzbroch Anything else missing before we can merge this one ? it would be useful to get a beta2 ASAP with these fixes. |
glennmatthews
left a comment
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.
Looks good to me, will keep an eye out for a follow-on PR with unit test improvements. :-)
mzbroch
left a comment
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.
LGTM
This PR addresses the following issues:
The onboarding_extensions_map setting (specified in netbox_onboarding/init.py
or overridden in configuration.py) is used to map napalm driver names to a custom
class which extends the driver, allowing extensibility. Currently, when a mapping
doesn't exist for a napalm driver, the NetdevKeepr class's get_onboarding_facts()
method fails. This causes the rq-worker to be unable to run the onboard_device()
function to onboard a device. The changes in this commit fix the issue.
Logging is not instantiated in the same way from file to file, and thus log messages
don't come through (at all in some cases) or consistently (in others). This PR standardizes
logging such that logs are consistently displayed while troubleshooting
Currently, the template_content.py DeviceContent class returns
Noneif onboarding isnot enabled for an OnboardingDevice object. Likewise, if no OnboardingDevice object
exists, the template continues trying to access attributes for an OnboardingDevice object.
In the first case, template rendering will fail as an empty string is needed in order to insert
nothing into the rendered HTML template presented to the user. In the second case, an
AttributeError is raised as you can not access attributes of a NoneType object. This PR returns
empty strings in both cases to ensure the HTML renders correctly.