mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 19:19:22 -06:00
Revert "Use SyncDataSourceJob for management"
This partially reverts commit db591d4
. The 'run_now' parameter of
'enqueue()' remains, as its being used by following commits.
This commit is contained in:
parent
fd8d5378cf
commit
15f888ca65
@ -34,12 +34,13 @@ class Command(BaseCommand):
|
||||
for i, datasource in enumerate(datasources, start=1):
|
||||
self.stdout.write(f"[{i}] Syncing {datasource}... ", ending='')
|
||||
self.stdout.flush()
|
||||
|
||||
datasource.enqueue_sync_job()
|
||||
datasource.refresh_from_db()
|
||||
|
||||
self.stdout.write(datasource.get_status_display())
|
||||
self.stdout.flush()
|
||||
try:
|
||||
datasource.sync()
|
||||
self.stdout.write(datasource.get_status_display())
|
||||
self.stdout.flush()
|
||||
except Exception as e:
|
||||
DataSource.objects.filter(pk=datasource.pk).update(status=DataSourceStatusChoices.FAILED)
|
||||
raise e
|
||||
|
||||
if len(options['name']) > 1:
|
||||
self.stdout.write(f"Finished.")
|
||||
|
@ -153,7 +153,7 @@ class DataSource(JobsMixin, PrimaryModel):
|
||||
|
||||
return objectchange
|
||||
|
||||
def enqueue_sync_job(self, request=None):
|
||||
def enqueue_sync_job(self, request):
|
||||
"""
|
||||
Enqueue a background job to synchronize the DataSource by calling sync().
|
||||
"""
|
||||
@ -165,8 +165,7 @@ class DataSource(JobsMixin, PrimaryModel):
|
||||
SyncDataSourceJob = import_string('core.jobs.SyncDataSourceJob')
|
||||
return SyncDataSourceJob.enqueue(
|
||||
instance=self,
|
||||
user=(request.user if request else None),
|
||||
run_now=(request is None),
|
||||
user=request.user
|
||||
)
|
||||
|
||||
def get_backend(self):
|
||||
|
Loading…
Reference in New Issue
Block a user