Class: ZoneList

Inherits:
Command show all
Includes:
ConfigReader
Defined in:
lib/zone.rb

Constant Summary collapse

LOCAL_STATUS =
{ 1 => "-", 3 => "*", 5 => "!", 7 => "!*"}

Instance Attribute Summary

Attributes inherited from Command

#desc, #name

Instance Method Summary collapse

Methods included from ConfigReader

#config_dir, #config_file, #mkdir, #param, #user_file

Methods inherited from Command

#add_arg, #add_cmd, #add_flow, #add_flow_from_usage, #add_input, #add_option, #add_options, #command_name?, #create_args, #create_flows, #flow_passes_parse, #flow_passes_preconditions, #get_args_used, #init, #initialize, #option_help_string, #run, #show_help, #show_help_option

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#execute(args, rest) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zone.rb', line 19

def execute(args, rest)
  zone_instance = @input['zone']
  zones = Route.do.get_all_zones
  Route.do.translate_zonelist(zones)
  zones.each { | zone |
    file_name = zone_instance.local_filename(zone['DomainName'], zone['ZoneId']) 
    local_status = 0
    if File.exists? (file_name)
      local_status += 1
      if not FileUtils.compare_file(file_name, config_file(file_name))
        local_status += 2
      end
      contents = File.open(file_name).read
      local_zone = JSON.parse(File.open(file_name).read)
      if local_zone['Version'] != zone['Version']
        local_status += 4
      end
      local_status = LOCAL_STATUS[local_status]
    else
      local_status = ''
    end
    zone["DomainName"] = sprintf("%-2s %s", local_status, zone["DomainName"])
  }
  StructurePrint.new('~').structure_print(zones, "zonelist")
end