Class: Provisioner::Command::Base
- Inherits:
-
Object
- Object
- Provisioner::Command::Base
- Defined in:
- lib/provisioner/command/base.rb
Instance Attribute Summary collapse
-
#distro ⇒ Object
Returns the value of attribute distro.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#flavor ⇒ Object
Returns the value of attribute flavor.
-
#host_number ⇒ Object
Returns the value of attribute host_number.
-
#host_prefix ⇒ Object
Returns the value of attribute host_prefix.
-
#host_presuffix ⇒ Object
Returns the value of attribute host_presuffix.
-
#host_sequence ⇒ Object
Returns the value of attribute host_sequence.
-
#host_suffix ⇒ Object
Returns the value of attribute host_suffix.
-
#image ⇒ Object
Returns the value of attribute image.
-
#log_dir ⇒ Object
Returns the value of attribute log_dir.
-
#networks ⇒ Object
Returns the value of attribute networks.
-
#options ⇒ Object
Returns the value of attribute options.
-
#run_list ⇒ Object
Returns the value of attribute run_list.
-
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(template_configuration, options = {}) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #shell_commands ⇒ Object
- #shell_commands_for(host_number) ⇒ Object
Constructor Details
#initialize(template_configuration, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/provisioner/command/base.rb', line 9 def initialize(template_configuration, = {}) @options = @host_number = [:number] template_configuration.each_pair do |key, value| self.send("#{key}=", value) end @ssh_user = [:ssh_user] if [:ssh_user] raise "Log path is required" unless @log_dir Dir.mkdir(log_dir) unless Dir.exists?(log_dir) end |
Instance Attribute Details
#distro ⇒ Object
Returns the value of attribute distro.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def distro @distro end |
#environment ⇒ Object
Returns the value of attribute environment.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def environment @environment end |
#flavor ⇒ Object
Returns the value of attribute flavor.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def flavor @flavor end |
#host_number ⇒ Object
Returns the value of attribute host_number.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def host_number @host_number end |
#host_prefix ⇒ Object
Returns the value of attribute host_prefix.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def host_prefix @host_prefix end |
#host_presuffix ⇒ Object
Returns the value of attribute host_presuffix.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def host_presuffix @host_presuffix end |
#host_sequence ⇒ Object
Returns the value of attribute host_sequence.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def host_sequence @host_sequence end |
#host_suffix ⇒ Object
Returns the value of attribute host_suffix.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def host_suffix @host_suffix end |
#image ⇒ Object
Returns the value of attribute image.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def image @image end |
#log_dir ⇒ Object
Returns the value of attribute log_dir.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def log_dir @log_dir end |
#networks ⇒ Object
Returns the value of attribute networks.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def networks @networks end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def @options end |
#run_list ⇒ Object
Returns the value of attribute run_list.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def run_list @run_list end |
#ssh_user ⇒ Object
Returns the value of attribute ssh_user.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def ssh_user @ssh_user end |
#tags ⇒ Object
Returns the value of attribute tags.
4 5 6 |
# File 'lib/provisioner/command/base.rb', line 4 def @tags end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 |
# File 'lib/provisioner/command/base.rb', line 20 def run shell_commands.each do |command| shellout command sleep 0.5 end end |
#shell_commands ⇒ Object
31 32 33 34 35 |
# File 'lib/provisioner/command/base.rb', line 31 def shell_commands host_numbers.map do |i| shell_commands_for(i.to_i) end.flatten end |
#shell_commands_for(host_number) ⇒ Object
27 28 29 |
# File 'lib/provisioner/command/base.rb', line 27 def shell_commands_for host_number raise 'Abstract method, implement in subclasses' end |