Class: Maestro::Node::Base
- Inherits:
-
Object
- Object
- Maestro::Node::Base
- Includes:
- Validator
- Defined in:
- lib/maestro/node.rb
Overview
A node (i.e. a server, a machine, a vm, a device, etc…) in a cloud.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cloud ⇒ Object
readonly
the Cloud this Node is associated with.
-
#hostname ⇒ Object
the host name of this Node.
-
#ip_address ⇒ Object
the IP address of this Node.
-
#log_file ⇒ Object
readonly
String containing the fully qualified path to the log file of this Node.
-
#logger ⇒ Object
readonly
the logger of this Node.
-
#name ⇒ Object
readonly
the name of this Node.
Attributes included from Validator
Instance Method Summary collapse
-
#disable_stdout ⇒ Object
disables the stdout Outputter and only logs to this Node’s log file.
-
#enable_stdout ⇒ Object
enables the stdout Outputter.
-
#initialize(name, cloud, &block) ⇒ Base
constructor
Creates a new Node.
-
#method_missing(name, *params) ⇒ Object
:nodoc:.
Methods included from Validator
#invalidate, #valid?, #validate
Constructor Details
#initialize(name, cloud, &block) ⇒ Base
Creates a new Node
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/maestro/node.rb', line 27 def initialize(name, cloud, &block) super() raise StandardError, "Node name cannot contain spaces: #{name}" if name.is_a?(String) && !name.index(/\s/).nil? @name = name @cloud = cloud @logger = Log4r::Logger.new(Regexp::quote(@name.to_s)) outputter = Log4r::StdoutOutputter.new("#{@name.to_s}-stdout") outputter.formatter = ConsoleFormatter.new @logger.add(outputter) init_logs instance_eval(&block) if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *params) ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/maestro/node.rb', line 40 def method_missing(name, *params) #:nodoc: invalidate "Unexpected attribute: #{name}" end |
Instance Attribute Details
#cloud ⇒ Object (readonly)
the Cloud this Node is associated with
16 17 18 |
# File 'lib/maestro/node.rb', line 16 def cloud @cloud end |
#hostname ⇒ Object
the host name of this Node
18 19 20 |
# File 'lib/maestro/node.rb', line 18 def hostname @hostname end |
#ip_address ⇒ Object
the IP address of this Node
20 21 22 |
# File 'lib/maestro/node.rb', line 20 def ip_address @ip_address end |
#log_file ⇒ Object (readonly)
String containing the fully qualified path to the log file of this Node
24 25 26 |
# File 'lib/maestro/node.rb', line 24 def log_file @log_file end |
#logger ⇒ Object (readonly)
the logger of this Node
22 23 24 |
# File 'lib/maestro/node.rb', line 22 def logger @logger end |
#name ⇒ Object (readonly)
the name of this Node
14 15 16 |
# File 'lib/maestro/node.rb', line 14 def name @name end |
Instance Method Details
#disable_stdout ⇒ Object
disables the stdout Outputter and only logs to this Node’s log file
45 46 47 48 |
# File 'lib/maestro/node.rb', line 45 def disable_stdout stdoutoutputter = Log4r::Outputter["#{@name.to_s}-stdout"] stdoutoutputter.level = Log4r::OFF end |
#enable_stdout ⇒ Object
enables the stdout Outputter
51 52 53 54 |
# File 'lib/maestro/node.rb', line 51 def enable_stdout stdoutoutputter = Log4r::Outputter["#{@name.to_s}-stdout"] stdoutoutputter.level = Log4r::ALL end |