aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2019-07-10 14:52:08 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2019-07-10 14:52:08 +0200
commit2a7a645788c2fdd6fff24f8fc2f10a54c1cc6088 (patch)
treeb1318ab35e4d64a70befa69fba7d8c405ee44db1
parent888915ab5055b873676783916f2e0cc887bb6329 (diff)
Fix ctlso load path on target
Change-Id: I948cf7ea9aa3113ba7daa02190853e25776b41a5
-rw-r--r--conf.d/project/etc/xds-supervisor-config.json30
-rw-r--r--conf.d/project/lua.d/CMakeLists.txt14
-rw-r--r--src/xds-binding.c48
3 files changed, 59 insertions, 33 deletions
diff --git a/conf.d/project/etc/xds-supervisor-config.json b/conf.d/project/etc/xds-supervisor-config.json
index 15304f4..e278715 100644
--- a/conf.d/project/etc/xds-supervisor-config.json
+++ b/conf.d/project/etc/xds-supervisor-config.json
@@ -6,19 +6,23 @@
"api": "xds",
"info": "XDS Data collection binding"
},
- "plugins": [{
- "uid": "supervisor",
- "info": "Plugin to handle interface with supervisor",
- "spath": "./lib/plugins:./var",
- "libs": [
- "supervisor.ctlso",
- "xds-supervisor.lua"
- ]
- }],
- "onload": [],
+ "plugins": [
+ {
+ "uid": "supervisor",
+ "info": "Plugin to handle interface with supervisor",
+ "libs": [
+ "supervisor.ctlso",
+ "xds-supervisor.lua"
+ ]
+ }
+ ],
+
+ "onload": [
+ ],
- "controls": [{
+ "controls": [
+ {
"uid": "list",
"privileges": "urn:AGL:permission::platform:can:list ",
"action": "plugin://supervisor#list"
@@ -39,6 +43,10 @@
{
"uid": "supervisor/xds-trace",
"action": "plugin://supervisor#tracing_events"
+ },
+ {
+ "uid": "afm-main/application-list-changed",
+ "action": "plugin://supervisor#apps_list_changed"
}
]
diff --git a/conf.d/project/lua.d/CMakeLists.txt b/conf.d/project/lua.d/CMakeLists.txt
index aade4cb..b82b879 100644
--- a/conf.d/project/lua.d/CMakeLists.txt
+++ b/conf.d/project/lua.d/CMakeLists.txt
@@ -21,13 +21,13 @@
# XDS Lua Scripts
##################################################
-# PROJECT_TARGET_ADD(xds-lua)
+PROJECT_TARGET_ADD(xds-lua)
-# file(GLOB LUA_FILES "*.lua")
+ file(GLOB LUA_FILES "*.lua")
-# add_input_files("${LUA_FILES}")
+ add_input_files("${LUA_FILES}")
-# SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
-# LABELS "DATA"
-# OUTPUT_NAME ${TARGET_NAME}
-# )
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ LABELS "DATA"
+ OUTPUT_NAME ${TARGET_NAME}
+ )
diff --git a/src/xds-binding.c b/src/xds-binding.c
index f93a121..81ac6b0 100644
--- a/src/xds-binding.c
+++ b/src/xds-binding.c
@@ -17,14 +17,14 @@
*/
#define _GNU_SOURCE
+#include <afb/afb-binding.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
+#include <stdbool.h>
#include "xds-binding.h"
-afb_dynapi* AFB_default;
-
// Config Section definition (note: controls section index should match handle
// retrieval in HalConfigExec)
static CtlSectionT ctrlSections[] = {
@@ -52,7 +52,7 @@ static void ctrlapi_ping(afb_req_t request)
return;
}
-void ctrlapi_auth(afb_req_t request)
+static void ctrlapi_auth(afb_req_t request)
{
afb_req_session_set_LOA(request, 1);
afb_req_success(request, NULL, NULL);
@@ -82,8 +82,6 @@ static int CtrlInitOneApi(afb_api_t apiHandle)
{
int err = 0;
- AFB_default = apiHandle; // hugely hack to make all V2 AFB_DEBUG to work in fileutils
-
// retrieve section config from api handle
CtlConfigT* ctrlConfig = (CtlConfigT*)afb_dynapi_get_userdata(apiHandle);
err = CtlConfigExec(apiHandle, ctrlConfig);
@@ -127,41 +125,61 @@ static int CtrlLoadOneApi(void* cbdata, afb_api_t apiHandle)
int afbBindingEntry(afb_dynapi* apiHandle)
{
+ int status = 0;
+ char* dirList;
+ bool dirListNeedFree = FALSE;
- AFB_default = apiHandle;
AFB_API_NOTICE(apiHandle, "Controller in afbBindingEntry");
- const char* dirList = getenv("CONTROL_CONFIG_PATH");
- if (!dirList)
+ const char* dir = GetBindingDirPath(apiHandle);
+ if (!dir) {
dirList = CONTROL_CONFIG_PATH;
+ dirListNeedFree = FALSE;
+ } else {
+ dirList = calloc(strlen(dir) + strlen("/etc"), sizeof(char));
+ if (dirList == NULL) {
+ AFB_API_ERROR(apiHandle, "afbBindingEntry: not enough memory");
+ return ERROR;
+ }
+ dirListNeedFree = TRUE;
+ strcpy(dirList, dir);
+ strcat(dirList, "/etc");
+ AFB_API_NOTICE(apiHandle, "Json config directory : %s", dirList);
+ }
const char* configPath = CtlConfigSearch(apiHandle, dirList, "");
if (!configPath) {
- AFB_API_ERROR(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
- return ERROR;
+ AFB_API_ERROR(apiHandle, "afbBindingEntry: No %s* config found in %s ", GetBinderName(), dirList);
+ status = ERROR;
+ goto _exit_afbBindingEntry;
}
// load config file and create API
CtlConfigT* ctrlConfig = CtlLoadMetaData(apiHandle, configPath);
if (!ctrlConfig) {
AFB_API_ERROR(apiHandle,
- "CtrlBindingDyn No valid control config file in:\n-- %s",
+ "afbBindingEntry No valid control config file in:\n-- %s",
configPath);
- return ERROR;
+ status = ERROR;
+ goto _exit_afbBindingEntry;
}
if (!ctrlConfig->api) {
AFB_API_ERROR(apiHandle,
- "CtrlBindingDyn API Missing from metadata in:\n-- %s",
+ "afbBindingEntry API Missing from metadata in:\n-- %s",
configPath);
- return ERROR;
+ status = ERROR;
+ goto _exit_afbBindingEntry;
}
AFB_API_NOTICE(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api,
ctrlConfig->info);
// create one API per config file (Pre-V3 return code ToBeChanged)
- int status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig);
+ status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig);
+_exit_afbBindingEntry:
+ if (dirListNeedFree)
+ free(dirList);
return status;
}