Sha256: 1568aede04a889ad5eecb66aa9a39577fe14e7f64b952478dd3e68ae6767c034
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require "log4r" module VagrantPlugins module ProfitBricks module Action # This deletes the running server, if there is one. class DeleteServer def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_profitbricks::action::delete_server") end def call(env) compute = env[:profitbricks_compute] server_id = env[:machine].id server = begin compute.servers.get(server_id) rescue nil end if server.nil? @logger.warn "Unable to find server #{server_id}..." env[:ui].warn(I18n.t('vagrant_profitbricks.errors.server_not_found')) env[:machine].id = nil else @logger.info "Deleting server #{server_id}..." env[:ui].info(I18n.t("vagrant_profitbricks.deleting_server")) server.attached_volumes.each do |vol_info| volume = compute.volumes.get(vol_info['id']) volume.delete if volume end server.delete env[:machine].id = nil @app.call(env) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-profitbricks-1.0.0 | lib/vagrant-profitbricks/action/delete_server.rb |