-
Notifications
You must be signed in to change notification settings - Fork 60
Hier Config V3 Upgrade #902
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: develop
Are you sure you want to change the base?
Conversation
@@ -177,32 +178,39 @@ def _verify_get_custom_compliance_data(compliance_details): | |||
|
|||
def _get_hierconfig_remediation(obj): | |||
"""Returns the remediating config.""" | |||
hierconfig_os = obj.device.platform.network_driver_mappings["hier_config"] | |||
hierconfig_os = obj.device.platform.network_driver_mappings.get("hier_config") |
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.
While testing the hier config v3 update, I noticed that if the network_driver_mappings
wasn't created, because of an unsupported driver, then this would cause an exception that isn't handled. By changing this to .get
, it produces a default value of None
, which would cause the ValidationError
below and handled appropriately.
if not hierconfig_os: | ||
raise ValidationError(f"platform {obj.network_driver} is not supported by hierconfig.") | ||
raise ValidationError(f"platform {obj.device.platform.network_driver} is not supported by hierconfig.") |
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.
While testing this function, I noticed that obj.network_driver
is not the correct syntax, it should be obj.device.platform.network_driver
. This would cause a separate exception that is not handled.
|
||
try: | ||
remediation_setting_obj = RemediationSetting.objects.get(platform=obj.rule.platform) | ||
except Exception as err: # pylint: disable=broad-except: | ||
raise ValidationError(f"Platform {obj.network_driver} has no Remediation Settings defined.") from err | ||
raise ValidationError( | ||
f"Platform {obj.device.platform.network_driver} has no Remediation Settings defined." |
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.
While testing this function, I noticed that obj.network_driver
is not the correct syntax, it should be obj.device.platform.network_driver
. This would cause a separate exception that is not handled.
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.
RemediationSetting is set per Platform, so probably we don't need network_driver here
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.
The network driver is specifically used to map to a hier config driver in netutils.
@@ -177,32 +178,39 @@ def _verify_get_custom_compliance_data(compliance_details): | |||
|
|||
def _get_hierconfig_remediation(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.
Would be great to document and standardize and document inputs in this method
|
||
try: | ||
remediation_setting_obj = RemediationSetting.objects.get(platform=obj.rule.platform) | ||
except Exception as err: # pylint: disable=broad-except: | ||
raise ValidationError(f"Platform {obj.network_driver} has no Remediation Settings defined.") from err | ||
raise ValidationError( | ||
f"Platform {obj.device.platform.network_driver} has no Remediation Settings defined." |
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.
RemediationSetting is set per Platform, so probably we don't need network_driver here
What's Changed
This pull requests updates hier_config from 2.2.2 to 3.2.2. This hier_config migration across major revisions required a refactor of the hier_config implementation in Golden Config. All this occurs under the hood and will not change the remediation experience for the user.
To Do
models.py
.