Include namespaces in the phosphor-logging exception name
Currently the phosphor-logging exception name is for example
Device for an error file located in xyz/openbmc_project/Error/Callout/.
It should instead be named xyz.openbmc_project.Error.Callout.Device
following the naming structure of the sdbusplus++ tool
to differentiate it from other Device error exceptions.
With the full name, the namespaces can be determined, so there's no
need to pass the namespace parameter to the template that generates
the elog-errors.hpp. As with the name, follow the namespace
structure of the sdbusplus exception object.
Closes openbmc/phosphor-logging#2
Change-Id: I960d759d90aa18fd43211034ebd6009859113ee7
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/tools/elog-gen.py b/tools/elog-gen.py
index 360ae11..0452489 100755
--- a/tools/elog-gen.py
+++ b/tools/elog-gen.py
@@ -56,17 +56,23 @@
return True
+# Return the yaml files with their directory structure plus the file name
+# without the yaml extension, which will be used to set the namespaces.
+# Ex: file xyz/openbmc_project/Error/Callout/Device.errors.yaml
+# will have namespce xyz/openbmc_project/Error/Callout/Device
def get_error_yaml_files(i_yaml_dir, i_test_dir):
yaml_files = dict()
if i_yaml_dir != "None":
for root, dirs, files in os.walk(i_yaml_dir):
for files in filter(lambda file:
file.endswith('.errors.yaml'), files):
- splitdir = root.split(i_yaml_dir)[1]
+ splitdir = root.split(i_yaml_dir)[1] + "/" + files[:-12]
+ if splitdir.startswith("/"):
+ splitdir = splitdir[1:]
yaml_files[(os.path.join(root, files))] = splitdir
for root, dirs, files in os.walk(i_test_dir):
for files in filter(lambda file: file.endswith('.errors.yaml'), files):
- splitdir = root.split(i_test_dir)[1]
+ splitdir = root.split(i_test_dir)[1] + "/" + files[:-12]
yaml_files[(os.path.join(root, files))] = splitdir
return yaml_files
@@ -114,7 +120,6 @@
meta = dict() # The meta data names associated (ERRNO, FILE_NAME, ...)
meta_data = dict() # The meta data info (type, format)
parents = dict()
- namespace = dict()
error_yamls = get_error_yaml_files(i_yaml_dir, i_test_dir)
@@ -145,8 +150,7 @@
error_lvl,
meta,
meta_data,
- parents,
- namespace))
+ parents))
if(not check_error_inheritance(errors, parents)):
print("Error - failed to validate error inheritance")
@@ -162,7 +166,7 @@
f.write(template.render(
errors=errors, error_msg=error_msg,
error_lvl=error_lvl, meta=meta,
- meta_data=meta_data, error_namespace=namespace,
+ meta_data=meta_data,
parents=parents))
f.close()
@@ -181,8 +185,7 @@
i_namespace namespace data
o_elog_data error metadata
"""
- errors, error_msg, error_lvl, meta, meta_data, parents, namespace = \
- o_elog_data
+ errors, error_msg, error_lvl, meta, meta_data, parents = o_elog_data
ifile = yaml.safe_load(open(i_elog_yaml))
mfile = yaml.safe_load(open(i_elog_meta_yaml))
for i in mfile:
@@ -196,19 +199,19 @@
print("Error - Did not find meta data for " + i['name'])
exit(1)
# Grab the main error and it's info
- errors.append(i['name'])
+ fullname = i_namespace.replace('/', '.') + ('.') + i['name']
+ errors.append(fullname)
parent = None
if('inherits' in i):
- # xyz.openbmc.Foo, we need Foo
# Get 0th inherited error (current support - single inheritance)
- parent = i['inherits'][0].split(".").pop()
- parents[i['name']] = parent
- error_msg[i['name']] = match['description']
+ parent = i['inherits'][0]
+ parents[fullname] = parent
+ error_msg[fullname] = match['description']
try:
- error_lvl[i['name']] = i['level']
+ error_lvl[fullname] = i['level']
except:
print ("No level found for: " + i['name'] + ", using INFO")
- error_lvl[i['name']] = "INFO"
+ error_lvl[fullname] = "INFO"
tmp_meta = []
# grab all the meta data fields and info
for j in i['meta']:
@@ -218,8 +221,7 @@
meta_data[str_short]['str'] = j['str']
meta_data[str_short]['str_short'] = str_short
meta_data[str_short]['type'] = get_cpp_type(j['type'])
- meta[i['name']] = tmp_meta
- namespace[i['name']] = i_namespace
+ meta[fullname] = tmp_meta
# Debug
# for i in errors: