diff options
Diffstat (limited to 'app/controllers/backends/terraform_libvirt_controller.rb')
-rw-r--r-- | app/controllers/backends/terraform_libvirt_controller.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/controllers/backends/terraform_libvirt_controller.rb b/app/controllers/backends/terraform_libvirt_controller.rb index bbc5e08..1feae41 100644 --- a/app/controllers/backends/terraform_libvirt_controller.rb +++ b/app/controllers/backends/terraform_libvirt_controller.rb @@ -26,7 +26,7 @@ class Backends::TerraformLibvirtController < ApplicationController def create backend = Backends::TerraformLibvirt.create(create_params) - Backends::DeployTerraformLibvirtJob.enqueue(backend.id) + Backends::TerraformLibvirtJob.enqueue(backend.id, :deploy_backend) flash[:success] = "Backend #{backend.label} created" @@ -57,6 +57,27 @@ class Backends::TerraformLibvirtController < ApplicationController redirect_to setup_path end + def perform_action + @backend = Backends::TerraformLibvirt.find(params['id']) + + action = params.require(:commit) + + case action + when 'Destroy' + Backends::TerraformLibvirtJob.enqueue(@backend.id, :destroy_backend) + + flash[:notice] = 'Destroying the backend' + when 'Deploy' + Backends::TerraformLibvirtJob.enqueue(@backend.id, :deploy_backend) + + flash[:notice] = 'Deploying the backend' + else + flash[:error] = "Unknown action #{action}" + end + + render 'show' + end + private def create_params |