| 1 |
# Bacula(R) - The Network Backup Solution |
| 2 |
# |
| 3 |
# Copyright (C) 2000-2022 Kern Sibbald |
| 4 |
# |
| 5 |
# The original author of Bacula is Kern Sibbald, with contributions |
| 6 |
# from many others, a complete list can be found in the file AUTHORS. |
| 7 |
# |
| 8 |
# You may use this file and others of this release according to the |
| 9 |
# license defined in the LICENSE file, which includes the Affero General |
| 10 |
# Public License, v3.0 ("AGPLv3") and some additional permissions and |
| 11 |
# terms pursuant to its AGPLv3 Section 7. |
| 12 |
# |
| 13 |
# This notice must be preserved when any source code is |
| 14 |
# conveyed and/or propagated. |
| 15 |
# |
| 16 |
# Bacula(R) is a registered trademark of Kern Sibbald. |
| 17 |
|
| 18 |
from baculak8s.jobs.backup_job import BackupJob |
| 19 |
from baculak8s.jobs.estimation_job import EstimationJob |
| 20 |
from baculak8s.jobs.listing_job import ListingJob |
| 21 |
from baculak8s.jobs.query_job import QueryJob |
| 22 |
from baculak8s.jobs.restore_job import RestoreJob |
| 23 |
from baculak8s.services.job_info_service import (TYPE_BACKUP, TYPE_ESTIMATION, |
| 24 |
TYPE_RESTORE) |
| 25 |
|
| 26 |
|
| 27 |
class JobFactory(object): |
| 28 |
""" |
| 29 |
Creates a Job that will be executed by the Backend |
| 30 |
|
| 31 |
:param job_type: The type of the created Job (Backup, Restore, Estimation) |
| 32 |
:param plugin: The plugin that this Job should use |
| 33 |
|
| 34 |
:raise: ValueError, if an invalid job_type was provided |
| 35 |
|
| 36 |
""" |
| 37 |
|
| 38 |
@staticmethod |
| 39 |
def create(params, plugin): |
| 40 |
if params["type"] == TYPE_BACKUP: |
| 41 |
return BackupJob(plugin, params) |
| 42 |
|
| 43 |
elif params["type"] == TYPE_RESTORE: |
| 44 |
return RestoreJob(plugin, params) |
| 45 |
|
| 46 |
elif params["type"] == TYPE_ESTIMATION: |
| 47 |
if params.get("listing", None) is not None: |
| 48 |
return ListingJob(plugin, params) |
| 49 |
if params.get("query", None) is not None: |
| 50 |
return QueryJob(plugin, params) |
| 51 |
|
| 52 |
return EstimationJob(plugin, params) |
| 53 |
|
| 54 |
else: |
| 55 |
raise ValueError("Invalid Job Type") |