mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Merge pull request #4852 from glennmatthews/gfm-2006-continued
Some additional fixes to scripts/reports background running (2.9)
This commit is contained in:
		@@ -101,7 +101,7 @@ class TemplateLanguageChoices(ChoiceSet):
 | 
			
		||||
class LogLevelChoices(ChoiceSet):
 | 
			
		||||
 | 
			
		||||
    LOG_DEFAULT = 'default'
 | 
			
		||||
    LOG_SUCCESS = 'sucess'
 | 
			
		||||
    LOG_SUCCESS = 'success'
 | 
			
		||||
    LOG_INFO = 'info'
 | 
			
		||||
    LOG_WARNING = 'warning'
 | 
			
		||||
    LOG_FAILURE = 'failure'
 | 
			
		||||
 
 | 
			
		||||
@@ -415,8 +415,6 @@ def run_script(data, request, commit=True, *args, **kwargs):
 | 
			
		||||
    try:
 | 
			
		||||
        with transaction.atomic():
 | 
			
		||||
            script.output = script.run(**kwargs)
 | 
			
		||||
            job_result.data = ScriptOutputSerializer(script).data
 | 
			
		||||
            job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED)
 | 
			
		||||
 | 
			
		||||
            if not commit:
 | 
			
		||||
                raise AbortTransaction()
 | 
			
		||||
@@ -434,6 +432,10 @@ def run_script(data, request, commit=True, *args, **kwargs):
 | 
			
		||||
        job_result.set_status(JobResultStatusChoices.STATUS_ERRORED)
 | 
			
		||||
 | 
			
		||||
    finally:
 | 
			
		||||
        if job_result.status != JobResultStatusChoices.STATUS_ERRORED:
 | 
			
		||||
            job_result.data = ScriptOutputSerializer(script).data
 | 
			
		||||
            job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED)
 | 
			
		||||
 | 
			
		||||
        if not commit:
 | 
			
		||||
            # Delete all pending changelog entries
 | 
			
		||||
            purge_changelog.send(Script)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user