mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbfdm: Use object name in ubus for microservices
This commit is contained in:
parent
70c0665f95
commit
870d903d0c
5 changed files with 38 additions and 20 deletions
|
|
@ -64,9 +64,9 @@ static void sig_handler(int sig)
|
|||
|
||||
static void service_sig_handler(int sig)
|
||||
{
|
||||
WARNING("# PID[%ld] received %d signal ...", getpid(), sig);
|
||||
WARNING("# Micro-service PID[%ld] received %d signal ...", getpid(), sig);
|
||||
if (sig == SIGSEGV) {
|
||||
ERR("# Exception in PID[%ld] ...", getpid());
|
||||
ERR("# Micro-service in PID[%ld] ...", getpid());
|
||||
}
|
||||
exit(-1);
|
||||
}
|
||||
|
|
@ -1083,7 +1083,7 @@ static int bbfdm_notify_event(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__BBF_NOTIFY_MAX] = {NULL};
|
||||
char method_name[40] = {0};
|
||||
char method_name[256] = {0};
|
||||
struct bbfdm_context *u;
|
||||
|
||||
u = container_of(ctx, struct bbfdm_context, ubus_ctx);
|
||||
|
|
@ -1132,7 +1132,7 @@ static struct ubus_object bbf_object = {
|
|||
static void run_schema_updater(struct bbfdm_context *u)
|
||||
{
|
||||
bool ret;
|
||||
char method_name[45] = {0};
|
||||
char method_name[256] = {0};
|
||||
|
||||
ret = is_object_schema_update_available(u);
|
||||
if (ret && (is_micro_service == false)) {
|
||||
|
|
@ -1172,7 +1172,7 @@ static void broadcast_add_del_event(const char *method, struct list_head *inst,
|
|||
a = blobmsg_open_array(&bb, "instances");
|
||||
list_for_each_entry(ptr, inst, list) {
|
||||
blobmsg_add_string(&bb, NULL, ptr->path);
|
||||
DEBUG("#%s:: %s #", (is_add)?"Add":"Del", ptr->path);
|
||||
DEBUG("#%s:: %s, method %s #", (is_add)?"Add":"Del", ptr->path, method);
|
||||
}
|
||||
blobmsg_close_array(&bb, a);
|
||||
|
||||
|
|
@ -1383,10 +1383,10 @@ static bool register_service(struct ubus_context *ctx)
|
|||
blobmsg_add_string(&bb, "name", u->config.out_name);
|
||||
blobmsg_add_string(&bb, "parent_dm", u->config.out_parent_dm);
|
||||
|
||||
if (DM_STRLEN(u->config.multi_object[0]) != 0) {
|
||||
if (DM_STRLEN(u->config.out_multi_objects[0]) != 0) {
|
||||
void *arr = blobmsg_open_array(&bb, "multiple_objects");
|
||||
for (int i = 0; i < MAX_MULTI_OBJS && DM_STRLEN(u->config.multi_object[i]) != 0; i++)
|
||||
blobmsg_add_string(&bb, NULL, u->config.multi_object[i]);
|
||||
for (int i = 0; i < MAX_MULTI_OBJS && DM_STRLEN(u->config.out_multi_objects[i]) != 0; i++)
|
||||
blobmsg_add_string(&bb, NULL, u->config.out_multi_objects[i]);
|
||||
blobmsg_close_array(&bb, arr);
|
||||
} else {
|
||||
blobmsg_add_string(&bb, "object", u->config.out_object);
|
||||
|
|
@ -1445,11 +1445,6 @@ static int bbfdm_load_deamon_config(bbfdm_config_t *config, const char *json_pat
|
|||
config->subprocess_level = BBF_SUBPROCESS_DEPTH;
|
||||
}
|
||||
|
||||
opt_val = dmjson_get_value(deamon_obj, 2, "output", "name");
|
||||
if (DM_STRLEN(opt_val)) {
|
||||
strncpyt(config->out_name, opt_val, sizeof(config->out_name));
|
||||
}
|
||||
|
||||
opt_val = dmjson_get_value(deamon_obj, 2, "output", "parent_dm");
|
||||
if (DM_STRLEN(opt_val)) {
|
||||
strncpyt(config->out_parent_dm, opt_val, sizeof(config->out_parent_dm));
|
||||
|
|
@ -1466,7 +1461,7 @@ static int bbfdm_load_deamon_config(bbfdm_config_t *config, const char *json_pat
|
|||
|
||||
dmjson_foreach_value_in_array(deamon_obj, arr_obj, mem_obj, i, 2, "output", "multiple_objects") {
|
||||
if (i < MAX_MULTI_OBJS) {
|
||||
replace_str(mem_obj, "{BBF_VENDOR_PREFIX}", BBF_VENDOR_PREFIX, config->multi_object[i], sizeof(config->multi_object[i]));
|
||||
replace_str(mem_obj, "{BBF_VENDOR_PREFIX}", BBF_VENDOR_PREFIX, config->out_multi_objects[i], sizeof(config->out_multi_objects[i]));
|
||||
} else {
|
||||
WARNING("More multiple_object defined, can handle only %d ...", MAX_MULTI_OBJS);
|
||||
break;
|
||||
|
|
@ -1478,6 +1473,31 @@ static int bbfdm_load_deamon_config(bbfdm_config_t *config, const char *json_pat
|
|||
strncpyt(config->out_root_obj, opt_val, sizeof(config->out_root_obj));
|
||||
}
|
||||
|
||||
opt_val = dmjson_get_value(deamon_obj, 2, "output", "name");
|
||||
if (is_micro_service == false) {
|
||||
strncpyt(config->out_name, opt_val, sizeof(config->out_name));
|
||||
} else {
|
||||
char val[256] = {0};
|
||||
|
||||
if (DM_STRLEN(config->out_object)) {
|
||||
snprintf(val, sizeof(val), "%s.%s", config->out_root_obj, config->out_object);
|
||||
} else { //out_multi_objects present
|
||||
snprintf(val, sizeof(val), "%s", config->out_root_obj);
|
||||
for (i = 0; i < MAX_MULTI_OBJS; i++) {
|
||||
if (DM_STRLEN(config->out_multi_objects[i]) == 0) {
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
snprintf(val, sizeof(val), "%s.%s", config->out_root_obj, config->out_multi_objects[0]);
|
||||
} else {
|
||||
int len = DM_STRLEN(val);
|
||||
snprintf(val+len, sizeof(val) - len, "_%s", config->out_multi_objects[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
strncpyt(config->out_name, val, sizeof(config->out_name));
|
||||
}
|
||||
|
||||
opt_val = dmjson_get_value(deamon_obj, 2, "input", "plugin_dir");
|
||||
if (DM_STRLEN(opt_val)) {
|
||||
strncpyt(config->in_plugin_dir, opt_val, sizeof(config->in_plugin_dir));
|
||||
|
|
@ -1676,7 +1696,7 @@ int daemon_load_datamodel(struct bbfdm_context *daemon_ctx)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (DM_STRLEN(daemon_ctx->config.out_object) == 0 && DM_STRLEN(daemon_ctx->config.multi_object[0]) == 0) {
|
||||
if (DM_STRLEN(daemon_ctx->config.out_object) == 0 && DM_STRLEN(daemon_ctx->config.out_multi_objects[0]) == 0) {
|
||||
ERR("output object and multiple_objects both are not defined");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ typedef struct bbfdm_config {
|
|||
char in_name[128];
|
||||
char in_plugin_dir[128];
|
||||
char out_type[32];
|
||||
char out_name[32];
|
||||
char out_name[128];
|
||||
char out_parent_dm[32];
|
||||
char out_object[32];
|
||||
char multi_object[MAX_MULTI_OBJS][32];
|
||||
char out_multi_objects[MAX_MULTI_OBJS][32];
|
||||
char out_root_obj[32];
|
||||
char cli_in_type[32];
|
||||
char cli_in_name[128];
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand
|
|||
|
||||
struct dm_parameter *param = NULL;
|
||||
struct blob_buf b = {0}, bb = {0};
|
||||
char method_name[64] = {0};
|
||||
char method_name[256] = {0};
|
||||
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
memset(&bb, 0, sizeof(struct blob_buf));
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ It's a three step process, if DotSO or JSON plugin already present, if not refer
|
|||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"name": "bbfdm.bulkdata", // name of the ubus object to register for micro-service
|
||||
"parent_dm": "Device.", // Parent tree to attach the plugin
|
||||
"object": "BulkData", // Name of the object
|
||||
"root_obj": "bbfdm" // Name of the root tree ubus object which is bbfdm
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
},
|
||||
"output": {
|
||||
"type": "UBUS",
|
||||
"name": "bbfdm.dataelements",
|
||||
"parent_dm": "Device.WiFi.",
|
||||
"object": "DataElements",
|
||||
"root_obj": "bbfdm"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue