Class: Pione::Log::DomainLog

Inherits:
Object
  • Object
show all
Includes:
Sys
Defined in:
lib/pione/log/domain-log.rb

Overview

DomainLog is a domain log that records domain inputs and parameters.

Constant Summary collapse

FILENAME =
".domain.log"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler) ⇒ DomainLog

Returns a new instance of DomainLog.

Parameters:

  • handler (RuleHandler::BasicHandler)

    rule handler



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pione/log/domain-log.rb', line 21

def initialize(handler)
  @domain_location = handler.domain_location
  @record = {
    :system_name => Uname.sysname,
    :system_nodename => Uname.nodename,
    :system_machine => Uname.machine,
    :system_version => Uname.version,
    :system_release => Uname.release,
    :params => handler.param_set.textize,
    :inputs => inputs_string(handler.inputs),
    :domain => handler.domain_id,
    :domain_location => @domain_location.uri.to_s,
    :dry_run => handler.dry_run.to_s
  }
  if handler.respond_to?(:working_directory)
    @record[:working_directory] = handler.working_directory.location.uri.to_s
  end
end

Instance Attribute Details

#domain_locationLocation::BasicLocation (readonly)

Returns domain's location.

Returns:



13
14
15
# File 'lib/pione/log/domain-log.rb', line 13

def domain_location
  @domain_location
end

#recordHash{String => String} (readonly)

Returns record table.

Returns:

  • (Hash{String => String})

    record table



17
18
19
# File 'lib/pione/log/domain-log.rb', line 17

def record
  @record
end

Instance Method Details

#savevoid

This method returns an undefined value.

Save domain information file.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pione/log/domain-log.rb', line 43

def save
  domain_info_location = @domain_location + FILENAME
  text = "== %s\n\n" % Time.now
  text << @record.map{|key, val| "- %s: %s" % [key,val]}.join("\n")
  text << "\n\n"
  if domain_info_location.exist?
    domain_info_location.append(text)
  else
    domain_info_location.create(text)
  end
end