Sha256: e8f90afa4086b0f9bd8007dd25fe3918ab2bee22da6d57124ad47e30bdcc3c9f
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'vagrant/util/retryable' require 'timeout' require 'vmfloaty/pooler' require "log4r" module VagrantPlugins module Vmpooler module Action # This deletes the running server, if there is one. class DeleteServer include Vagrant::Util::Retryable def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_vmpooler::action::delete_server") end def call(env) machine = env[:machine] id = machine.id if id provider_config = machine.provider_config token = provider_config.token url = provider_config.url verbose = provider_config.verbose env[:ui].info(I18n.t("vagrant_vmpooler.deleting_server")) os = [] os.push(id) response_body = Pooler.delete(verbose, url, os, token) if response_body[id]['ok'] == false # the only way this can happen is if the vm existed at one point # but got deleted from vmpoolers redis db. We should probably # still delete it from vagrants internal state if this is true env[:ui].info(I18n.t("vagrant_vmpooler.not_deleted")) else env[:ui].info(I18n.t("vagrant_vmpooler.deleted")) env[:machine].id = nil end else env[:ui].info(I18n.t("vagrant_vmpooler.not_created")) end @app.call(env) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-vmpooler-0.1.7 | lib/vagrant-vmpooler/action/delete_server.rb |
vagrant-vmpooler-0.1.6 | lib/vagrant-vmpooler/action/delete_server.rb |