Backend daemon startup modes
This commit is contained in:
parent
23e40384f7
commit
496d676ad3
26 changed files with 769 additions and 280 deletions
|
|
@ -63,6 +63,13 @@ enum genmodel_type{
|
|||
GT_ALL, /* Keywords on all variables */
|
||||
};
|
||||
|
||||
/*! See clixon-config.yang type startup_mode */
|
||||
enum startup_mode_t{
|
||||
SM_NONE=0,
|
||||
SM_STARTUP,
|
||||
SM_RUNNING,
|
||||
SM_INIT
|
||||
};
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
@ -93,6 +100,7 @@ char *clicon_clispec_dir(clicon_handle h);
|
|||
char *clicon_netconf_dir(clicon_handle h);
|
||||
char *clicon_restconf_dir(clicon_handle h);
|
||||
char *clicon_xmldb_plugin(clicon_handle h);
|
||||
int clicon_startup_mode(clicon_handle h);
|
||||
int clicon_sock_family(clicon_handle h);
|
||||
char *clicon_sock(clicon_handle h);
|
||||
int clicon_sock_port(clicon_handle h);
|
||||
|
|
|
|||
|
|
@ -75,34 +75,34 @@ typedef int (xmldb_getopt_t)(xmldb_handle xh, char *optname, void **value);
|
|||
typedef int (xmldb_setopt_t)(xmldb_handle xh, char *optname, void *value);
|
||||
|
||||
/* Type of xmldb get function */
|
||||
typedef int (xmldb_get_t)(xmldb_handle xh, char *db, char *xpath, int config, cxobj **xtop);
|
||||
typedef int (xmldb_get_t)(xmldb_handle xh, const char *db, char *xpath, int config, cxobj **xtop);
|
||||
|
||||
/* Type of xmldb put function */
|
||||
typedef int (xmldb_put_t)(xmldb_handle xh, char *db, enum operation_type op, cxobj *xt);
|
||||
typedef int (xmldb_put_t)(xmldb_handle xh, const char *db, enum operation_type op, cxobj *xt);
|
||||
|
||||
/* Type of xmldb copy function */
|
||||
typedef int (xmldb_copy_t)(xmldb_handle xh, char *from, char *to);
|
||||
typedef int (xmldb_copy_t)(xmldb_handle xh, const char *from, const char *to);
|
||||
|
||||
/* Type of xmldb lock function */
|
||||
typedef int (xmldb_lock_t)(xmldb_handle xh, char *db, int pid);
|
||||
typedef int (xmldb_lock_t)(xmldb_handle xh, const char *db, int pid);
|
||||
|
||||
/* Type of xmldb unlock function */
|
||||
typedef int (xmldb_unlock_t)(xmldb_handle xh, char *db);
|
||||
typedef int (xmldb_unlock_t)(xmldb_handle xh, const char *db);
|
||||
|
||||
/* Type of xmldb unlock_all function */
|
||||
typedef int (xmldb_unlock_all_t)(xmldb_handle xh, int pid);
|
||||
|
||||
/* Type of xmldb islocked function */
|
||||
typedef int (xmldb_islocked_t)(xmldb_handle xh, char *db);
|
||||
typedef int (xmldb_islocked_t)(xmldb_handle xh, const char *db);
|
||||
|
||||
/* Type of xmldb exists function */
|
||||
typedef int (xmldb_exists_t)(xmldb_handle xh, char *db);
|
||||
typedef int (xmldb_exists_t)(xmldb_handle xh, const char *db);
|
||||
|
||||
/* Type of xmldb delete function */
|
||||
typedef int (xmldb_delete_t)(xmldb_handle xh, char *db);
|
||||
typedef int (xmldb_delete_t)(xmldb_handle xh, const char *db);
|
||||
|
||||
/* Type of xmldb init function */
|
||||
typedef int (xmldb_create_t)(xmldb_handle xh, char *db);
|
||||
typedef int (xmldb_create_t)(xmldb_handle xh, const char *db);
|
||||
|
||||
/* plugin init struct for the api */
|
||||
struct xmldb_api{
|
||||
|
|
@ -133,20 +133,20 @@ struct xmldb_api{
|
|||
int xmldb_plugin_load(clicon_handle h, char *filename);
|
||||
int xmldb_plugin_unload(clicon_handle h);
|
||||
|
||||
int xmldb_validate_db(char *db);
|
||||
int xmldb_validate_db(const char *db);
|
||||
int xmldb_connect(clicon_handle h);
|
||||
int xmldb_disconnect(clicon_handle h);
|
||||
int xmldb_getopt(clicon_handle h, char *optname, void **value);
|
||||
int xmldb_setopt(clicon_handle h, char *optname, void *value);
|
||||
int xmldb_get(clicon_handle h, char *db, char *xpath, int config, cxobj **xtop);
|
||||
int xmldb_put(clicon_handle h, char *db, enum operation_type op, cxobj *xt);
|
||||
int xmldb_copy(clicon_handle h, char *from, char *to);
|
||||
int xmldb_lock(clicon_handle h, char *db, int pid);
|
||||
int xmldb_unlock(clicon_handle h, char *db);
|
||||
int xmldb_get(clicon_handle h, const char *db, char *xpath, int config, cxobj **xtop);
|
||||
int xmldb_put(clicon_handle h, const char *db, enum operation_type op, cxobj *xt);
|
||||
int xmldb_copy(clicon_handle h, const char *from, const char *to);
|
||||
int xmldb_lock(clicon_handle h, const char *db, int pid);
|
||||
int xmldb_unlock(clicon_handle h, const char *db);
|
||||
int xmldb_unlock_all(clicon_handle h, int pid);
|
||||
int xmldb_islocked(clicon_handle h, char *db);
|
||||
int xmldb_exists(clicon_handle h, char *db);
|
||||
int xmldb_delete(clicon_handle h, char *db);
|
||||
int xmldb_create(clicon_handle h, char *db);
|
||||
int xmldb_islocked(clicon_handle h, const char *db);
|
||||
int xmldb_exists(clicon_handle h, const char *db);
|
||||
int xmldb_delete(clicon_handle h, const char *db);
|
||||
int xmldb_create(clicon_handle h, const char *db);
|
||||
|
||||
#endif /* _CLIXON_XML_DB_H */
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ quit:
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Make a copy of file src
|
||||
/*! Make a copy of file src. Overwrite existing
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
/* clicon */
|
||||
#include "clixon_err.h"
|
||||
#include "clixon_string.h"
|
||||
#include "clixon_queue.h"
|
||||
#include "clixon_hash.h"
|
||||
#include "clixon_handle.h"
|
||||
|
|
@ -69,6 +70,16 @@
|
|||
#include "clixon_xsl.h"
|
||||
#include "clixon_xml_map.h"
|
||||
|
||||
/* Mapping between Clicon startup modes string <--> constants,
|
||||
see clixon-config.yang type startup_mode */
|
||||
static const map_str2int startup_mode_map[] = {
|
||||
{"none", SM_NONE},
|
||||
{"running", SM_RUNNING},
|
||||
{"startup", SM_STARTUP},
|
||||
{"init", SM_INIT},
|
||||
{NULL, -1}
|
||||
};
|
||||
|
||||
/*! Print registry on file. For debugging.
|
||||
*/
|
||||
void
|
||||
|
|
@ -332,7 +343,6 @@ clicon_option_sanity(clicon_hash_t *copt)
|
|||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*! Initialize option values
|
||||
*
|
||||
* Set default options, Read config-file, Check that all values are set.
|
||||
|
|
@ -387,9 +397,12 @@ clicon_options_main(clicon_handle h)
|
|||
}
|
||||
|
||||
/*! Check if a clicon option has a value
|
||||
* @param[in] h clicon_handle
|
||||
* @param[in] name option name
|
||||
*/
|
||||
int
|
||||
clicon_option_exists(clicon_handle h, const char *name)
|
||||
clicon_option_exists(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
clicon_hash_t *copt = clicon_options(h);
|
||||
|
||||
|
|
@ -449,7 +462,8 @@ clicon_option_str_set(clicon_handle h,
|
|||
* supply a defualt value as shown in the example.
|
||||
*/
|
||||
int
|
||||
clicon_option_int(clicon_handle h, const char *name)
|
||||
clicon_option_int(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
|
@ -461,7 +475,9 @@ clicon_option_int(clicon_handle h, const char *name)
|
|||
/*! Set option given as int.
|
||||
*/
|
||||
int
|
||||
clicon_option_int_set(clicon_handle h, const char *name, int val)
|
||||
clicon_option_int_set(clicon_handle h,
|
||||
const char *name,
|
||||
int val)
|
||||
{
|
||||
char s[64];
|
||||
|
||||
|
|
@ -473,7 +489,8 @@ clicon_option_int_set(clicon_handle h, const char *name, int val)
|
|||
/*! Delete option
|
||||
*/
|
||||
int
|
||||
clicon_option_del(clicon_handle h, const char *name)
|
||||
clicon_option_del(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
clicon_hash_t *copt = clicon_options(h);
|
||||
|
||||
|
|
@ -550,6 +567,15 @@ clicon_xmldb_plugin(clicon_handle h)
|
|||
return clicon_option_str(h, "CLICON_XMLDB_PLUGIN");
|
||||
}
|
||||
|
||||
int
|
||||
clicon_startup_mode(clicon_handle h)
|
||||
{
|
||||
char *mode;
|
||||
if ((mode = clicon_option_str(h, "CLICON_STARTUP_MODE")) == NULL)
|
||||
return -1;
|
||||
return clicon_str2int(startup_mode_map, mode);
|
||||
}
|
||||
|
||||
/*! Get family of backend socket: AF_UNIX, AF_INET or AF_INET6 */
|
||||
int
|
||||
clicon_sock_family(clicon_handle h)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ xmldb_plugin_unload(clicon_handle h)
|
|||
* @retval -1 Failed validate, xret set to error
|
||||
*/
|
||||
int
|
||||
xmldb_validate_db(char *db)
|
||||
xmldb_validate_db(const char *db)
|
||||
{
|
||||
if (strcmp(db, "running") != 0 &&
|
||||
strcmp(db, "candidate") != 0 &&
|
||||
|
|
@ -336,7 +336,7 @@ xmldb_setopt(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_get(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
char *xpath,
|
||||
int config,
|
||||
cxobj **xtop)
|
||||
|
|
@ -393,7 +393,7 @@ xmldb_get(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_put(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
enum operation_type op,
|
||||
cxobj *xt)
|
||||
{
|
||||
|
|
@ -439,8 +439,8 @@ xmldb_put(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_copy(clicon_handle h,
|
||||
char *from,
|
||||
char *to)
|
||||
const char *from,
|
||||
const char *to)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -472,7 +472,7 @@ xmldb_copy(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_lock(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
int pid)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -506,7 +506,7 @@ xmldb_lock(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_unlock(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -569,7 +569,7 @@ xmldb_unlock_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_islocked(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -601,7 +601,7 @@ xmldb_islocked(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_exists(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -632,7 +632,7 @@ xmldb_exists(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_delete(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -663,7 +663,7 @@ xmldb_delete(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_create(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue