bbfdm: add dm-service daemon

This commit is contained in:
Amin Ben Romdhane 2024-09-06 14:37:54 +02:00
parent fc37507afb
commit 31e6887d42
7 changed files with 65 additions and 103 deletions

View file

@ -1,7 +1,7 @@
if PACKAGE_libbbfdm
config BBF_VENDOR_LIST
string "Vendor List"
default "iopsys"
if PACKAGE_bbfdmd
config BBF_VENDOR_EXTENSION
bool "Enable Vendor Extension"
default y
config BBF_VENDOR_PREFIX
string "Vendor Prefix"

View file

@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bbfdm
PKG_VERSION:=1.11.5
PKG_VERSION:=1.12.0
USE_LOCAL:=0
ifneq ($(USE_LOCAL),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
PKG_SOURCE_VERSION:=ebdb414e098228ca4fb2c266eb58dee8e4b228a0
PKG_SOURCE_VERSION:=9a6dfdfe3e8a6e0964b2b8006453c8278fbf9467
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@ -40,21 +40,20 @@ define Package/libbbfdm-ubus
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api
endef
define Package/libbbfdm
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Library for broadband forum data model support
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +libopenssl
MENU:=1
endef
define Package/bbfdmd
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Datamodel ubus backend
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libbbfdm-api +libbbfdm-ubus +libbbfdm +jq +bbf_configmngr
TITLE:=Datamodel ubus backend to expose core tree
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +libopenssl +libbbfdm-ubus +bbf_configmngr
endef
define Package/dm-service
SECTION:=utils
CATEGORY:=Utilities
SUBMENU:=TRx69
TITLE:=Datamodel ubus backend to expose micro-service tree
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json +libjson-c +libbbfdm-api +libbbfdm-ubus +jq +bbf_configmngr
endef
define Package/bbf_configmngr
@ -63,11 +62,10 @@ define Package/bbf_configmngr
SUBMENU:=TRx69
TITLE:= BBF Config Manager
DEPENDS:=+libuci +libubox +libubus +libblobmsg-json
MENU:=1
endef
define Package/libbbfdm/config
source "$(SOURCE)/Config_bbfdm.in"
define Package/bbfdmd/config
source "$(SOURCE)/Config_bbfdmd.in"
endef
define Package/bbf_configmngr/config
@ -82,8 +80,12 @@ define Package/libbbfdm-ubus/description
Library contains the APIs to expose data model over ubus
endef
define Package/libbbfdm/description
Library contains the data model tree, It includes basic TR181 nodes.
define Package/bbfdmd/description
Daemon to expose Datamodel core tree
endef
define Package/dm-service/description
Daemon to expose Datamodel micro-service tree
endef
define Package/bbf_configmngr/description
@ -97,17 +99,9 @@ endef
endif
CMAKE_OPTIONS += \
-DBBF_TR181=ON
CMAKE_OPTIONS += \
-DBBF_VENDOR_LIST:String="$(CONFIG_BBF_VENDOR_LIST)" \
-DBBF_VENDOR_PREFIX:String="$(CONFIG_BBF_VENDOR_PREFIX)" \
-DBBF_MAX_OBJECT_INSTANCES:Integer=$(CONFIG_BBF_MAX_OBJECT_INSTANCES)
ifeq ($(CONFIG_PACKAGE_bbfdmd),y)
CMAKE_OPTIONS += \
-DBBF_MAX_OBJECT_INSTANCES:Integer=$(CONFIG_BBF_MAX_OBJECT_INSTANCES) \
-DBBFDMD_MAX_MSG_LEN:Integer=10485760
endif
define Package/libbbfdm-api/install
$(INSTALL_DIR) $(1)/lib
@ -129,45 +123,43 @@ define Package/libbbfdm-ubus/install
$(CP) $(PKG_BUILD_DIR)/libbbfdm-ubus/libbbfdm-ubus.so $(1)/lib/
endef
define Package/libbbfdm/install
define Package/bbfdmd/install
$(INSTALL_DIR) $(1)/etc/bbfdm/dmmap
$(INSTALL_DIR) $(1)/usr/share/bbfdm
$(INSTALL_DIR) $(1)/usr/share/bbfdm/
$(CP) $(PKG_BUILD_DIR)/libbbfdm/libbbfdm.so $(1)/usr/share/bbfdm/libbbfdm.so
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/etc/config/bbfdm $(1)/etc/config/bbfdm
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bbfdmd/ubus/bbfdmd $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/bbfdmd $(1)/etc/init.d/bbfdmd
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/85-bbfdm-sysctl $(1)/etc/hotplug.d/iface/85-bbfdm-sysctl
$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/bbf $(1)/lib/upgrade/keep.d/bbf
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/etc/uci-defaults/91-fix-bbfdmd-enabled-option $(1)/etc/uci-defaults/
ifeq ($(findstring iopsys,$(CONFIG_BBF_VENDOR_LIST)),iopsys)
$(BBFDM_INSTALL_CORE_PLUGIN) $(PKG_BUILD_DIR)/libbbfdm/dmtree/vendor/iopsys/libbbfdm_iopsys_ext.so $(1)
ifeq ($(CONFIG_BBF_VENDOR_EXTENSION),y)
$(BBFDM_INSTALL_CORE_PLUGIN) $(PKG_BUILD_DIR)/libbbfdm/vendor/vendor.json $(1)
endif
$(INSTALL_DIR) $(1)/usr/share/bbfdm/scripts/
$(INSTALL_DIR) $(1)/usr/share/bbfdm/scripts
$(CP) $(PKG_BUILD_DIR)/utilities/files/usr/share/bbfdm/scripts/bbf_activate_handler.sh $(1)/usr/share/bbfdm/scripts/
$(CP) $(PKG_BUILD_DIR)/utilities/files/usr/share/bbfdm/scripts/bbf_check_idle.sh $(1)/usr/share/bbfdm/scripts/
endef
define Package/libbbfdm/prerm
#!/bin/sh
rm -rf /etc/bbfdm/dmmap/*
exit 0
endef
define Package/bbfdmd/install
define Package/dm-service/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/bbfdm
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bbfdmd/ubus/bbfdmd $(1)/usr/sbin/
$(INSTALL_DATA) ./files/etc/bbfdm/input.json $(1)/etc/bbfdm/
$(INSTALL_BIN) ./files/etc/init.d/bbfdmd $(1)/etc/init.d/bbfdmd
$(INSTALL_BIN) ./files/etc/init.d/bbfdm.services $(1)/etc/init.d/
$(INSTALL_CONF) ./files/etc/config/bbfdm $(1)/etc/config/bbfdm
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/85-bbfdm-sysctl $(1)/etc/hotplug.d/iface/85-bbfdm-sysctl
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/dm-service/dm-service $(1)/usr/sbin/
endef
define Package/bbf_configmngr/install
@ -183,6 +175,12 @@ ifeq ($(CONFIG_BBF_CONFIGMNGR_SCRIPT_BACKEND),y)
endif
endef
define Package/bbfdmd/prerm
#!/bin/sh
rm -rf /etc/bbfdm/dmmap/*
exit 0
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_DIR) $(1)/usr/include
@ -198,5 +196,5 @@ endef
$(eval $(call BuildPackage,bbf_configmngr))
$(eval $(call BuildPackage,libbbfdm-api))
$(eval $(call BuildPackage,libbbfdm-ubus))
$(eval $(call BuildPackage,libbbfdm))
$(eval $(call BuildPackage,bbfdmd))
$(eval $(call BuildPackage,dm-service))

View file

@ -1,28 +0,0 @@
{
"daemon": {
"config": {
},
"input": {
"type": "DotSo",
"name": "/usr/share/bbfdm/libbbfdm.so",
"plugin_dir": "/usr/share/bbfdm/plugins"
},
"output": {
"type": "UBUS",
"name": "bbfdm"
}
},
"cli": {
"config": {
"proto": "both",
"instance_mode": 0
},
"input": {
"type": "UBUS",
"name": "bbfdm"
},
"output": {
"type": "CLI"
}
}
}

View file

@ -1,7 +1,7 @@
config bbfdmd 'bbfdmd'
option enable '1'
option debug '0'
option loglevel '3'
option subprocess_level '2'
config micro_services 'micro_services'
option enable '1'

View file

@ -4,7 +4,7 @@ START=40
STOP=8
USE_PROCD=1
PROG=/usr/sbin/bbfdmd
PROG=/usr/sbin/dm-service
BBFDM_MICROSERVICE_DIR="/etc/bbfdm/micro_services"
@ -23,12 +23,12 @@ validate_bbfdm_micro_service_section()
_add_microservice()
{
local name path
local name path loglevel
local enable enable_core
# Check enable from micro-service
path="${1}"
enable_core="${3}"
enable_core="${2}"
name="$(basename ${path})"
name="${name//.json}"
@ -38,11 +38,14 @@ _add_microservice()
log "datamodel micro-service ${name} not enabled"
return 0
fi
loglevel="$(jq -r '.daemon.config.loglevel//3' ${path})"
procd_open_instance "${name}"
procd_set_param command ${PROG}
procd_append_param command -m "${name}"
procd_append_param command -l "${loglevel}"
if [ "${enable_core}" -eq "1" ]; then
procd_set_param limits core="unlimited"

View file

@ -6,9 +6,6 @@ STOP=10
USE_PROCD=1
PROG=/usr/sbin/bbfdmd
BBFDM_JSON_INPUT="/etc/bbfdm/input.json"
BBFDM_TEMP_DIR="/tmp/bbfdm"
. /usr/share/libubox/jshn.sh
log() {
@ -19,15 +16,13 @@ validate_bbfdm_bbfdmd_section()
{
uci_validate_section bbfdm bbfdmd "bbfdmd" \
'enable:bool:true' \
'sock:string' \
'debug:bool:false' \
'loglevel:uinteger:1' \
'subprocess_level:uinteger'
'loglevel:uinteger:3'
}
configure_bbfdmd()
{
local enable debug sock
local enable debug
local jlog jrefresh jtimeout jlevel
config_load bbfdm
@ -38,19 +33,13 @@ configure_bbfdmd()
[ "${enable}" -eq 0 ] && return 0
if [ -f "${BBFDM_JSON_INPUT}" ]; then
echo "$(jq --arg log ${loglevel} --arg level ${subprocess_level} '.daemon.config += {"loglevel": $log, "subprocess_level": $level}' ${BBFDM_JSON_INPUT})" > "${BBFDM_TEMP_DIR}/input.json"
fi
procd_set_param command ${PROG}
procd_append_param command -l "${loglevel}"
if [ "${debug}" -eq 1 ]; then
procd_set_param stdout 1
procd_set_param stderr 1
fi
if [ -f "${sock}" ]; then
procd_append_param command -s "${sock}"
fi
}
start_service()

View file

@ -2,7 +2,7 @@
BBFDM_BASE_DM_PATH="usr/share/bbfdm"
BBFDM_INPUT_PATH="etc/bbfdm/micro_services"
INPUT_TEMPLATE='{"daemon":{"enable":"1","service_name":"template","config":{"loglevel":"1"}}}'
INPUT_TEMPLATE='{"daemon":{"enable":"1","service_name":"template","config":{"loglevel":"3"}}}'
OUT_NAME=""
MICRO_SERVICE=0