mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
node: add enabled setting
This commit is contained in:
parent
0acce9e375
commit
e65ffc78dd
3 changed files with 17 additions and 1 deletions
|
@ -60,6 +60,7 @@ extern "C" {
|
|||
*/
|
||||
struct node {
|
||||
char *name; /**< A short identifier of the node, only used for configuration and logging */
|
||||
int enabled;
|
||||
|
||||
enum state state;
|
||||
|
||||
|
@ -198,6 +199,8 @@ struct node_type * node_type(struct node *n)
|
|||
struct memory_type * node_memory_type(struct node *n, struct memory_type *parent);
|
||||
|
||||
int node_is_valid_name(const char *name);
|
||||
bool node_is_enabled(const struct node *n);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ int node_init(struct node *n, struct node_type *vt)
|
|||
n->name = NULL;
|
||||
n->_name = NULL;
|
||||
n->_name_long = NULL;
|
||||
n->enabled = 1;
|
||||
|
||||
#ifdef __linux__
|
||||
n->fwmark = -1;
|
||||
|
@ -113,8 +114,9 @@ int node_parse(struct node *n, json_t *json, const char *name)
|
|||
|
||||
n->name = strdup(name);
|
||||
|
||||
ret = json_unpack_ex(json, &err, 0, "{ s: s, s?: { s?: o } }",
|
||||
ret = json_unpack_ex(json, &err, 0, "{ s: s, s?: b, s?: { s?: o } }",
|
||||
"type", &type,
|
||||
"enabled", &n->enabled,
|
||||
"in",
|
||||
"signals", &json_signals
|
||||
);
|
||||
|
@ -603,4 +605,9 @@ int node_is_valid_name(const char *name)
|
|||
}
|
||||
|
||||
return 0;
|
||||
bool node_is_enabled(const struct node *n)
|
||||
{
|
||||
return n->enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -375,6 +375,9 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes)
|
|||
vlist_push(&p->sources, ps);
|
||||
}
|
||||
|
||||
if (!node_is_enabled(ps->node))
|
||||
error("Source %s of path %s is not enabled", node_name(ps->node), path_name(p));
|
||||
|
||||
vlist_push(&ps->mappings, me);
|
||||
}
|
||||
|
||||
|
@ -385,6 +388,9 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes)
|
|||
|
||||
pd->node = n;
|
||||
|
||||
if (!node_is_enabled(pd->node))
|
||||
error("Destination %s of path %s is not enabled", node_name(pd->node), path_name(p));
|
||||
|
||||
vlist_push(&p->destinations, pd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue