aboutsummaryrefslogtreecommitdiff
path: root/external/fwts
diff options
context:
space:
mode:
authorJack Miller <jack@codezen.org>2016-11-08 13:52:54 -0600
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-12-14 17:21:16 +1100
commit3e6e795cd5e8728f5fd7437b6aeea27b6adb3ed4 (patch)
tree0bcf90174d3a1b6008dc5848e9c76a70da18cd2e /external/fwts
parent02a7c2cf6b2af393e66610bc102da5101736f8be (diff)
downloadskiboot-3e6e795cd5e8728f5fd7437b6aeea27b6adb3ed4.zip
skiboot-3e6e795cd5e8728f5fd7437b6aeea27b6adb3ed4.tar.gz
skiboot-3e6e795cd5e8728f5fd7437b6aeea27b6adb3ed4.tar.bz2
external/fwts: Add FWTS olog merge script
A script to merge olog error definitions from multiple skiboot versions into a single olog JSON file. Will prompt when conflicting patterns are found to update the pattern, or add both. Signed-off-by: Jack Miller <jack@codezen.org> [stewart@linux.vnet.ibm.com: add copyright notice] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external/fwts')
-rwxr-xr-xexternal/fwts/merge-fwts-olog115
1 files changed, 115 insertions, 0 deletions
diff --git a/external/fwts/merge-fwts-olog b/external/fwts/merge-fwts-olog
new file mode 100755
index 0000000..2a4b290
--- /dev/null
+++ b/external/fwts/merge-fwts-olog
@@ -0,0 +1,115 @@
+#!/usr/bin/env python2
+#
+# Copyright 2016 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import json
+import sys
+
+json_params = {
+ 'indent': 1,
+ 'sort_keys': True,
+ 'separators': (',', ': '),
+}
+
+def get_input():
+ while True:
+ resp = raw_input("Update pattern to match both? (y/n): ")
+ if resp in [ "y", "Y" ]:
+ break
+ elif resp in [ "n", "N" ]:
+ print "New entry will be added."
+ return False
+ else:
+ print "???"
+ continue
+
+ return raw_input("New pattern: ")
+
+def main():
+ if len(sys.argv) != 4:
+ print("USAGE: merge.py old_olog new_olog output")
+ sys.exit(-1)
+
+ old_olog = sys.argv[1]
+ cur_olog = sys.argv[2]
+ out_olog = sys.argv[3]
+
+ try:
+ old_file = open(old_olog, "r")
+ old_json = json.load(old_file)
+ old_file.close()
+ except Exception as e:
+ print("Failed to parse old olog: %s" % e)
+ sys.exit(-1)
+
+ try:
+ cur_file = open(cur_olog, "r")
+ cur_json = json.load(cur_file)
+ cur_file.close()
+ except Exception as e:
+ print("Failed to parse new olog: %s" % e)
+ sys.exit(-1)
+
+ try:
+ out_file = open(out_olog, "w")
+ except Exception as e:
+ print("Failed to open output file: %s" % e)
+ sys.exit(-1)
+
+ cur_patterns = cur_json["olog_error_warning_patterns"]
+ old_patterns = old_json["olog_error_warning_patterns"]
+
+ # Match current patterns to old definitions, detect when pattern is
+ # different.
+
+ for cp in cur_patterns:
+ for op in old_patterns:
+ if cp["label"] != op["label"]:
+ continue
+
+ if cp["pattern"] != op["pattern"]:
+ print "Pattern update detected."
+ print "Label: %s" % cp["label"]
+ print ""
+ print "Cur Pattern: %s" % cp["pattern"]
+ print "New Pattern: %s" % op["pattern"]
+ print ""
+
+ user_pattern = get_input()
+
+ if user_pattern == False:
+ continue
+
+ cp["pattern"] = user_pattern
+
+ op["found"] = True
+ break
+
+ # Take any old patterns that are no longer current and move them over
+
+ for op in old_patterns:
+ if "found" in op:
+ continue
+
+ cur_patterns.append(op)
+
+ json.dump(cur_json, out_file, **json_params)
+ out_file.close()
+
+ print("OK")
+
+if __name__ == "__main__":
+ main()