Module: BlackStack::Deployer::NodeModule

Includes:
Infrastructure::NodeModule
Included in:
Node
Defined in:
lib/blackstack-deployer.rb

Overview

inherit BlackStack::Infrastructure::NodeModule, including features of deployer.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deployment_routineObject

Returns the value of attribute deployment_routine.



33
34
35
# File 'lib/blackstack-deployer.rb', line 33

def deployment_routine
  @deployment_routine
end

#parametersObject

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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/blackstack-deployer.rb', line 45

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

Instance Method Details

#deployObject

def to_hash



75
76
77
# File 'lib/blackstack-deployer.rb', line 75

def deploy()
  BlackStack::Deployer::run_routine(self.name, self.deployment_routine);
end

#eth0_ip(interface = 'eth0') ⇒ Object

get the IP address for an interface using the ip addr command. this is a helper method for installing cockroachdb nodes.



39
40
41
42
43
# File 'lib/blackstack-deployer.rb', line 39

def eth0_ip(interface='eth0')
  a = self.ssh.exec!('ip addr show dev eth0').scan(/inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/)
  return nil if a.size == 0
  return a.last.to_s.gsub(/inet /, '')
end

#initialize(h, i_logger = nil) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/blackstack-deployer.rb', line 61

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_hashObject

def self.create(h)



69
70
71
72
73
# File 'lib/blackstack-deployer.rb', line 69

def to_hash
  h = super
  h[:deployment_routine] = self.deployment_routine
  h
end