Class: VagrantPlugins::VSphere::Action::ConnectVSphere

Inherits:
Object
  • Object
show all
Defined in:
lib/vSphere/action/connect_vsphere.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ConnectVSphere

Returns a new instance of ConnectVSphere.



7
8
9
# File 'lib/vSphere/action/connect_vsphere.rb', line 7

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vSphere/action/connect_vsphere.rb', line 11

def call(env)
  config = env[:machine].provider_config

  begin
    env[:vSphere_connection] = RbVmomi::VIM.connect host: config.host,
                                                    user: config.user, password: config.password,
                                                    insecure: config.insecure, proxyHost: config.proxy_host,
                                                    proxyPort: config.proxy_port
    @app.call env
  rescue Errors::VSphereError
    raise
  rescue StandardError => e
    raise Errors::VSphereError.new, e.message
  end
end