aboutsummaryrefslogtreecommitdiff
path: root/app/jobs
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-23 11:16:26 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-23 12:58:05 +0100
commit05df9f91e9bdf39b190710ef5d80162d03dd52c5 (patch)
tree4a092a555a120131f8b3f096d274d2e3afc5bbae /app/jobs
parent837e1ecec9798381f78b838947f8028403cb0bef (diff)
downloadgovuk-mini-environment-admin-05df9f91e9bdf39b190710ef5d80162d03dd52c5.tar
govuk-mini-environment-admin-05df9f91e9bdf39b190710ef5d80162d03dd52c5.tar.gz
Support managing the libvirt backend from the show page
Diffstat (limited to 'app/jobs')
-rw-r--r--app/jobs/backends/terraform_libvirt_job.rb (renamed from app/jobs/backends/deploy_terraform_libvirt_job.rb)18
1 files changed, 11 insertions, 7 deletions
diff --git a/app/jobs/backends/deploy_terraform_libvirt_job.rb b/app/jobs/backends/terraform_libvirt_job.rb
index 4565189..af8eba3 100644
--- a/app/jobs/backends/deploy_terraform_libvirt_job.rb
+++ b/app/jobs/backends/terraform_libvirt_job.rb
@@ -18,13 +18,17 @@
# License along with the GOV.UK Mini Environment Admin. If not, see
# <http://www.gnu.org/licenses/>.
-class Backends::DeployTerraformLibvirtJob < Que::Job
- def run(terraform_libvirt_backend_id)
- @terraform_libvirt_backend_id = terraform_libvirt_backend_id
+class Backends::TerraformLibvirtJob < Que::Job
+ def run(terraform_libvirt_backend_id, action)
+ ActiveRecord::Base.transaction do
+ @backend = Backends::TerraformLibvirt.find(
+ terraform_libvirt_backend_id
+ )
- Backends::TerraformLibvirt
- .find(terraform_libvirt_backend_id)
- .deploy_backend
+ @backend.send(action)
+
+ finish
+ end
end
def self.jobs(terraform_libvirt_backend_id)
@@ -33,6 +37,6 @@ class Backends::DeployTerraformLibvirtJob < Que::Job
job_class: name
).where(
"args->>0 = '#{terraform_libvirt_backend_id}'"
- ).to_a
+ )
end
end