Class: DreamOps::BaseInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/dream-ops/init/base.rb

Direct Known Subclasses

SoloInitializer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initiailizer_method(name) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/dream-ops/init/base.rb', line 9

def initiailizer_method(name)
  class_eval <<-EOH, __FILE__, __LINE__ + 1
    def #{name}(*args)
      raise AbstractFunction,
        "##{name} must be implemented on \#{self.class.name}!"
    end
  EOH
end

Instance Method Details

#__bail_with_fatal_error(ex) ⇒ Object



42
43
44
45
# File 'lib/dream-ops/init/base.rb', line 42

def __bail_with_fatal_error(ex)
  raise ex
  Thread.exit
end

#analyze(*args) ⇒ Object

Create a initiailizer method for the declaration



34
# File 'lib/dream-ops/init/base.rb', line 34

initiailizer_method :analyze

#init(*args, dryrun) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dream-ops/init/base.rb', line 47

def init(*args, dryrun)
  targets = analyze(args)

  # Update cookbooks if needed and deploy to all targets
  deploy_success = true
  deploy_threads = []
  targets.each do |target|
    deploy_threads << Thread.new { init_target(target, dryrun) }
  end
  deploy_threads.each do |t|
    begin
      t.join
    rescue DreamOps::DreamOpsError
      DreamOps.ui.error "#{$!}"
      deploy_success = deploy_success && false
    end
  end

  # If ANY deploy threads failed, exit with failure
  exit(1) if !deploy_success
end

#init_target(*args) ⇒ Object

Create a initiailizer method for the declaration



40
# File 'lib/dream-ops/init/base.rb', line 40

initiailizer_method :init_target