From e710df3123c382fc735c451a048f7c51250c1a92 Mon Sep 17 00:00:00 2001 From: James Feist Date: Thu, 11 Jun 2020 13:14:11 -0700 Subject: [PATCH 1/2] Add more error types This adds ImageFailure and Busy error types to updates status in bmcweb. elog-errors.hpp is a generated file. Tested: Could create errors Signed-off-by: James Feist --- elog-errors.hpp | 269 ++++++++++++------ .../Software/Image.errors.yaml | 5 + .../Software/Image.metadata.yaml | 11 + 3 files changed, 204 insertions(+), 81 deletions(-) diff --git a/elog-errors.hpp b/elog-errors.hpp index 2888f0d..38016e1 100644 --- a/elog-errors.hpp +++ b/elog-errors.hpp @@ -2,12 +2,12 @@ // See elog-gen.py for more details #pragma once -#include -#include -#include #include #include #include +#include +#include +#include namespace sdbusplus { @@ -21,7 +21,7 @@ namespace Image { namespace Error { -struct UnTarFailure; + struct InternalFailure; } // namespace Error } // namespace Image } // namespace Software @@ -41,7 +41,7 @@ namespace Image { namespace Error { -struct InternalFailure; + struct UnTarFailure; } // namespace Error } // namespace Image } // namespace Software @@ -61,7 +61,7 @@ namespace Image { namespace Error { -struct ManifestFileFailure; + struct BusyFailure; } // namespace Error } // namespace Image } // namespace Software @@ -69,6 +69,47 @@ struct ManifestFileFailure; } // namespace xyz } // namespace sdbusplus +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Software +{ +namespace Image +{ +namespace Error +{ + struct ImageFailure; +} // namespace Error +} // namespace Image +} // namespace Software +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Software +{ +namespace Image +{ +namespace Error +{ + struct ManifestFileFailure; +} // namespace Error +} // namespace Image +} // namespace Software +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + + namespace phosphor { @@ -88,38 +129,25 @@ namespace _UnTarFailure struct PATH { - static constexpr auto str = "PATH=%s"; + /* + * We can't use -fsanitize=undefined if we declare a + * 'static constexpr auto str' member, so don't. Instead, open-code the + * mako template lookups. + */ static constexpr auto str_short = "PATH"; - using type = std::tuple, const char*>; - explicit constexpr PATH(const char* a) : _entry(entry(str, a)){}; + using type = std::tuple,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; type _entry; }; -} // namespace _UnTarFailure +} // namespace _UnTarFailure -struct UnTarFailure : public sdbusplus::exception_t +struct UnTarFailure { - static constexpr auto errName = - "xyz.openbmc_project.Software.Image.UnTarFailure"; - static constexpr auto errDesc = "An error occurred during untar."; static constexpr auto L = level::ERR; using PATH = _UnTarFailure::PATH; using metadata_types = std::tuple; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Image @@ -127,16 +155,17 @@ struct UnTarFailure : public sdbusplus::exception_t } // namespace openbmc_project } // namespace xyz + namespace details { template <> -struct map_exception_type< - sdbusplus::xyz::openbmc_project::Software::Image::Error::UnTarFailure> +struct map_exception_type { using type = xyz::openbmc_project::Software::Image::UnTarFailure; }; -} // namespace details + +} namespace xyz { @@ -151,38 +180,25 @@ namespace _ManifestFileFailure struct PATH { - static constexpr auto str = "PATH=%s"; + /* + * We can't use -fsanitize=undefined if we declare a + * 'static constexpr auto str' member, so don't. Instead, open-code the + * mako template lookups. + */ static constexpr auto str_short = "PATH"; - using type = std::tuple, const char*>; - explicit constexpr PATH(const char* a) : _entry(entry(str, a)){}; + using type = std::tuple,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; type _entry; }; -} // namespace _ManifestFileFailure +} // namespace _ManifestFileFailure -struct ManifestFileFailure : public sdbusplus::exception_t +struct ManifestFileFailure { - static constexpr auto errName = - "xyz.openbmc_project.Software.Image.ManifestFileFailure"; - static constexpr auto errDesc = "An error when reading the Manifest file."; static constexpr auto L = level::ERR; using PATH = _ManifestFileFailure::PATH; using metadata_types = std::tuple; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Image @@ -190,16 +206,17 @@ struct ManifestFileFailure : public sdbusplus::exception_t } // namespace openbmc_project } // namespace xyz + namespace details { template <> -struct map_exception_type +struct map_exception_type { using type = xyz::openbmc_project::Software::Image::ManifestFileFailure; }; -} // namespace details + +} namespace xyz { @@ -214,39 +231,76 @@ namespace _InternalFailure struct FAIL { - static constexpr auto str = "FAIL=%s"; + /* + * We can't use -fsanitize=undefined if we declare a + * 'static constexpr auto str' member, so don't. Instead, open-code the + * mako template lookups. + */ static constexpr auto str_short = "FAIL"; - using type = std::tuple, const char*>; - explicit constexpr FAIL(const char* a) : _entry(entry(str, a)){}; + using type = std::tuple,const char*>; + explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)) {}; type _entry; }; -} // namespace _InternalFailure +} // namespace _InternalFailure -struct InternalFailure : public sdbusplus::exception_t +struct InternalFailure { - static constexpr auto errName = - "xyz.openbmc_project.Software.Image.InternalFailure"; - static constexpr auto errDesc = - "The operation failed internally during processing the image."; static constexpr auto L = level::ERR; using FAIL = _InternalFailure::FAIL; using metadata_types = std::tuple; - const char* name() const noexcept - { - return errName; - } +}; + +} // namespace Image +} // namespace Software +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Software::Image::InternalFailure; +}; + +} - const char* description() const noexcept - { - return errDesc; - } +namespace xyz +{ +namespace openbmc_project +{ +namespace Software +{ +namespace Image +{ +namespace _ImageFailure +{ + +struct PATH +{ + /* + * We can't use -fsanitize=undefined if we declare a + * 'static constexpr auto str' member, so don't. Instead, open-code the + * mako template lookups. + */ + static constexpr auto str_short = "PATH"; + using type = std::tuple,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; + type _entry; +}; + +} // namespace _ImageFailure + +struct ImageFailure +{ + static constexpr auto L = level::ERR; + using PATH = _ImageFailure::PATH; + using metadata_types = std::tuple; - const char* what() const noexcept - { - return errName; - } }; } // namespace Image @@ -254,16 +308,69 @@ struct InternalFailure : public sdbusplus::exception_t } // namespace openbmc_project } // namespace xyz + namespace details { template <> -struct map_exception_type< - sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure> +struct map_exception_type { - using type = xyz::openbmc_project::Software::Image::InternalFailure; + using type = xyz::openbmc_project::Software::Image::ImageFailure; }; -} // namespace details + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Software +{ +namespace Image +{ +namespace _BusyFailure +{ + +struct PATH +{ + /* + * We can't use -fsanitize=undefined if we declare a + * 'static constexpr auto str' member, so don't. Instead, open-code the + * mako template lookups. + */ + static constexpr auto str_short = "PATH"; + using type = std::tuple,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; + type _entry; +}; + +} // namespace _BusyFailure + +struct BusyFailure +{ + static constexpr auto L = level::ERR; + using PATH = _BusyFailure::PATH; + using metadata_types = std::tuple; + +}; + +} // namespace Image +} // namespace Software +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Software::Image::BusyFailure; +}; + +} + } // namespace logging diff --git a/xyz/openbmc_project/Software/Image.errors.yaml b/xyz/openbmc_project/Software/Image.errors.yaml index 67d6c20..2b8f7ee 100644 --- a/xyz/openbmc_project/Software/Image.errors.yaml +++ b/xyz/openbmc_project/Software/Image.errors.yaml @@ -4,3 +4,8 @@ description: An error when reading the Manifest file. - name: InternalFailure description: The operation failed internally during processing the image. +- name: ImageFailure + description: An error occured processing the image. +- name: BusyFailure + description: The device is busy during the update. + diff --git a/xyz/openbmc_project/Software/Image.metadata.yaml b/xyz/openbmc_project/Software/Image.metadata.yaml index 5e749c9..65d4e1c 100644 --- a/xyz/openbmc_project/Software/Image.metadata.yaml +++ b/xyz/openbmc_project/Software/Image.metadata.yaml @@ -13,3 +13,14 @@ meta: - str: "FAIL=%s" type: string +- name: ImageFailure + level: ERR + meta: + - str: "PATH=%s" + type: string +- name: BusyFailure + level: ERR + meta: + - str: "PATH=%s" + type: string + -- 2.17.1