Sha256: 886e0ef65b6786a91344e7f82361923d2c7a2669dea50fa6ae78a19dda365493

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

require "log4r"

module VagrantPlugins
  module GANETI
    module Action
      # "unlink" vagrant and the managed server
      class RemoveInstance

        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_ganeti::action::remove_instance")
        end

        def call(env)
	  server = env[:ganeti_compute]
	  createjob = server.instance_terminate
          # set machine id to nil
          env[:machine].id = nil

	  env[:ui].info("Removing the instance #{server.info['instance_name']}")
	  while true
		status =  server.is_job_ready(createjob)

		if  status == "error"
			env[:ui].info("Error Removing instance")
			break
		elsif status == "running"
			#Waiting for the message to succeed
			sleep(15)
		elsif status  == "success"
	    		env[:ui].info("Instance #{server.info['instance_name']} Sucessfully Removed")
			break
		end
	
            end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-ganeti-0.1.1 lib/vagrant-ganeti/action/remove_instance.rb