Class: TtlAuto::Exe

Inherits:
Object
  • Object
show all
Includes:
Constant, Log
Defined in:
lib/ttlauto/exe.rb

Constant Summary

Constants included from Log

Log::LOG

Constants included from Constant

Constant::OUT, Constant::PEM, Constant::TEMPLATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#log_debug, #log_error, #log_info

Constructor Details

#initialize(file, templates = nil) ⇒ Exe

Returns a new instance of Exe.



7
8
9
10
11
12
13
14
15
# File 'lib/ttlauto/exe.rb', line 7

def initialize file, templates=nil
  @yaml = TtlAuto::Yaml.new
  @yaml.read file
  @yaml.set_categories
  unless templates.nil?
    yml = TtlAuto::Yaml.new
    @command_templates = yml.read templates
  end
end

Instance Attribute Details

#command_templatesObject (readonly)

Returns the value of attribute command_templates.



6
7
8
# File 'lib/ttlauto/exe.rb', line 6

def command_templates
  @command_templates
end

#yamlObject (readonly)

Returns the value of attribute yaml.



6
7
8
# File 'lib/ttlauto/exe.rb', line 6

def yaml
  @yaml
end

Instance Method Details

#pingObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ttlauto/exe.rb', line 23

def ping
  return_code = 0
  server_list.each do |server|
    tcp = TtlAuto::Ping.new( server )
    if tcp.scan?
      log_info "#{server[:server]}:#{server[:port]} is enable to connect"
    else
      log_error "!!! #{server[:server]}:#{server[:port]} is NOT enable to connect !!!"
      return_code = 1
    end
  end
  return_code
end

#runObject



17
18
19
20
21
# File 'lib/ttlauto/exe.rb', line 17

def run
  @yaml.records.each do |record|
    run_each_parents record
  end
end