Sha256: 899498455bf93c68cab4a3930d446b0ab9c17027b5e2f990f147c372a02fb66e

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

#encoding: utf-8
module Vagabond
  module Actions
    module Up
      class << self
        def included(klass)
          klass.class_eval do
            class << self
              def _up_options
                [[:auto_provision, :type => :boolean, :default => true]]
              end
            end
          end
        end
      end

      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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagabond-0.2.10 lib/vagabond/actions/up.rb