-
Notifications
You must be signed in to change notification settings - Fork 57
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
Config Deployment and Remediation #533
Conversation
* Adds ConfigPlan model and initial generation utils * Updates logic to not create empty config_set * Changes functions to return config_set instead * Format via black * Adds signal to create default ConfigPlan statuses * Adds ConfigPlan initial UI/API elements * Fixes Status filter * Removes unused imports * Changes variable to function * Adds ConfigPlan nested serializer * Update help text per feedback * Adds CLI rule generation * Adds ConfigPlan model tests * Adds ConfigPlan filter tests * Adds ConfigPlan api tests * Adds ConfigPlan utility tests * Adds ConfigPlan view tests * Changes the test to only run on certain versions * Hides generate button until a plan type is chosen * Adds line break to help text * Changes serializer to disable POST method * Updates wording * Changes default statuses to Approved/Not Approved * Changes field to singular * Adds plan type to str method * Adds initial Config Plan documentation * Reorders migration file after rebase * Fixes imported class after rebase * Updates from PR feedback * Fixes absolute url test * Fixes typo * Enables and fixes Edit View tests --------- Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com>
* initial commit for remediation * initial commit for remediation * typo fix * typo fix * initial commit for remediation * initial commit for remediation * typo fix * typo fix * modified: nautobot_golden_config/models.py modified: pyproject.toml * temporary fixes and changes * modified: nautobot_golden_config/nornir_plays/config_compliance.py * modified: nautobot_golden_config/models.py * modified: nautobot_golden_config/forms.py modified: nautobot_golden_config/templates/nautobot_golden_config/compliance_device_report.html modified: nautobot_golden_config/templates/nautobot_golden_config/compliancerule_retrieve.html modified: nautobot_golden_config/templates/nautobot_golden_config/configcompliance.html * Remediation options updates * modified: nautobot_golden_config/choices.py modified: nautobot_golden_config/models.py modified: nautobot_golden_config/navigation.py modified: nautobot_golden_config/tables.py * modified: nautobot_golden_config/models.py modified: nautobot_golden_config/navigation.py modified: nautobot_golden_config/tables.py modified: nautobot_golden_config/templates/nautobot_golden_config/remediationsetting_retrieve.html * modified: nautobot_golden_config/models.py modified: nautobot_golden_config/templates/nautobot_golden_config/compliancerule_retrieve.html modified: nautobot_golden_config/templates/nautobot_golden_config/remediationsetting_retrieve.html modified: nautobot_golden_config/views.py * modified: nautobot_golden_config/models.py modified: nautobot_golden_config/templates/nautobot_golden_config/compliancerule_retrieve.html modified: nautobot_golden_config/templates/nautobot_golden_config/configcompliance.html * lint: nautobot_golden_config/api/serializers.py lint: nautobot_golden_config/forms.py lint: nautobot_golden_config/models.py lint: nautobot_golden_config/tables.py lint: nautobot_golden_config/views.py * lint: nautobot_golden_config/models.py * lint: nautobot_golden_config/models.py * lint: nautobot_golden_config/models.py * lint: nautobot_golden_config/models.py * lint: nautobot_golden_config/models.py * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * remove python 3.7 from ci.yml * Update ci.yml * Update ci.yml * modified: .github/workflows/ci.yml new file: nautobot_golden_config/migrations/0025_auto_20230707_0921.py modified: poetry.lock * black: nautobot_golden_config/migrations/0025_auto_20230707_0921.py * black: nautobot_golden_config/migrations/0025_auto_20230707_0921.py * modified: nautobot_golden_config/migrations/0005_json_compliance_rule.py modified: nautobot_golden_config/migrations/0025_auto_20230707_0921.py * modified: nautobot_golden_config/tests/test_models.py * tests: nautobot_golden_config/tests/test_models.py * modified: nautobot_golden_config/tests/test_models.py * peer-review: .github/workflows/ci.yml peer-review: nautobot_golden_config/models.py * new file: docs/images/remediation_custom_function_setup.png new file: docs/images/remediation_enable_compliance_rule_feature.png new file: docs/images/remediation_hier_edit_options.png new file: docs/images/remediation_settings_per_platform.png new file: docs/images/remediation_validate_feature.png new file: docs/user/app_feature_remediation.md modified: nautobot_golden_config/api/serializers.py modified: nautobot_golden_config/filters.py modified: nautobot_golden_config/models.py modified: nautobot_golden_config/tests/conftest.py modified: nautobot_golden_config/tests/test_api.py modified: nautobot_golden_config/tests/test_models.py modified: pyproject.toml * modified: nautobot_golden_config/filters.py * lint: nautobot_golden_config/filters.py * new file: nautobot_golden_config/migrations/0025_remediation_settings_part1.py * deleted: nautobot_golden_config/migrations/0025_auto_20230707_0921.py * lint: nautobot_golden_config/tests/test_models.py * modified: nautobot_golden_config/migrations/0005_json_compliance_rule.py modified: nautobot_golden_config/migrations/0025_remediation_settings_part1.py * modified: nautobot_golden_config/migrations/0025_remediation_settings_part1.py --------- Co-authored-by: pato23arg <patricior_villar@hotmail.com> Co-authored-by: pvillar_netdev <pato23arg@users.noreply.github.com> Co-authored-by: Ken Celenza <ken@celenza.org>
* Split Migrations * Bump min to 1.5.14
#536) * Add Config Set modal to list view, copy button on modal/detail view, and update bulk edit. * Update nautobot_golden_config/tables.py Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com> * update navigation --------- Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>
* Move config create to a javascript process that waits for job to complete and report details into modal. Modal provides * Provide progress spinner * Provide job status, * Job results link * Redirect link * Error message. * Separated edit and create templates as they serve different purposes. * Converted hidden form to uses standard NautobotUIViewSet create method with small amount of JS * Updated model to link job_result and cm URL * Updated job to aggregate config to one per job run Made the JS pieces composable for near future use to kick off job to push configurations.
nautobot_golden_config/models.py
Outdated
try: | ||
remediation_setting = RemediationSetting.objects.get(platform=self.platform) | ||
except RemediationSetting.DoesNotExist as err: | ||
raise ValidationError(f"Platform {self.platform.slug} has no Remediation Settings defined.") from err |
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.
I think this should rather return None
here
self.remediation = None | ||
return | ||
|
||
if not self.rule.config_remediation: |
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.
This will have no effect , but technically this should be the first rule in order
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.
@mzbroch Can you expand on why you're saying here?
rule2 = create_feature_rule_json(device2, feature="Test Feature 2") | ||
rule3 = create_feature_rule_json(device3, feature="Test Feature 3") | ||
|
||
not_approved_status = Status.objects.get(slug="not-approved") |
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.
With planned slug removal, would it make sense to change this to simpler form "unapproved" ?
|
||
# TODO: Make the default Status configurable | ||
def config_plan_default_status(): | ||
"""Return the default status for config plan.""" |
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.
This one should come from the plugin's settings.
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.
reviewing..
Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>
* Removes deprecated pylint options * Updates CI to run on 1.5.14 * Updates CI to run on 1.5.14
* Adds config deployment job and UI elements * Adds logic to fail if any plans are not approved * Skips plan deletion if the job failed
needed for now, can remove late but some other dependencies
Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com>
Last few todos:
|
#559 needs to be merged into this PR before we finalize this. |
* Replaces screenshots with new form fields * Removes copy pasta title
Yes, all Jobs are disabled by default. We can, however, add a simple check to the view to create a warning message if the Job is disabled. |
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.
There are a lack of View and Filter tests for RemediationSetting
nautobot_golden_config/templates/nautobot_golden_config/compliance_device_report.html
Outdated
Show resolved
Hide resolved
Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>
Overall, plugins should be able to provide jobs that are installed and enabled without any additional user interactions. Ideal workflow is to install and enable the golden config plugin, without any extra steps to enable / migrate jobs etc. Do You mind creating an issue within Nautobot core to track this ? The overall user experience should be simple and allow to user plugin immediately. |
Do I mind? Yes. I agree with the stance that all Jobs should be disabled by default for security reasons. |
* additional pr review updates * fix dunder string method * fix docstrings and fix filters * fix api testing for remediation settings
Co-authored-by: Joe Wesch <10467633+joewesch@users.noreply.github.com>
Anything else form this comment that we want to scope now? I agree that much of these would be well suited for individual feature request that can come in the near future. But don't want to neglect the solid work @mzbroch put into this review. |
closing this as the simplified commit history was done in #573 . This has all the history along with all commits, conversation etc. for these features. |
closing per completed in #573 |
The origin branch has two new models etc. to support these features, this PR will be used to make sure all integrations of both new features work in conjunction before merging into Next.