Class: Maestro::Node::Configurable

Inherits:
Base
  • Object
show all
Defined in:
lib/maestro/node.rb

Overview

A node which is able to be SSH’d into to be configured by Maestro with Chef

Direct Known Subclasses

Aws::Ec2

Constant Summary collapse

DEFAULT_SSH_USER =
"root"

Instance Attribute Summary collapse

Attributes inherited from Base

#cloud, #hostname, #ip_address, #log_file, #logger, #name

Attributes included from Validator

#valid, #validation_errors

Instance Method Summary collapse

Methods inherited from Base

#disable_stdout, #enable_stdout, #method_missing

Methods included from Validator

#invalidate, #valid?, #validate

Constructor Details

#initialize(name, cloud, &block) ⇒ Configurable

Creates a new Configurable Node



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/maestro/node.rb', line 104

def initialize(name, cloud, &block)
  super(name, cloud, &block)
  @json_filename = cloud.name.to_s + "-" + name.to_s + ".json"
  @json = "{ \"run_list\": ["
  if !@roles.nil? && !@roles.empty?
    @roles.each {|role_name| @json = @json + "\"role[#{role_name.to_s}]\", "}
    @json.chop! if @json =~ /\s$/
    @json.chop! if @json =~ /,$/
  end
  @json = @json + "]"
  if !@cookbook_attributes.nil?
    @cookbook_attributes.gsub!(/(\n|\n\r)\s{0,}/, ' ')
    @cookbook_attributes.strip!
    @cookbook_attributes.chop! if @cookbook_attributes =~ /,$/
    @cookbook_attributes.slice!(0) if @cookbook_attributes =~ /^\{/
    @json = @json + ", "
    @json = @json + @cookbook_attributes
    @json.chop! if @json =~ /\s$/
  end
  @json = @json + " }"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Maestro::Node::Base

Instance Attribute Details

#jsonObject

the contents of this Configurable Node’s Chef Node JSON file



101
102
103
# File 'lib/maestro/node.rb', line 101

def json
  @json
end

#json_filenameObject

the file name of this Configurable Node’s Chef Node JSON file



99
100
101
# File 'lib/maestro/node.rb', line 99

def json_filename
  @json_filename
end