Class: Hetzner::Boot::FreeBSD
- Inherits:
-
Object
- Object
- Hetzner::Boot::FreeBSD
- Defined in:
- lib/hetzner-boot-freebsd.rb,
lib/hetzner/boot/freebsd/target.rb,
lib/hetzner/boot/freebsd/version.rb
Defined Under Namespace
Classes: Target
Constant Summary collapse
- VERSION =
'0.0.2'
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#api ⇒ Object
Returns the value of attribute api.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#targets ⇒ Object
Returns the value of attribute targets.
Instance Method Summary collapse
- #<<(param) ⇒ Object
- #add_target(param) ⇒ Object
- #bootstrap!(options = {}) ⇒ Object
- #bootstrap_one_target!(target) ⇒ Object
-
#initialize(options = {}) ⇒ FreeBSD
constructor
A new instance of FreeBSD.
Constructor Details
#initialize(options = {}) ⇒ FreeBSD
Returns a new instance of FreeBSD.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hetzner-boot-freebsd.rb', line 16 def initialize( = {}) @targets = [] @actions = %w( remove_from_local_known_hosts enable_rescue_mode reset wait_for_ssh_down wait_for_ssh_up update_local_known_hosts verify_installation ) @api = [:api] @logger = [:logger] || Logger.new(STDOUT) end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
13 14 15 |
# File 'lib/hetzner-boot-freebsd.rb', line 13 def actions @actions end |
#api ⇒ Object
Returns the value of attribute api.
12 13 14 |
# File 'lib/hetzner-boot-freebsd.rb', line 12 def api @api end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/hetzner-boot-freebsd.rb', line 14 def logger @logger end |
#targets ⇒ Object
Returns the value of attribute targets.
11 12 13 |
# File 'lib/hetzner-boot-freebsd.rb', line 11 def targets @targets end |
Instance Method Details
#<<(param) ⇒ Object
39 40 41 |
# File 'lib/hetzner-boot-freebsd.rb', line 39 def <<(param) add_target param end |
#add_target(param) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/hetzner-boot-freebsd.rb', line 31 def add_target(param) if param.is_a? Hetzner::Boot::FreeBSD::Target @targets << param else @targets << (Hetzner::Boot::FreeBSD::Target.new param) end end |
#bootstrap!(options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/hetzner-boot-freebsd.rb', line 43 def bootstrap!( = {}) @targets.each do |target| target.use_api @api target.use_logger @logger bootstrap_one_target! target end end |
#bootstrap_one_target!(target) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hetzner-boot-freebsd.rb', line 51 def bootstrap_one_target!(target) actions = (target.actions || @actions) actions.each_with_index do |action, index| loghack = "\b" * 24 # remove: "[bootstrap_one_target!] ".length target.logger.info "#{loghack}[#{action}] #{sprintf "%-20s", "START"}" d = Benchmark.realtime do target.send action end target.logger.info "#{loghack}[#{action}] FINISHED in #{sprintf "%.5f",d} seconds" end rescue => e target.logger.error "Something bad happened unexpectedly: #{e.class} => #{e.}" end |