diff --git a/include/villas/node.h b/include/villas/node.h index 8f166b2e9..e7d34eac3 100644 --- a/include/villas/node.h +++ b/include/villas/node.h @@ -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 } diff --git a/lib/node.c b/lib/node.c index b49c01eb3..f9752f903 100644 --- a/lib/node.c +++ b/lib/node.c @@ -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; +} + } diff --git a/lib/path.c b/lib/path.c index 9f1288bb3..ddaf6926a 100644 --- a/lib/path.c +++ b/lib/path.c @@ -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); }