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.



44
45
46
# File 'lib/blackstack-deployer.rb', line 44

def deployment_routine
  @deployment_routine
end

#parametersObject

Returns the value of attribute parameters.



44
45
46
# File 'lib/blackstack-deployer.rb', line 44

def parameters
  @parameters
end

Class Method Details

.descriptor_errors(h) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/blackstack-deployer.rb', line 72

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



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

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

#deployObject

def to_hash



102
103
104
# File 'lib/blackstack-deployer.rb', line 102

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

#eth0_ipObject

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



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

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



88
89
90
91
92
93
94
# File 'lib/blackstack-deployer.rb', line 88

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)



96
97
98
99
100
# File 'lib/blackstack-deployer.rb', line 96

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