Class: Vm::Watcher::VmObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/vm-watcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(observable, script) ⇒ VmObserver

Returns a new instance of VmObserver.



9
10
11
12
13
14
15
16
17
# File 'lib/vm-watcher.rb', line 9

def initialize(observable, script)
  observable.add_observer(self, :provision)

  @script = script

  @vagrant = Vagrant::Environment.new(:ui_class => Vagrant::UI::Basic)
  @vagrant.cli('up', '--no-provision')
  @vagrant.primary_vm.channel.ready?
end

Instance Method Details

#provisionObject



19
20
21
22
23
# File 'lib/vm-watcher.rb', line 19

def provision
  @vagrant.primary_vm.channel.execute(@script, false) do |type, data|
    @vagrant.primary_vm.ui.info(data.to_s, :prefix => false, :new_line => false, :channel => :out)
  end
end