Просмотр исходного кода

Rename JOBRESULT_RETENTION to JOB_RETENTION

jeremystretch 2 лет назад
Родитель
Сommit
7b258dc11f

+ 1 - 1
docs/administration/housekeeping.md

@@ -4,7 +4,7 @@ NetBox includes a `housekeeping` management command that should be run nightly.
 
 
 * Clearing expired authentication sessions from the database
 * Clearing expired authentication sessions from the database
 * Deleting changelog records older than the configured [retention time](../configuration/miscellaneous.md#changelog_retention)
 * Deleting changelog records older than the configured [retention time](../configuration/miscellaneous.md#changelog_retention)
-* Deleting job result records older than the configured [retention time](../configuration/miscellaneous.md#jobresult_retention)
+* Deleting job result records older than the configured [retention time](../configuration/miscellaneous.md#job_retention)
 * Check for new NetBox releases (if [`RELEASE_CHECK_URL`](../configuration/miscellaneous.md#release_check_url) is set)
 * Check for new NetBox releases (if [`RELEASE_CHECK_URL`](../configuration/miscellaneous.md#release_check_url) is set)
 
 
 This command can be invoked directly, or by using the shell script provided at `/opt/netbox/contrib/netbox-housekeeping.sh`. This script can be linked from your cron scheduler's daily jobs directory (e.g. `/etc/cron.daily`) or referenced directly within the cron configuration file.
 This command can be invoked directly, or by using the shell script provided at `/opt/netbox/contrib/netbox-housekeeping.sh`. This script can be linked from your cron scheduler's daily jobs directory (e.g. `/etc/cron.daily`) or referenced directly within the cron configuration file.

+ 1 - 1
docs/configuration/index.md

@@ -26,7 +26,7 @@ Some configuration parameters are primarily controlled via NetBox's admin interf
 * [`DEFAULT_USER_PREFERENCES`](./default-values.md#default_user_preferences)
 * [`DEFAULT_USER_PREFERENCES`](./default-values.md#default_user_preferences)
 * [`ENFORCE_GLOBAL_UNIQUE`](./miscellaneous.md#enforce_global_unique)
 * [`ENFORCE_GLOBAL_UNIQUE`](./miscellaneous.md#enforce_global_unique)
 * [`GRAPHQL_ENABLED`](./miscellaneous.md#graphql_enabled)
 * [`GRAPHQL_ENABLED`](./miscellaneous.md#graphql_enabled)
-* [`JOBRESULT_RETENTION`](./miscellaneous.md#jobresult_retention)
+* [`JOB_RETENTION`](./miscellaneous.md#job_retention)
 * [`MAINTENANCE_MODE`](./miscellaneous.md#maintenance_mode)
 * [`MAINTENANCE_MODE`](./miscellaneous.md#maintenance_mode)
 * [`MAPS_URL`](./miscellaneous.md#maps_url)
 * [`MAPS_URL`](./miscellaneous.md#maps_url)
 * [`MAX_PAGE_SIZE`](./miscellaneous.md#max_page_size)
 * [`MAX_PAGE_SIZE`](./miscellaneous.md#max_page_size)

+ 5 - 3
docs/configuration/miscellaneous.md

@@ -87,14 +87,16 @@ Setting this to False will disable the GraphQL API.
 
 
 ---
 ---
 
 
-## JOBRESULT_RETENTION
+## JOB_RETENTION
 
 
 !!! tip "Dynamic Configuration Parameter"
 !!! tip "Dynamic Configuration Parameter"
 
 
+!!! note
+    This parameter was renamed from `JOBRESULT_RETENTION` in NetBox v3.5.
+
 Default: 90
 Default: 90
 
 
-The number of days to retain job results (scripts and reports). Set this to `0` to retain
-job results in the database indefinitely.
+The number of days to retain job results (scripts and reports). Set this to `0` to retain job results in the database indefinitely.
 
 
 !!! warning
 !!! warning
     If enabling indefinite job results retention, it is recommended to periodically delete old entries. Otherwise, the database may eventually exceed capacity.
     If enabling indefinite job results retention, it is recommended to periodically delete old entries. Otherwise, the database may eventually exceed capacity.

+ 1 - 1
netbox/extras/admin.py

@@ -39,7 +39,7 @@ class ConfigRevisionAdmin(admin.ModelAdmin):
             'fields': ('DEFAULT_USER_PREFERENCES',),
             'fields': ('DEFAULT_USER_PREFERENCES',),
         }),
         }),
         ('Miscellaneous', {
         ('Miscellaneous', {
-            'fields': ('MAINTENANCE_MODE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOBRESULT_RETENTION', 'MAPS_URL'),
+            'fields': ('MAINTENANCE_MODE', 'GRAPHQL_ENABLED', 'CHANGELOG_RETENTION', 'JOB_RETENTION', 'MAPS_URL'),
         }),
         }),
         ('Config Revision', {
         ('Config Revision', {
             'fields': ('comment',),
             'fields': ('comment',),

+ 4 - 4
netbox/extras/management/commands/housekeeping.py

@@ -67,10 +67,10 @@ class Command(BaseCommand):
         # Delete expired Jobs
         # Delete expired Jobs
         if options['verbosity']:
         if options['verbosity']:
             self.stdout.write("[*] Checking for expired jobs")
             self.stdout.write("[*] Checking for expired jobs")
-        if config.JOBRESULT_RETENTION:
-            cutoff = timezone.now() - timedelta(days=config.JOBRESULT_RETENTION)
+        if config.JOB_RETENTION:
+            cutoff = timezone.now() - timedelta(days=config.JOB_RETENTION)
             if options['verbosity'] >= 2:
             if options['verbosity'] >= 2:
-                self.stdout.write(f"\tRetention period: {config.JOBRESULT_RETENTION} days")
+                self.stdout.write(f"\tRetention period: {config.JOB_RETENTION} days")
                 self.stdout.write(f"\tCut-off time: {cutoff}")
                 self.stdout.write(f"\tCut-off time: {cutoff}")
             expired_records = Job.objects.filter(created__lt=cutoff).count()
             expired_records = Job.objects.filter(created__lt=cutoff).count()
             if expired_records:
             if expired_records:
@@ -88,7 +88,7 @@ class Command(BaseCommand):
                 self.stdout.write("\tNo expired records found.", self.style.SUCCESS)
                 self.stdout.write("\tNo expired records found.", self.style.SUCCESS)
         elif options['verbosity']:
         elif options['verbosity']:
             self.stdout.write(
             self.stdout.write(
-                f"\tSkipping: No retention period specified (JOBRESULT_RETENTION = {config.JOBRESULT_RETENTION})"
+                f"\tSkipping: No retention period specified (JOB_RETENTION = {config.JOB_RETENTION})"
             )
             )
 
 
         # Check for new releases (if enabled)
         # Check for new releases (if enabled)

+ 1 - 1
netbox/netbox/config/parameters.py

@@ -214,7 +214,7 @@ PARAMS = (
         field=forms.IntegerField
         field=forms.IntegerField
     ),
     ),
     ConfigParam(
     ConfigParam(
-        name='JOBRESULT_RETENTION',
+        name='JOB_RETENTION',
         label=_('Job result retention'),
         label=_('Job result retention'),
         default=90,
         default=90,
         description=_("Days to retain job result history (set to zero for unlimited)"),
         description=_("Days to retain job result history (set to zero for unlimited)"),