meta-ampere: refine code structure
Restructure Ampere recipes to better reuse existing resource for
multiple platforms later.
Tested:
1. Compile without error.
2. Run regression test for related features without error.
Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I5d034d21273b99be651f20dc2eb5549c1092f079
diff --git a/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils.bb b/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils.bb
new file mode 100644
index 0000000..5d308dc
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils.bb
@@ -0,0 +1,16 @@
+SUMMARY = "Ampere Platform Environment Definitions"
+DESCRIPTION = "Ampere Platform Environment Definitions"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+SRC_URI = " \
+ file://ampere_add_redfishevent.sh \
+ "
+
+RDEPENDS:${PN} = "bash"
+
+do_install() {
+ install -d ${D}/usr/sbin
+ install -m 0755 ${WORKDIR}/ampere_add_redfishevent.sh ${D}/${sbindir}/
+}
diff --git a/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils/ampere_add_redfishevent.sh b/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils/ampere_add_redfishevent.sh
new file mode 100644
index 0000000..1170c6a
--- /dev/null
+++ b/meta-ampere/meta-common/recipes-ampere/platform/ampere-utils/ampere_add_redfishevent.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+registry=$1
+msgarg=$2
+
+if [ -z "$registry" ]; then
+ echo "Usage:"
+ echo " $0 <redfish registry> <argument>"
+ exit
+fi
+
+# Check if logger-systemd exist. Do nothing if not exists
+if ! command -v logger-systemd;
+then
+ echo "logger-systemd does not exist. Skip log events for $registry $msgarg"
+ exit
+fi
+
+# Log events
+logger-systemd --journald << EOF
+MESSAGE=
+PRIORITY=
+SEVERITY=
+REDFISH_MESSAGE_ID=$registry
+REDFISH_MESSAGE_ARGS=$msgarg
+EOF