mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
node: refactore constant for node name regex
This commit is contained in:
parent
f892e5e29f
commit
b467169d3c
7 changed files with 11 additions and 11 deletions
|
@ -51,7 +51,7 @@
|
|||
struct rtnl_cls;
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
#define REGEX_NODE_NAME "[a-z0-9_-]{3,32}"
|
||||
#define RE_NODE_NAME "[a-z0-9_-]{3,32}"
|
||||
|
||||
/** The data structure for a node.
|
||||
*
|
||||
|
|
|
@ -58,27 +58,27 @@ public:
|
|||
|
||||
/* Register API requests */
|
||||
static char n1[] = "node/start";
|
||||
static char r1[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/start";
|
||||
static char r1[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/start";
|
||||
static char d1[] = "start a node";
|
||||
static RequestPlugin<NodeActionRequest<node_start>, n1, r1, d1> p1;
|
||||
|
||||
static char n2[] = "node/stop";
|
||||
static char r2[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/stop";
|
||||
static char r2[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/stop";
|
||||
static char d2[] = "stop a node";
|
||||
static RequestPlugin<NodeActionRequest<node_stop>, n2, r2, d2> p2;
|
||||
|
||||
static char n3[] = "node/pause";
|
||||
static char r3[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/pause";
|
||||
static char r3[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/pause";
|
||||
static char d3[] = "pause a node";
|
||||
static RequestPlugin<NodeActionRequest<node_pause>, n3, r3, d3> p3;
|
||||
|
||||
static char n4[] = "node/resume";
|
||||
static char r4[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/resume";
|
||||
static char r4[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/resume";
|
||||
static char d4[] = "resume a node";
|
||||
static RequestPlugin<NodeActionRequest<node_resume>, n4, r4, d4> p4;
|
||||
|
||||
static char n5[] = "node/restart";
|
||||
static char r5[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/restart";
|
||||
static char r5[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/restart";
|
||||
static char d5[] = "restart a node";
|
||||
static RequestPlugin<NodeActionRequest<node_restart>, n5, r5, d5> p5;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
/* Register API request */
|
||||
static char n[] = "node/file";
|
||||
static char r[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/file(?:/([^/]+))?";
|
||||
static char r[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/file(?:/([^/]+))?";
|
||||
static char d[] = "control instances of 'file' node-type";
|
||||
static RequestPlugin<FileRequest, n, r, d> p;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
/* Register API request */
|
||||
static char n[] = "node";
|
||||
static char r[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")";
|
||||
static char r[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")";
|
||||
static char d[] = "retrieve info of a node";
|
||||
static RequestPlugin<NodeInfoRequest, n, r, d> p;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
/* Register API requests */
|
||||
static char n[] = "node/stats";
|
||||
static char r[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/stats";
|
||||
static char r[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/stats";
|
||||
static char d[] = "get internal statistics counters";
|
||||
static RequestPlugin<StatsRequest, n, r, d> p;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
/* Register API requests */
|
||||
static char n[] = "node/stats/reset";
|
||||
static char r[] = "/node/(" REGEX_NODE_NAME "|" REGEX_UUID ")/stats/reset";
|
||||
static char r[] = "/node/(" RE_NODE_NAME "|" RE_UUID ")/stats/reset";
|
||||
static char d[] = "reset internal statistics counters";
|
||||
static RequestPlugin<StatsRequest, n, r, d> p;
|
||||
|
||||
|
|
|
@ -640,7 +640,7 @@ invalid2:
|
|||
|
||||
bool node_is_valid_name(const char *name)
|
||||
{
|
||||
std::regex re(REGEX_NODE_NAME);
|
||||
std::regex re(RE_NODE_NAME);
|
||||
|
||||
return std::regex_match(name, re);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue