Class: VagrantPlugins::CORL::BaseAction

Inherits:
Object
  • Object
show all
Defined in:
lib/core/vagrant/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ BaseAction


Constructor / Destructor



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/core/vagrant/action.rb', line 9

def initialize(app, env)
  @app     = app
  @env     = env[:machine].env
   
  @network = nil
  @node    = nil
  @vm      = nil
  
  if @corl_config_loaded = ::CORL.vagrant_config_loaded?
    # Hackish solution to ensure our code has access to Vagrant machines.
    # This serves as a Vagrant VM manager.
    ::CORL::Vagrant.command = Command::Launcher.new([], @env)
    
    if @network = ::CORL::Vagrant::Config.load_network(env[:root_path])
      @vm   = env[:machine]
      @node = network.node(:vagrant, @vm.name) if @vm
    end
  end
end

Instance Attribute Details

#networkObject (readonly)


Property accessor / modifiers



32
33
34
# File 'lib/core/vagrant/action.rb', line 32

def network
  @network
end

#nodeObject (readonly)


Property accessor / modifiers



32
33
34
# File 'lib/core/vagrant/action.rb', line 32

def node
  @node
end

#vmObject (readonly)


Property accessor / modifiers



32
33
34
# File 'lib/core/vagrant/action.rb', line 32

def vm
  @vm
end

Instance Method Details

#call(env) ⇒ Object


Action execution



37
38
39
# File 'lib/core/vagrant/action.rb', line 37

def call(env)
  yield if block_given? && @corl_config_loaded && @network && @node
end