mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 03:27:21 -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):
|
for i, datasource in enumerate(datasources, start=1):
|
||||||
self.stdout.write(f"[{i}] Syncing {datasource}... ", ending='')
|
self.stdout.write(f"[{i}] Syncing {datasource}... ", ending='')
|
||||||
self.stdout.flush()
|
self.stdout.flush()
|
||||||
|
try:
|
||||||
datasource.enqueue_sync_job()
|
datasource.sync()
|
||||||
datasource.refresh_from_db()
|
self.stdout.write(datasource.get_status_display())
|
||||||
|
self.stdout.flush()
|
||||||
self.stdout.write(datasource.get_status_display())
|
except Exception as e:
|
||||||
self.stdout.flush()
|
DataSource.objects.filter(pk=datasource.pk).update(status=DataSourceStatusChoices.FAILED)
|
||||||
|
raise e
|
||||||
|
|
||||||
if len(options['name']) > 1:
|
if len(options['name']) > 1:
|
||||||
self.stdout.write(f"Finished.")
|
self.stdout.write(f"Finished.")
|
||||||
|
@ -153,7 +153,7 @@ class DataSource(JobsMixin, PrimaryModel):
|
|||||||
|
|
||||||
return objectchange
|
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().
|
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')
|
SyncDataSourceJob = import_string('core.jobs.SyncDataSourceJob')
|
||||||
return SyncDataSourceJob.enqueue(
|
return SyncDataSourceJob.enqueue(
|
||||||
instance=self,
|
instance=self,
|
||||||
user=(request.user if request else None),
|
user=request.user
|
||||||
run_now=(request is None),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_backend(self):
|
def get_backend(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user