Class: FrameworkData
- Inherits:
-
Object
- Object
- FrameworkData
- Defined in:
- lib/Framework/framework_data.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#hmc_directory ⇒ Object
Returns the value of attribute hmc_directory.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#vios_datafile_extension ⇒ Object
Returns the value of attribute vios_datafile_extension.
-
#vios_subdirectory ⇒ Object
Returns the value of attribute vios_subdirectory.
Instance Method Summary collapse
- #create_dir(dirname) ⇒ Object
- #create_structure(base_dir) ⇒ Object
-
#initialize(directory, date, config_file = nil) ⇒ FrameworkData
constructor
A new instance of FrameworkData.
- #search_frame(sys_to_find) ⇒ Object
- #search_lpar(lpar_to_find, data_to_find = 'none') ⇒ Object
- #vios_data(lparname, command) ⇒ Object
Constructor Details
#initialize(directory, date, config_file = nil) ⇒ FrameworkData
Returns a new instance of FrameworkData.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/Framework/framework_data.rb', line 23 def initialize(directory, date, config_file = nil) @directory = directory @date = date @verbose = $VERBOSE.nil? || $VERBOSE == false ? 0 : $VERBOSE if config_file.nil? @vios_datafile_extension = "txt" @hmc_directory = '/hmc' @vios_subdirectory = '/vios' else = YAML.load_file(config_file) @vios_datafile_extension = [:vios_datafile_extension] @hmc_directory = [:hmc_subdirectory] @vios_subdirectory = [:vios_subdirectory] end end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
16 17 18 |
# File 'lib/Framework/framework_data.rb', line 16 def date @date end |
#directory ⇒ Object
Returns the value of attribute directory.
15 16 17 |
# File 'lib/Framework/framework_data.rb', line 15 def directory @directory end |
#hmc_directory ⇒ Object
Returns the value of attribute hmc_directory.
20 21 22 |
# File 'lib/Framework/framework_data.rb', line 20 def hmc_directory @hmc_directory end |
#verbose ⇒ Object
Returns the value of attribute verbose.
17 18 19 |
# File 'lib/Framework/framework_data.rb', line 17 def verbose @verbose end |
#vios_datafile_extension ⇒ Object
Returns the value of attribute vios_datafile_extension.
21 22 23 |
# File 'lib/Framework/framework_data.rb', line 21 def vios_datafile_extension @vios_datafile_extension end |
#vios_subdirectory ⇒ Object
Returns the value of attribute vios_subdirectory.
19 20 21 |
# File 'lib/Framework/framework_data.rb', line 19 def vios_subdirectory @vios_subdirectory end |
Instance Method Details
#create_dir(dirname) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/Framework/framework_data.rb', line 48 def create_dir(dirname) if Dir.exist?(dirname) puts ">DEBUG: dirname exist: #{dirname}, ignoring..." if @verbose > 0 else puts ">DEBUG: creating dirname: #{dirname}" if @verbose > 0 Dir.mkdir(dirname) end end |
#create_structure(base_dir) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/Framework/framework_data.rb', line 41 def create_structure(base_dir) create_dir(base_dir) create_dir(base_dir + '/' + @date) create_dir(base_dir + '/' + @date + @hmc_directory) create_dir(base_dir + '/' + @date + @vios_subdirectory) end |
#search_frame(sys_to_find) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/Framework/framework_data.rb', line 57 def search_frame(sys_to_find) systems = [] puts ">DEBUG(1): searching data about frame #{sys_to_find}" if @verbose > 0 hmc_dir_base = @directory + '/' + @date + '/' + @hmc_directory + '/' puts ">DEBUG(1): checking directory #{hmc_dir_base}" if @verbose > 0 Dir.chdir(hmc_dir_base) Dir.glob('*').select do |hmc| puts "DEBUG(1): Checking HMC #{hmc} (dir: #{hmc_dir_base}/#{hmc}" if @verbose > 0 next unless File.directory?(hmc) hmc_data = HmcDir.new(hmc_dir_base + hmc) hmc_data.verbose = @verbose hmc_data.create_list_of_frames hmc_data.sys.each do |sys_name| sys = System.new(sys_name, hmc) sys.parse_raw_data(hmc_data.file_content(sys_name, 'lpar_info')) systems.push(sys) if sys.name == sys_to_find or sys_to_find == 'ALL' end end systems end |
#search_lpar(lpar_to_find, data_to_find = 'none') ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/Framework/framework_data.rb', line 82 def search_lpar(lpar_to_find, data_to_find = 'none') lpars = [] puts ">DEBUG: verbose: #{@verbose}" if @verbose > 0 puts '>DEBUG: searching data about frame on HMCs' if @verbose > 0 hmc_dir_base = @directory + '/' + @date + '/' + @hmc_directory + '/' puts ">DEBUG: going to directory #{hmc_dir_base}" if @verbose > 0 unless File.directory?(hmc_dir_base) puts ">DEBUG: Directory #{hmc_dir_base} doesn't exist!" if @verbose > 0 return [] end Dir.chdir(hmc_dir_base) Dir.glob('*').select do |hmc| puts ">DEBUG: Checking HMC #{hmc} and directory #{hmc_dir_base}/#{hmc} " if @verbose > 0 unless File.directory? hmc puts ">DEBUG: Directory #{hmc} doesn't exist!" if @verbose > 0 next end hmc_data = HmcDir.new(hmc_dir_base + hmc) hmc_data.verbose = @verbose hmc_data.create_list_of_frames hmc_data.sys.each do |sys_name| sys = System.new(sys_name, hmc) sys.parse_raw_data(hmc_data.file_content(sys_name, 'lpar_info')) lpars.push(sys.getLparByName(lpar_to_find)) if sys.lpars_by_name.include?(lpar_to_find) end end puts '>DEBUG: checking if data from both HMCs are equal (not implemented yet)' if @verbose > 0 # @TODO: create code to compare real data and profiles from all HMCs puts '>DEBUG: searching data from VIOSes' if @verbose > 0 lpars.each_index do |index| puts ">DEBUG:Possible VIOSes :" + lpars[index].vioses.sort.join(',') if @verbose > 0 lpar_id = lpars[index].lpar_id lpars[index].vioses.each do |vios| filename = "#{directory}/#{@vios_subdirectory}/#{@date}/#{vios}.#{vios_datafile_extension}" puts ">DEBUG: VIOS #{vios} filename #{filename}" if @verbose > 0 unless File.exist?(filename) puts "DEBUG: VIOS #{vios}, file doesn't exist! (is down? not accessible etc?)..." next end data_file = DataFile.new(filename) npiv_all = Lsmap_npiv.new(data_file.find("lsmap -all -npiv"), vios, lpars[index].sys) vhost_all = Lsmap.new(data_file.find("lsmap -all"), vios, lpars[index].sys) lpar_vscsi = vhost_all.mapping_for_lpar(lpar_id) lpar_npiv = npiv_all.mapping_for_lpar_id(lpar_id) puts ">DEBUG: Putting data from VIOSes about NPIV: #{lpar_npiv.count} vchosts" if @verbose > 0 lpars[index].vscsi.concat(lpar_vscsi) puts ">DEBUG: Putting data from VIOSes about VSCSI: #{lpar_vscsi.count} vhosts" if @verbose > 0 lpars[index].npiv.concat(lpar_npiv) end end lpars end |
#vios_data(lparname, command) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/Framework/framework_data.rb', line 147 def vios_data(lparname, command) path = Pathname.new("#{directory}/#{@date}/#{@vios_subdirectory}/#{lparname}.#{vios_datafile_extension}") path.cleanpath filename = path.realpath puts ">DEBUG: Data will be taken from file #{filename}" if @verbose > 0 unless File.exist?(filename) puts ">DEBUG: This file >#{filename}< doesn't exist! " if @verbose > 0 return nil end data_file = DataFile.new(filename) data_file.find(command) end |