mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-01 17:35:33 +01:00
Get the correct reference if the object was exposed from micro-service
This commit is contained in:
parent
3f9ab21a59
commit
8162d226fe
3 changed files with 125 additions and 28 deletions
|
|
@ -18,7 +18,7 @@ install_libbbf_test ${1}
|
|||
#compile and install libwifi_dataelements dynamic extension library
|
||||
install_libwifi_dataelements ${1}
|
||||
|
||||
# Install datamodel plugins only when pipeline trigger for bbfdm
|
||||
# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm
|
||||
if [ -z "${1}" ]; then
|
||||
git clone --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/feed/iopsys.git /opt/dev/iopsys
|
||||
git clone --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/bbf/bulkdata.git /opt/dev/bulkdata
|
||||
|
|
@ -29,6 +29,7 @@ if [ -z "${1}" ]; then
|
|||
cp -f /opt/dev/iopsys/icwmp/files/etc/bbfdm/json/CWMPManagementServer.json /etc/bbfdm/json
|
||||
cp -f /opt/dev/iopsys/ponmngr/files/etc/bbfdm/json/xpon.json /etc/bbfdm/json
|
||||
|
||||
# install bulkdata micro-service
|
||||
mkdir -p /etc/bulkdata
|
||||
cp -f /opt/dev/bulkdata/bbf_plugin/bulkdata.json /etc/bulkdata
|
||||
cp -f /opt/dev/iopsys/bulkdata/files/etc/bulkdata/input.json /etc/bulkdata
|
||||
|
|
@ -36,9 +37,15 @@ if [ -z "${1}" ]; then
|
|||
# install usermngr plugin
|
||||
install_libusermngr
|
||||
|
||||
# install periodicstats plugin
|
||||
install_libperiodicstats
|
||||
# install periodicstats micro-service
|
||||
install_periodicstats
|
||||
|
||||
# install cwmpdm plugin
|
||||
install_libcwmpdm
|
||||
|
||||
# install hosts micro-service
|
||||
install_hosts_micro_service
|
||||
|
||||
# install time micro-service
|
||||
install_time_micro_service
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -154,6 +154,49 @@ function install_libcwmpdm()
|
|||
cd /builds/bbf/bbfdm
|
||||
}
|
||||
|
||||
|
||||
function install_hosts_micro_service()
|
||||
{
|
||||
# clone and compile hostdm
|
||||
[ -d "/opt/dev/hostmngr" ] && rm -rf /opt/dev/hostmngr
|
||||
|
||||
if [ -n "${HOSTS_BRANCH}" ]; then
|
||||
exec_cmd git clone -b ${HOSTS_BRANCH} --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/iopsys/hostmngr.git /opt/dev/hostmngr
|
||||
else
|
||||
exec_cmd git clone -b devel --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/iopsys/hostmngr.git /opt/dev/hostmngr
|
||||
fi
|
||||
|
||||
echo "Compiling hosts micro-service"
|
||||
exec_cmd_verbose make clean -C /opt/dev/hostmngr/src/bbf_plugin
|
||||
exec_cmd_verbose make -C /opt/dev/hostmngr/src/bbf_plugin
|
||||
|
||||
echo "installing hosts micro-service"
|
||||
mkdir -p /etc/hostmngr
|
||||
cp -f /opt/dev/hostmngr/src/bbf_plugin/libhostmngr.so /etc/hostmngr/
|
||||
cp -f /opt/dev/iopsys/hostmngr/files/etc/hostmngr/input.json /etc/hostmngr
|
||||
}
|
||||
|
||||
function install_time_micro_service()
|
||||
{
|
||||
# clone and compile timedm
|
||||
[ -d "/opt/dev/timemngr" ] && rm -rf /opt/dev/timemngr
|
||||
|
||||
if [ -n "${TIME_BRANCH}" ]; then
|
||||
exec_cmd git clone -b ${TIME_BRANCH} --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/bbf/timemngr.git /opt/dev/timemngr
|
||||
else
|
||||
exec_cmd git clone -b devel --depth 1 https://gitlab-ci-token:${CI_JOB_TOKEN}@dev.iopsys.eu/bbf/timemngr.git /opt/dev/timemngr
|
||||
fi
|
||||
|
||||
echo "Compiling time micro-service"
|
||||
exec_cmd_verbose make clean -C /opt/dev/timemngr/src
|
||||
exec_cmd_verbose make -C /opt/dev/timemngr/src
|
||||
|
||||
echo "installing time micro-service"
|
||||
mkdir -p /etc/timemngr
|
||||
cp -f /opt/dev/timemngr/src/libtimemngr.so /etc/timemngr/
|
||||
cp -f /opt/dev/iopsys/timemngr/files/etc/timemngr/input.json /etc/timemngr
|
||||
}
|
||||
|
||||
function error_on_zero()
|
||||
{
|
||||
ret=$1
|
||||
|
|
|
|||
|
|
@ -2204,8 +2204,60 @@ int dm_entry_set_value(struct dmctx *dmctx)
|
|||
}
|
||||
|
||||
/******************
|
||||
* get linker param
|
||||
* get reference param
|
||||
*****************/
|
||||
static int get_key_ubus_value(struct dmctx *dmctx, struct dmnode *node)
|
||||
{
|
||||
json_object *res = NULL, *res_obj = NULL;
|
||||
char *ubus_name = node->obj->checkdep;
|
||||
|
||||
json_object *in_args = json_object_new_object();
|
||||
json_object_object_add(in_args, "proto", json_object_new_string((dmctx->dm_type == BBFDM_BOTH) ? "both" : (dmctx->dm_type == BBFDM_CWMP) ? "cwmp" : "usp"));
|
||||
json_object_object_add(in_args, "instance_mode", json_object_new_string(dmctx->instance_mode ? "1" : "0"));
|
||||
json_object_object_add(in_args, "format", json_object_new_string("raw"));
|
||||
|
||||
dmubus_call(ubus_name, "get",
|
||||
UBUS_ARGS{
|
||||
{"path", dmctx->in_param, String},
|
||||
{"optional", json_object_to_json_string(in_args), Table}
|
||||
},
|
||||
2, &res);
|
||||
|
||||
json_object_put(in_args);
|
||||
|
||||
if (!res)
|
||||
return FAULT_9005;
|
||||
|
||||
json_object *res_array = dmjson_get_obj(res, 1, "results");
|
||||
if (!res_array)
|
||||
return FAULT_9005;
|
||||
|
||||
size_t nbre_obj = json_object_array_length(res_array);
|
||||
|
||||
if (nbre_obj == 0)
|
||||
return FAULT_9005;
|
||||
|
||||
for (size_t i = 0; i < nbre_obj; i++) {
|
||||
res_obj = json_object_array_get_idx(res_array, i);
|
||||
|
||||
char *fault = dmjson_get_value(res_obj, 1, "fault");
|
||||
if (DM_STRLEN(fault))
|
||||
return DM_STRTOUL(fault);
|
||||
|
||||
char *path = dmjson_get_value(res_obj, 1, "path");
|
||||
char *data = dmjson_get_value(res_obj, 1, "data");
|
||||
|
||||
if (data && DM_STRCMP(data, dmctx->linker) == 0) {
|
||||
dmctx->linker_param = dmstrdup(path);
|
||||
char *p = strrchr(dmctx->linker_param, '.');
|
||||
if (p) *p = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_key_check_obj(DMOBJECT_ARGS)
|
||||
{
|
||||
return FAULT_9005;
|
||||
|
|
@ -2213,35 +2265,30 @@ static int get_key_check_obj(DMOBJECT_ARGS)
|
|||
|
||||
static int get_key_check_param(DMPARAM_ARGS)
|
||||
{
|
||||
char *full_param;
|
||||
char *value = "";
|
||||
|
||||
// Entry not found
|
||||
if (leaf == NULL) {
|
||||
if (node->is_ubus_service) {
|
||||
int err = get_key_ubus_value(dmctx, node);
|
||||
dmctx->stop = true;
|
||||
return 0;
|
||||
}
|
||||
return err ? err : 0;
|
||||
} else {
|
||||
char *full_param;
|
||||
char *value = "";
|
||||
|
||||
if (DM_STRLEN(leaf->parameter) == 0) {
|
||||
dmctx->stop = true;
|
||||
return FAULT_9005;
|
||||
}
|
||||
dmastrcat(&full_param, node->current_object, leaf->parameter);
|
||||
|
||||
dmastrcat(&full_param, node->current_object, leaf->parameter);
|
||||
if (dm_strcmp_wildcard(dmctx->in_param, full_param) != 0) {
|
||||
dmfree(full_param);
|
||||
return FAULT_9005;
|
||||
}
|
||||
|
||||
if (dm_strcmp_wildcard(dmctx->in_param, full_param) != 0) {
|
||||
dmfree(full_param);
|
||||
return FAULT_9005;
|
||||
}
|
||||
(leaf->getvalue)(full_param, dmctx, data, instance, &value);
|
||||
|
||||
(leaf->getvalue)(full_param, dmctx, data, instance, &value);
|
||||
|
||||
if (value && value[0] != '\0' && DM_STRCMP(value, dmctx->linker) == 0) {
|
||||
if (node->current_object[DM_STRLEN(node->current_object) - 1] == '.')
|
||||
node->current_object[DM_STRLEN(node->current_object) - 1] = 0;
|
||||
dmctx->linker_param = dmstrdup(node->current_object);
|
||||
dmctx->stop = true;
|
||||
return 0;
|
||||
if (value && value[0] != '\0' && DM_STRCMP(value, dmctx->linker) == 0) {
|
||||
if (node->current_object[DM_STRLEN(node->current_object) - 1] == '.')
|
||||
node->current_object[DM_STRLEN(node->current_object) - 1] = 0;
|
||||
dmctx->linker_param = dmstrdup(node->current_object);
|
||||
dmctx->stop = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return FAULT_9005;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue