Module: Vagabond::Actions::Up

Defined in:
lib/vagabond/actions/up.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/vagabond/actions/up.rb', line 6

def included(klass)
  klass.class_eval do
    class << self
      def _up_options
        [[:auto_provision, :type => :boolean, :default => true]]
      end
    end
  end
end

Instance Method Details

#_upObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vagabond/actions/up.rb', line 17

def _up
  name_required!
  if(lxc.exists?)
    if(lxc.running?)
      ui.warn "Node already exists and is running: #{name}"
    else
      ui.info "#{ui.color('Vagabond:', :bold)} Starting node: #{ui.color(name, :green)}"
      lxc.start
      ui.info ui.color('  -> STARTED', :green)
    end
  end
  if(options[:parallel])
    # TODO: Need strategy for chains
    @threads[:up] ||= []
    t_holder = Mash.new
    @threads[:up] << t_holder.update(
      :thread => Thread.new{
        sleep(0.01)
        _create
        begin
          do_provision if options[:auto_provision]
          t_holder[:result] = true
        rescue => e
          t_holder[:result] = false
        end
      }
    )
  else
    if(!lxc.exists?)
      add_link(:create)
    elsif(!lxc.running?)
      add_link(:start)
    end
    add_link(:provision) if options[:auto_provision]
  end
end