Class: VagrantPlugins::DelphixEngine::Action::EnableEnvironment

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/vagrant-delphix/action/enable_environment.rb

Instance Method Summary collapse

Methods included from Util

#get_config

Constructor Details

#initialize(app, env) ⇒ EnableEnvironment

Returns a new instance of EnableEnvironment.



12
13
14
15
16
17
18
19
20
# File 'lib/vagrant-delphix/action/enable_environment.rb', line 12

def initialize(app, env)
  @app = app
  @machine = env[:machine]
  @global_env = @machine.env
  @provider = @machine.provider_name
  @logger = Log4r::Logger.new('vagrant::delphix_engine::create_environment')

  @config = get_config(@machine)
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-delphix/action/enable_environment.rb', line 22

def call(env)
  # skip if plugin is not active on destroy action
  return @app.call(env) if !@config.enabled

  # set the DE url
  Delphix.url = @config.engine_url
  Delphix.debug = @config.trace

  # authenticate the connection
  Delphix.authenticate!(@config.engine_user,@config.engine_password)

  # lookup the environment
  environment = Delphix::Environment.list.lookup_by_name @config.env_name

  # Enable the environment but no sources. Blocks until completion or error.
  environment.enable.wait_for_completion if environment != nil

  @app.call(env)
end