Sha256: f9c2586ded50ad3fa1b91c78ab74363c835f2164d9bc9909584c802950343f78

Contents?: true

Size: 757 Bytes

Versions: 3

Compression:

Stored size: 757 Bytes

Contents

require "log4r"

module VagrantPlugins
  module OpenStack
    module Action
      # This deletes the running server, if there is one.
      class DeleteServer
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_openstack::action::delete_server")
        end

        def call(env)
          machine = env[:machine]
          id = machine.id || env[:openstack_compute].servers.all( :name => machine.name ).first.id

          if id
            env[:ui].info(I18n.t("vagrant_openstack.deleting_server"))
            server = env[:openstack_compute].servers.get(id)
            server.destroy
            env[:machine].id = nil
          end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-openstack-plugin-0.6.1 lib/vagrant-openstack-plugin/action/delete_server.rb
vagrant-openstack-plugin-0.6.0 lib/vagrant-openstack-plugin/action/delete_server.rb
vagrant-openstack-plugin-0.5.0 lib/vagrant-openstack-plugin/action/delete_server.rb