Sha256: 3da1b0d43fec509ac321b029c374263d8431ede816af5753454f4c51c7816a63

Contents?: true

Size: 782 Bytes

Versions: 9

Compression:

Stored size: 782 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)
          if env[:machine].id
            @logger.info "Deleting server #{env[:machine].id}..."
            env[:ui].info(I18n.t('vagrant_openstack.deleting_server'))
            env[:openstack_client].nova.delete_server(env, env[:machine].id)
            env[:openstack_client].nova.delete_keypair_if_vagrant(env, env[:machine].id)
            env[:machine].id = nil
          end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vagrant-openstack-provider-0.5.2 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.5.1 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.5.0 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.4.1 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.4.0 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.3.4.pre lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.3.3 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.3.2 lib/vagrant-openstack-provider/action/delete_server.rb
vagrant-openstack-provider-0.3.0 lib/vagrant-openstack-provider/action/delete_server.rb