HardwareState: Cooperation and compatibility with cla-sysrepo
IETF Hardware model exports only some components to Sysrepo. Some of
them are handled by cla-sysrepo daemon. In order for things to cooperate
smoothly, the following must be taken in mind:
1. Sysrepo does not allow two subscriptions to the same XPath. Velia
therefore subscribes to "/ietf-hardware-state:hardware/*", which is
a different path (but effectively the same). This is a workaround for
Sysrepo described in [1].
2. ietf-hardware-state stores all the components in a tree (which is
represented by a list with links to parents). Sysrepo does not (as of
now) check whether the parent is present in the tree but this can of
course change.
cla-sysrepo, which starts first, handles some of the components whose
parent is the topmost element. Therefore it must also handle the
topmost element. It indeed initialises it (it creates the component
and sets 'name', 'model' and 'class' leafs in the component -- see
ietf-hardware-state YANG model [2]).
However, velia will handle setting of some other properties (like
reading and setting of serial numbers, manufacturer,...).
[1] https://github.com/sysrepo/sysrepo/issues/2191
[2] https://tools.ietf.org/html/rfc8348#appendix-A
Change-Id: Ia790a07a830334f8fd541bae9d770faf930a40fe
diff --git a/src/Factory.cpp b/src/Factory.cpp
index 737e63d..408e06d 100644
--- a/src/Factory.cpp
+++ b/src/Factory.cpp
@@ -20,7 +20,12 @@
auto sysfsTempMII1 = std::make_shared<velia::ietf_hardware::sysfs::HWMon>("/sys/devices/platform/soc/soc:internal-regs/f1072004.mdio/mdio_bus/f1072004.mdio-mii/f1072004.mdio-mii:01/hwmon/");
auto emmc = std::make_shared<velia::ietf_hardware::sysfs::EMMC>("/sys/block/mmcblk0/device/");
- ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::StaticData("ne", std::nullopt, {{"class", "iana-hardware:chassis"}, {"mfg-name", "CESNET"s}})); // FIXME: We have an EEPROM at the PCB for storing these information, but it's so far unused. We could also use U-Boot env variables for this.
+ /* FIXME:
+ * Publish more properties for ne element. We have an EEPROM at the PCB for storing serial numbers (etc.), but it's so far unused. We could also use U-Boot env variables
+ * This will be needed for sdn-roadm-line only. So we should also parse the model from /proc/cmdline here
+ */
+ ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::StaticData("ne", std::nullopt, {{"description", "Czechlight project"s}}));
+
ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::StaticData("ne:ctrl", "ne", {{"class", "iana-hardware:module"}}));
ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::Fans("ne:fans", "ne", hwmonFans, 4));
ietfHardware->registerDataReader(velia::ietf_hardware::data_reader::SysfsTemperature("ne:ctrl:temperature-front", "ne:ctrl", sysfsTempFront, 1));
diff --git a/src/ietf-hardware/sysrepo/Sysrepo.cpp b/src/ietf-hardware/sysrepo/Sysrepo.cpp
index 088d495..313ec5d 100644
--- a/src/ietf-hardware/sysrepo/Sysrepo.cpp
+++ b/src/ietf-hardware/sysrepo/Sysrepo.cpp
@@ -13,7 +13,7 @@
namespace {
const auto IETF_HARDWARE_MODULE_NAME = "ietf-hardware-state"s;
-const auto IETF_HARDWARE_MODULE_PREFIX = "/"s + IETF_HARDWARE_MODULE_NAME + ":hardware"s;
+const auto IETF_HARDWARE_MODULE_PREFIX = "/"s + IETF_HARDWARE_MODULE_NAME + ":hardware/*"s;
void valuesToYang(const std::map<std::string, std::string>& values, std::shared_ptr<::sysrepo::Session> session, std::shared_ptr<libyang::Data_Node>& parent)
{