diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2016-11-21 16:06:53 -0600 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2016-11-23 06:18:56 -0600 |
commit | e8596300873a33e220d275e714e8ae2fb9aaf42a (patch) | |
tree | 36232c1a6fb2b9c7c663eae7e1b119659b2a0f9e /tools | |
parent | f1f2cfa943d08f270976e42e1f386fd34e723003 (diff) | |
download | phosphor-logging-e8596300873a33e220d275e714e8ae2fb9aaf42a.tar.gz phosphor-logging-e8596300873a33e220d275e714e8ae2fb9aaf42a.zip |
Break elog yaml files into two pieces
This is the final piece to supporting the phosphor-dbus-interfaces
design where the errors are defined in one yaml file and
their corresponding meta data is defined within another file.
Change-Id: Idd2e18c1fd82fccb1298a2570a484deb382954f8
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/elog-gen.py | 33 | ||||
-rw-r--r-- | tools/example/xyz/openbmc_project/Example/Elog.errors.yaml | 16 | ||||
-rw-r--r-- | tools/example/xyz/openbmc_project/Example/Elog.logging.yaml | 19 |
3 files changed, 46 insertions, 22 deletions
diff --git a/tools/elog-gen.py b/tools/elog-gen.py index 7234e8b..430f991 100755 --- a/tools/elog-gen.py +++ b/tools/elog-gen.py @@ -19,7 +19,8 @@ import sys import os -def gen_elog_hpp(i_rootdir, i_elog_yaml, i_input_mako, i_output_hpp): +def gen_elog_hpp(i_rootdir, i_elog_yaml, i_elog_meta_yaml, + i_input_mako, i_output_hpp): r""" Read the input yaml file, grab the relevant data and call the mako template to generate the header file. @@ -27,6 +28,7 @@ def gen_elog_hpp(i_rootdir, i_elog_yaml, i_input_mako, i_output_hpp): Description of arguments: i_rootdir base directory to search for yaml files i_elog_yaml yaml file describing the error logs + i_elog_meta_yaml yaml file describing the meta data for elogs i_input_mako input mako template file to use i_output_hpp header file to output the generated code to """ @@ -39,16 +41,26 @@ def gen_elog_hpp(i_rootdir, i_elog_yaml, i_input_mako, i_output_hpp): meta_data = dict() # The meta data info (type, format) # see elog.yaml for reference - ifile = yaml.safe_load(open("/".join((i_rootdir,i_elog_yaml)))) + ifile = yaml.safe_load(open("/".join((i_rootdir, i_elog_yaml)))) + mfile = yaml.safe_load(open(i_elog_meta_yaml)) err_count = 0 for i in ifile: + match = None + # Find the corresponding meta data for this entry + for m in mfile: + if m['name'] == i['name']: + match = m + break + if (match is None): + print "Error - Did not find meta data for " + i['name'] + exit(1) # Grab the main error and it's info errors[err_count] = i['name'] error_msg[i['name']] = i['description'] - error_lvl[i['name']] = i['level'] + error_lvl[i['name']] = match['level'] tmp_meta = [] # grab all the meta data fields and info - for j in i['meta']: + for j in match['meta']: str_short = j['str'].split('=')[0] tmp_meta.append(str_short) meta_data[str_short] = {} @@ -101,19 +113,28 @@ def main(i_args): (options, args) = parser.parse_args(i_args) # Verify the input yaml file - yaml_path = "/".join((options.rootdir,options.elog_yaml)) + yaml_path = "/".join((options.rootdir, options.elog_yaml)) if (not (os.path.isfile(yaml_path))): print "Can not find input yaml file " + yaml_path exit(1) + # the meta data will be defined in a similar file name where we replace + # <Interface>.errors.yaml with <Interface>.logging.yaml + meta_file = options.elog_yaml.replace("errors", "logging") + meta_file = "/".join((options.rootdir, meta_file)) + if (not (os.path.isfile(meta_file))): + print "Can not find meta yaml file " + meta_file + exit(1) + # Verify the input mako file - template_path = "/".join((options.templatedir,options.elog_mako)) + template_path = "/".join((options.templatedir, options.elog_mako)) if (not (os.path.isfile(template_path))): print "Can not find input template file " + template_path exit(1) gen_elog_hpp(options.rootdir, options.elog_yaml, + meta_file, template_path, options.output_hpp) diff --git a/tools/example/xyz/openbmc_project/Example/Elog.errors.yaml b/tools/example/xyz/openbmc_project/Example/Elog.errors.yaml index 9ae2028..1ec9997 100644 --- a/tools/example/xyz/openbmc_project/Example/Elog.errors.yaml +++ b/tools/example/xyz/openbmc_project/Example/Elog.errors.yaml @@ -1,21 +1,5 @@ - name: TestErrorOne description: this is test error one - level: INFO - meta: - - str: "ERRNUM=0x%.4X" - type: int - - str: FILE_PATH=%s - type: const char * - - str: FILE_NAME=%s - type: const char * - name: TestErrorTwo description: This is test error two - level: ERR - meta: - - str: DEV_ADDR=0x%.8X - type: int - - str: DEV_ID=%u - type: int - - str: DEV_NAME=%s - type: const char* diff --git a/tools/example/xyz/openbmc_project/Example/Elog.logging.yaml b/tools/example/xyz/openbmc_project/Example/Elog.logging.yaml new file mode 100644 index 0000000..9ca4a4e --- /dev/null +++ b/tools/example/xyz/openbmc_project/Example/Elog.logging.yaml @@ -0,0 +1,19 @@ +- name: TestErrorOne + level: INFO + meta: + - str: "ERRNUM=0x%.4X" + type: int + - str: FILE_PATH=%s + type: const char* + - str: FILE_NAME=%s + type: const char* + +- name: TestErrorTwo + level: ERR + meta: + - str: DEV_ADDR=0x%.8X + type: int + - str: DEV_ID=%u + type: int + - str: DEV_NAME=%s + type: const char* |