Class: Upman::Service::Node
- Inherits:
-
Object
- Object
- Upman::Service::Node
- Defined in:
- lib/upman/services/node.rb
Instance Attribute Summary collapse
-
#node_config ⇒ Object
Returns the value of attribute node_config.
Instance Method Summary collapse
- #generate_node_data ⇒ Object
- #get_node_uuuid ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #update_node_data ⇒ Object
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
11 12 13 |
# File 'lib/upman/services/node.rb', line 11 def initialize @node_config = 'node.yml' end |
Instance Attribute Details
#node_config ⇒ Object
Returns the value of attribute node_config.
9 10 11 |
# File 'lib/upman/services/node.rb', line 9 def node_config @node_config end |
Instance Method Details
#generate_node_data ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/upman/services/node.rb', line 21 def generate_node_data unless File.exist? @node_config data = { hostname: Socket.gethostbyname(Socket.gethostname).first, uuid: SecureRandom.uuid, } File.write(@node_config, data.to_yaml) end update_node_data end |
#get_node_uuuid ⇒ Object
16 17 18 19 |
# File 'lib/upman/services/node.rb', line 16 def get_node_uuuid data = YAML::load_file(@node_config).deep_symbolize_keys data[:uuid] end |
#update_node_data ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/upman/services/node.rb', line 32 def update_node_data unless File.exist? @node_config generate_node_data end data = YAML::load_file(@node_config).deep_symbolize_keys data.merge!( operatingsystem: Facter['operatingsystem'].value, rubyversion: Facter['rubyversion'].value, operatingsystemrelease: Facter['operatingsystemrelease'].value, last_sync: DateTime.now ) File.write(@node_config, data.to_yaml) data end |