Class: VagrantPlugins::VCenter::Action::DisconnectvCenter

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vcenter/action/disconnect_vcenter.rb

Overview

This class disconnects the vagrant-vcenter provider from vCenter.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ DisconnectvCenter

Returns a new instance of DisconnectvCenter.



6
7
8
9
10
# File 'lib/vagrant-vcenter/action/disconnect_vcenter.rb', line 6

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new(
            'vagrant_vcenter::action::disconnect_vcenter')
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-vcenter/action/disconnect_vcenter.rb', line 12

def call(env)
  @logger.info('Disconnecting from vCenter ...')

  config = env[:machine].provider_config

  if !config.vcenter_cnx
    @logger.info('Session not open, impossible to disconnect')
  else
    config.vcenter_cnx.close
    @logger.info('Succesfully disconnected from vCenter...')
  end

  @app.call env
end