From 05df9f91e9bdf39b190710ef5d80162d03dd52c5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 23 Jun 2018 11:16:26 +0100 Subject: Support managing the libvirt backend from the show page --- app/jobs/backends/deploy_terraform_libvirt_job.rb | 38 -------------------- app/jobs/backends/terraform_libvirt_job.rb | 42 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 38 deletions(-) delete mode 100644 app/jobs/backends/deploy_terraform_libvirt_job.rb create mode 100644 app/jobs/backends/terraform_libvirt_job.rb (limited to 'app/jobs') diff --git a/app/jobs/backends/deploy_terraform_libvirt_job.rb b/app/jobs/backends/deploy_terraform_libvirt_job.rb deleted file mode 100644 index 4565189..0000000 --- a/app/jobs/backends/deploy_terraform_libvirt_job.rb +++ /dev/null @@ -1,38 +0,0 @@ -# GOV.UK Mini Environment Admin -# Copyright © 2018 Christopher Baines -# -# This file is part of the GOV.UK Mini Environment Admin. -# -# The GOV.UK Mini Environment Admin is free software: you can -# redistribute it and/or modify it under the terms of the GNU Affero -# General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later -# version. -# -# The GOV.UK Mini Environment Admin is distributed in the hope that it -# will be useful, but WITHOUT ANY WARRANTY; without even the implied -# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with the GOV.UK Mini Environment Admin. If not, see -# . - -class Backends::DeployTerraformLibvirtJob < Que::Job - def run(terraform_libvirt_backend_id) - @terraform_libvirt_backend_id = terraform_libvirt_backend_id - - Backends::TerraformLibvirt - .find(terraform_libvirt_backend_id) - .deploy_backend - end - - def self.jobs(terraform_libvirt_backend_id) - QueJob - .where( - job_class: name - ).where( - "args->>0 = '#{terraform_libvirt_backend_id}'" - ).to_a - end -end diff --git a/app/jobs/backends/terraform_libvirt_job.rb b/app/jobs/backends/terraform_libvirt_job.rb new file mode 100644 index 0000000..af8eba3 --- /dev/null +++ b/app/jobs/backends/terraform_libvirt_job.rb @@ -0,0 +1,42 @@ +# GOV.UK Mini Environment Admin +# Copyright © 2018 Christopher Baines +# +# This file is part of the GOV.UK Mini Environment Admin. +# +# The GOV.UK Mini Environment Admin is free software: you can +# redistribute it and/or modify it under the terms of the GNU Affero +# General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later +# version. +# +# The GOV.UK Mini Environment Admin is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with the GOV.UK Mini Environment Admin. If not, see +# . + +class Backends::TerraformLibvirtJob < Que::Job + def run(terraform_libvirt_backend_id, action) + ActiveRecord::Base.transaction do + @backend = Backends::TerraformLibvirt.find( + terraform_libvirt_backend_id + ) + + @backend.send(action) + + finish + end + end + + def self.jobs(terraform_libvirt_backend_id) + QueJob + .where( + job_class: name + ).where( + "args->>0 = '#{terraform_libvirt_backend_id}'" + ) + end +end -- cgit v1.2.3