Module: BlackStack::Deployer::NodeModule
Overview
inherit BlackStack::Infrastructure::NodeModule, including features of deployer.
Instance Attribute Summary collapse
-
#deployment_routine ⇒ Object
Returns the value of attribute deployment_routine.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
Class Method Summary collapse
Instance Method Summary collapse
-
#deploy ⇒ Object
def to_hash.
-
#eth0_ip ⇒ Object
get the IP address for an interface using the ip addr command.
- #initialize(h, i_logger = nil) ⇒ Object
-
#to_hash ⇒ Object
def self.create(h).
Instance Attribute Details
#deployment_routine ⇒ Object
Returns the value of attribute deployment_routine.
33 34 35 |
# File 'lib/blackstack-deployer.rb', line 33 def deployment_routine @deployment_routine end |
#parameters ⇒ Object
Returns the value of attribute parameters.
33 34 35 |
# File 'lib/blackstack-deployer.rb', line 33 def parameters @parameters end |
Class Method Details
.descriptor_errors(h) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/blackstack-deployer.rb', line 61 def self.descriptor_errors(h) errors = BlackStack::Infrastructure::NodeModule.descriptor_errors(h) # validate: does not exist any other element in @@nodes with the same value for the parameter h[:name] errors << "The parameter h[:name] is not unique" if BlackStack::Deployer.nodes.select{|n| n.name == h[:name]}.length > 0 # validate: h[:deployment_routine] is not nil errors << "The parameter h[:deployment_routine] is required" if h[:deployment_routine].nil? # validate: h[:deployment_routine] is a string errors << "The parameter h[:deployment_routine] is not a string" unless h[:deployment_routine].is_a?(String) # return list of errors errors.uniq end |
.eth0_ip(insterface) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/blackstack-deployer.rb', line 37 def self.eth0_ip(insterface) ret = nil a = `ip addr show dev #{insterface}`.scan(/inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) if a.size > 0 ret = a.last.to_s.gsub(/inet /, '') else raise "Cannot get ip address of the interface #{insterface}" end ret end |
Instance Method Details
#deploy ⇒ Object
def to_hash
91 92 93 |
# File 'lib/blackstack-deployer.rb', line 91 def deploy() BlackStack::Deployer::run_routine(self.name, self.deployment_routine); end |
#eth0_ip ⇒ Object
get the IP address for an interface using the ip addr command. this is a helper method for installing cockroachdb nodes.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/blackstack-deployer.rb', line 50 def eth0_ip() ret = nil a = self.ssh.exec!("ip addr show dev #{parameters[:laninterface]}").scan(/inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/) if a.size > 0 ret = a.last.to_s.gsub(/inet /, '') else raise "Cannot get ip address of the interface #{parameters[:laninterface]}" end ret end |
#initialize(h, i_logger = nil) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/blackstack-deployer.rb', line 77 def initialize(h, i_logger=nil) self.parameters = h errors = BlackStack::Deployer::NodeModule.descriptor_errors(h) raise "The node descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0 super(h, i_logger) self.deployment_routine = h[:deployment_routine] end |
#to_hash ⇒ Object
def self.create(h)
85 86 87 88 89 |
# File 'lib/blackstack-deployer.rb', line 85 def to_hash h = super h[:deployment_routine] = self.deployment_routine h end |