Sha256: ef4e9359e2c7ed82143ca1f67d922bff835244fcd24d5f42d90e3f8c265a787d
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
require "log4r" require "json" module VagrantPlugins module GQ module Action # This terminates the running instance. class TerminateInstance def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_gq::action::terminate_instance") end def call(env) server = env[:gq_compute].servers.get(env[:machine].id) # Release the elastic IP ip_file = env[:machine].data_dir.join('elastic_ip') if ip_file.file? release_address(env,ip_file.read) ip_file.delete end # Destroy the server and remove the tracking ID env[:ui].info(I18n.t("vagrant_gq.terminating")) server.destroy env[:machine].id = nil @app.call(env) end # Release an elastic IP address def release_address(env,eip) h = JSON.parse(eip) # Use association_id and allocation_id for VPC, use public IP for EC2 if h['association_id'] env[:gq_compute].disassociate_address(nil,h['association_id']) env[:gq_compute].release_address(h['allocation_id']) else env[:gq_compute].disassociate_address(h['public_ip']) env[:gq_compute].release_address(h['public_ip']) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vagrant-gq-0.1.2 | lib/vagrant-gq/action/terminate_instance.rb |
vagrant-gq-0.1.1 | lib/vagrant-gq/action/terminate_instance.rb |
vagrant-gq-0.1.0 | lib/vagrant-gq/action/terminate_instance.rb |