From e65ffc78ddb9d2083af787a5ef1452d43e2f0134 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 24 Feb 2019 11:08:15 +0100 Subject: [PATCH] node: add enabled setting --- include/villas/node.h | 3 +++ lib/node.c | 9 ++++++++- lib/path.c | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) 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); }