Class: VagrantPlugins::Vrealize::Action::ConnectVrealize

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vrealize/action/connect_vrealize.rb

Overview

This action connects to VRealize, and sticks a :vra object into the environment.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConnectVrealize

Returns a new instance of ConnectVrealize.



13
14
15
16
# File 'lib/vagrant-vrealize/action/connect_vrealize.rb', line 13

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_vrealize::action::connect_vrealize")
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-vrealize/action/connect_vrealize.rb', line 19

def call(env)
  vra = client(env)

  log_connecting(env)
  authorized = (vra.authorize!; true) rescue false

  if authorized
    store(env, vra)
  else
    env[:ui].warn("Authorisation failed")
  end
  @app.call(env)
end