Commit e29153c0 authored by Philip Carns's avatar Philip Carns
Browse files

stub in code to auto attach targets from json

parent 9e6c841d
......@@ -8,6 +8,7 @@
#include "bake-server.h"
#include "bake-client.h"
#include "bake-macros.h"
static int bake_register_provider(bedrock_args_t args,
bedrock_module_provider_t* provider)
......
......@@ -7,6 +7,8 @@
#ifndef __BAKE_MACROS
#define __BAKE_MACROS
#include <json-c/json.h>
static const int json_type_int64 = json_type_int;
// Checks if a JSON object has a particular key and its value is of the
......@@ -67,4 +69,9 @@ static const int json_type_int64 = json_type_int;
} \
} while (0)
// Can be used in configurations to check if a JSON object has a particular
// field. If it does, the __out parameter is set to that field.
#define CONFIG_HAS(__config, __key, __out) \
((__out = json_object_object_get(__config, __key)) != NULL)
#endif /* __BAKE_MACROS */
......@@ -50,6 +50,8 @@ DECLARE_MARGO_RPC_HANDLER(bake_migrate_target_ult)
*/
static int validate_and_complete_config(struct json_object* _config,
ABT_pool _progress_pool);
static int configure_targets(bake_provider_t provider,
struct json_object* _config);
static int setup_poolset(bake_provider_t provider);
static bake_target_t* find_target_entry(bake_provider_t provider,
......@@ -302,6 +304,13 @@ int bake_provider_register(margo_instance_id mid,
}
#endif
/* Did the config include targets that we need to attach or create? */
ret = configure_targets(tmp_provider, config);
if (ret < 0) {
ret = BAKE_ERR_INVALID_ARG;
goto error;
}
tmp_provider->json_cfg = config;
/* install the bake server finalize callback */
......@@ -311,6 +320,11 @@ int bake_provider_register(margo_instance_id mid,
if (provider != BAKE_PROVIDER_IGNORE) *provider = tmp_provider;
return BAKE_SUCCESS;
error:
/* TODO: fill this in; this fn needs much better error handling */
return (ret);
}
int bake_provider_deregister(bake_provider_t provider)
......@@ -1043,6 +1057,24 @@ static int setup_poolset(bake_provider_t provider)
return BAKE_SUCCESS;
}
static int configure_targets(bake_provider_t provider,
struct json_object* _config)
{
struct json_object* val;
if (CONFIG_HAS(_config, "file_backend", val)) {
BAKE_TRACE(provider->mid, "checking file_backend object in json");
/* TODO: walk target list and try to attach or create */
}
if (CONFIG_HAS(_config, "pmem_backend", val)) {
BAKE_TRACE(provider->mid, "checking pmem_backend object in json");
/* TODO: walk target list and try to attach or create */
}
return (0);
}
static int validate_and_complete_config(struct json_object* _config,
ABT_pool _progress_pool)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment