Class: Lssvcenevents_entry
- Inherits:
-
Object
- Object
- Lssvcenevents_entry
- Defined in:
- lib/HMC/lssvcenevents_entry.rb
Instance Attribute Summary collapse
-
#action_plan ⇒ Object
Returns the value of attribute action_plan.
-
#analyzing_hmc ⇒ Object
Returns the value of attribute analyzing_hmc.
-
#analyzing_mtms ⇒ Object
Returns the value of attribute analyzing_mtms.
-
#approval_state ⇒ Object
Returns the value of attribute approval_state.
-
#callhome_intended ⇒ Object
Returns the value of attribute callhome_intended.
-
#created_time ⇒ Object
Returns the value of attribute created_time.
-
#duplicate_count ⇒ Object
Returns the value of attribute duplicate_count.
-
#enclosure_mtms ⇒ Object
Returns the value of attribute enclosure_mtms.
-
#event_severity ⇒ Object
Returns the value of attribute event_severity.
-
#event_status ⇒ Object
Returns the value of attribute event_status.
-
#event_time ⇒ Object
Returns the value of attribute event_time.
-
#failing_mtms ⇒ Object
Returns the value of attribute failing_mtms.
-
#files ⇒ Object
Returns the value of attribute files.
-
#firmware_fix ⇒ Object
Returns the value of attribute firmware_fix.
-
#first_time ⇒ Object
Returns the value of attribute first_time.
-
#fru_details ⇒ Object
Returns the value of attribute fru_details.
-
#hmc_name ⇒ Object
Returns the value of attribute hmc_name.
-
#hmcs_name ⇒ Object
Returns the value of attribute hmcs_name.
-
#last_time ⇒ Object
Returns the value of attribute last_time.
-
#machine_model ⇒ Object
Returns the value of attribute machine_model.
-
#machine_type ⇒ Object
Returns the value of attribute machine_type.
-
#pmh_num ⇒ Object
readonly
Returns the value of attribute pmh_num.
-
#pmh_num_nice ⇒ Object
Returns the value of attribute pmh_num_nice.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#problem_num ⇒ Object
Returns the value of attribute problem_num.
-
#ref_code_extn ⇒ Object
Returns the value of attribute ref_code_extn.
-
#refcode ⇒ Object
Returns the value of attribute refcode.
-
#reporting_mtms ⇒ Object
Returns the value of attribute reporting_mtms.
-
#reporting_name ⇒ Object
Returns the value of attribute reporting_name.
-
#resolution_status ⇒ Object
Returns the value of attribute resolution_status.
-
#serial ⇒ Object
Returns the value of attribute serial.
-
#status ⇒ Object
Returns the value of attribute status.
-
#sys_mtms ⇒ Object
Returns the value of attribute sys_mtms.
-
#sys_name ⇒ Object
Returns the value of attribute sys_name.
-
#sys_refcode ⇒ Object
Returns the value of attribute sys_refcode.
-
#text ⇒ Object
Returns the value of attribute text.
-
#ticket_number ⇒ Object
Returns the value of attribute ticket_number.
Instance Method Summary collapse
- #compare(other, cols = nil) ⇒ Object
- #hmc_add(hmc_name) ⇒ Object
-
#initialize(string = nil, hmc_name = nil) ⇒ Lssvcenevents_entry
constructor
A new instance of Lssvcenevents_entry.
- #mhp_num=(string) ⇒ Object
- #mtms_to_serial_type_model(string) ⇒ Object
- #parse(string) ⇒ Object
- #parse_from_csv(header_line, value_line, headers_map = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(string = nil, hmc_name = nil) ⇒ Lssvcenevents_entry
Returns a new instance of Lssvcenevents_entry.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 50 def initialize(string = nil, hmc_name = nil) @hmcs_name = [] unless hmc_name.nil? @hmc_name = hmc_name @hmcs_name.push(hmc_name) end @problem_num = nil @pmh_num = nil @pmh_num_nice = nil @refcode = nil @status = nil @first_time = nil @last_time = nil @sys_name = nil @sys_mtms = nil @enclosure_mtms = nil @firmware_fix = nil @text = nil @created_time = nil @reporting_name = nil @reporting_mtms = nil @failing_mtms = nil @analyzing_hmc = nil @event_time = nil @files = nil @approval_state = nil @callhome_intended = nil @duplicate_count = nil @event_severity = nil @analyzing_mtms = nil @ref_code_extn = nil @sys_refcode = nil @fru_details = nil @serial = nil @machine_type = nil @machine_model = nil @priority = nil @ticket_number = nil @event_status = nil @resolution_status = nil @action_plan = nil @_allowed_cols = %w[problem_num pmh_num refcode status first_time last_time sys_name sys_mtms enclosure_mtms firmware_fix text created_time reporting_name reporting_mtms failing_mtms analyzing_hmc event_time files approval_state callhome_intended duplicate_count event_severity analyzing_mtms ref_code_extn sys_refcode fru_details ] @_allowed_cols_csv = @_allowed_cols + %w[serial machine_type machine_model priority ticket_number event_status resolution_status action_plan] parse(string) unless string.nil? end |
Instance Attribute Details
#action_plan ⇒ Object
Returns the value of attribute action_plan.
47 48 49 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 47 def action_plan @action_plan end |
#analyzing_hmc ⇒ Object
Returns the value of attribute analyzing_hmc.
27 28 29 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 27 def analyzing_hmc @analyzing_hmc end |
#analyzing_mtms ⇒ Object
Returns the value of attribute analyzing_mtms.
34 35 36 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 34 def analyzing_mtms @analyzing_mtms end |
#approval_state ⇒ Object
Returns the value of attribute approval_state.
30 31 32 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 30 def approval_state @approval_state end |
#callhome_intended ⇒ Object
Returns the value of attribute callhome_intended.
31 32 33 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 31 def callhome_intended @callhome_intended end |
#created_time ⇒ Object
Returns the value of attribute created_time.
23 24 25 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 23 def created_time @created_time end |
#duplicate_count ⇒ Object
Returns the value of attribute duplicate_count.
32 33 34 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 32 def duplicate_count @duplicate_count end |
#enclosure_mtms ⇒ Object
Returns the value of attribute enclosure_mtms.
20 21 22 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 20 def enclosure_mtms @enclosure_mtms end |
#event_severity ⇒ Object
Returns the value of attribute event_severity.
33 34 35 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 33 def event_severity @event_severity end |
#event_status ⇒ Object
Returns the value of attribute event_status.
45 46 47 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 45 def event_status @event_status end |
#event_time ⇒ Object
Returns the value of attribute event_time.
28 29 30 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 28 def event_time @event_time end |
#failing_mtms ⇒ Object
Returns the value of attribute failing_mtms.
26 27 28 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 26 def failing_mtms @failing_mtms end |
#files ⇒ Object
Returns the value of attribute files.
29 30 31 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 29 def files @files end |
#firmware_fix ⇒ Object
Returns the value of attribute firmware_fix.
21 22 23 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 21 def firmware_fix @firmware_fix end |
#first_time ⇒ Object
Returns the value of attribute first_time.
16 17 18 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 16 def first_time @first_time end |
#fru_details ⇒ Object
Returns the value of attribute fru_details.
37 38 39 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 37 def fru_details @fru_details end |
#hmc_name ⇒ Object
Returns the value of attribute hmc_name.
9 10 11 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 9 def hmc_name @hmc_name end |
#hmcs_name ⇒ Object
Returns the value of attribute hmcs_name.
8 9 10 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 8 def hmcs_name @hmcs_name end |
#last_time ⇒ Object
Returns the value of attribute last_time.
17 18 19 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 17 def last_time @last_time end |
#machine_model ⇒ Object
Returns the value of attribute machine_model.
41 42 43 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 41 def machine_model @machine_model end |
#machine_type ⇒ Object
Returns the value of attribute machine_type.
40 41 42 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 40 def machine_type @machine_type end |
#pmh_num ⇒ Object (readonly)
Returns the value of attribute pmh_num.
13 14 15 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 13 def pmh_num @pmh_num end |
#pmh_num_nice ⇒ Object
Returns the value of attribute pmh_num_nice.
10 11 12 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 10 def pmh_num_nice @pmh_num_nice end |
#priority ⇒ Object
Returns the value of attribute priority.
43 44 45 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 43 def priority @priority end |
#problem_num ⇒ Object
Returns the value of attribute problem_num.
12 13 14 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 12 def problem_num @problem_num end |
#ref_code_extn ⇒ Object
Returns the value of attribute ref_code_extn.
35 36 37 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 35 def ref_code_extn @ref_code_extn end |
#refcode ⇒ Object
Returns the value of attribute refcode.
14 15 16 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 14 def refcode @refcode end |
#reporting_mtms ⇒ Object
Returns the value of attribute reporting_mtms.
25 26 27 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 25 def reporting_mtms @reporting_mtms end |
#reporting_name ⇒ Object
Returns the value of attribute reporting_name.
24 25 26 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 24 def reporting_name @reporting_name end |
#resolution_status ⇒ Object
Returns the value of attribute resolution_status.
46 47 48 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 46 def resolution_status @resolution_status end |
#serial ⇒ Object
Returns the value of attribute serial.
39 40 41 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 39 def serial @serial end |
#status ⇒ Object
Returns the value of attribute status.
15 16 17 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 15 def status @status end |
#sys_mtms ⇒ Object
Returns the value of attribute sys_mtms.
19 20 21 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 19 def sys_mtms @sys_mtms end |
#sys_name ⇒ Object
Returns the value of attribute sys_name.
18 19 20 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 18 def sys_name @sys_name end |
#sys_refcode ⇒ Object
Returns the value of attribute sys_refcode.
36 37 38 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 36 def sys_refcode @sys_refcode end |
#text ⇒ Object
Returns the value of attribute text.
22 23 24 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 22 def text @text end |
#ticket_number ⇒ Object
Returns the value of attribute ticket_number.
44 45 46 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 44 def ticket_number @ticket_number end |
Instance Method Details
#compare(other, cols = nil) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 139 def compare(other, cols = nil) verbose = 0 # in case of network issue (problem with connection from second or third HMC), # sys_name and reporting_name would be the IP address cols = @_allowed_cols - %w[analyzing_hmc sys_name reporting_name] if cols.nil? cols.each do |cal| unless instance_variable_get("@#{cal}") == other.instance_variable_get("@#{cal}") if verbose > 0 print "self: #{cal}:" + instance_variable_get("@#{cal}") + "\n" print "other: #{cal}:" + other.instance_variable_get("@#{cal}") + "\n" print "----\n" end return false end end true end |
#hmc_add(hmc_name) ⇒ Object
176 177 178 179 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 176 def hmc_add(hmc_name) hmc_name.strip! @hmcs_name.push(hmc_name) unless @hmcs_name.include?(hmc_name) end |
#mhp_num=(string) ⇒ Object
134 135 136 137 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 134 def mhp_num=(string) @mhp_num = string @pmh_num_nice = @pmh_num.tr(',', ' ') end |
#mtms_to_serial_type_model(string) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 160 def mtms_to_serial_type_model(string) unless string.nil? regexp = %r{(\d{4})-(\w{3})\/(\w{7})} matched = regexp.match(string) if matched @serial = matched[3] @machine_type = matched[1] @machine_model = matched[2] else pp string raise 'wrong regexp' end end end |
#parse(string) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 117 def parse(string) HmcString.parse(string).each_pair do |key, value| if @_allowed_cols.include?(key) instance_variable_set("@#{key}", value) if key == 'failing_mtms' mtms_to_serial_type_model(value) end elsif key =~ /^fru_details/ @fru_details = key + value else pp key pp value raise 'wrong key' end end end |
#parse_from_csv(header_line, value_line, headers_map = nil) ⇒ Object
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 181 def parse_from_csv(header_line, value_line, headers_map = nil) headers = header_line.split(';') values = value_line.split(';') headers.map!{ |x| x.strip } if headers_map.nil? headers_map = { 'HMC' => 'hmcs_name', 'event time' => 'last_time', 'ID' => 'problem_num', 'PHM' => 'pmh_num', 'refcode' => 'refcode', 'system serial' => 'serial', 'sys name' => 'sys_name', 'failing mtms' => 'failing_mtms', 'machine type' => 'machine_type', 'model' => 'machine_model', 'priority' => 'priority', 'ticket number' => 'ticket_number', 'event status' => 'status', 'Resolution Status' => 'resolution_status', 'text' => 'text', 'action plan' => 'action_plan' } end (0..(headers.count - 1)).each do |i| if headers_map.key?(headers[i]) header_name = headers_map[headers[i]] else raise "wrong column name in headers_map >#{headers[i]}<" end if header_name == 'hmcs_name' values[i].split(',').each do |hmc_name| hmc_add(hmc_name) end elsif header_name == 'phm_num' instance_variable_set("@#{header_name}", values[i]) unless values[i] == '' else instance_variable_set("@#{header_name}", values[i]) end end true # useful for running debug end |
#to_s ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/HMC/lssvcenevents_entry.rb', line 107 def to_s string = '' @_allowed_cols.each do |col| string += "#{col}=" + instance_variable_get("@#{col}") + ',' end string end |