summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 78921c3)
raw | patch | inline | side by side (parent: 78921c3)
author | daryder <daryder@cisco.com> | |
Fri, 4 Apr 2014 14:03:59 +0000 (10:03 -0400) | ||
committer | daryder <daryder@cisco.com> | |
Fri, 4 Apr 2014 14:03:59 +0000 (10:03 -0400) |
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index e1653bf7692098de97de462372d62cf0805160be..76c220e59747b00f535b22386d0ccba24399d83e 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
@@ -392,24 +392,82 @@ static int cc_handle_str(struct oconfig_item_s *item, char *dest, int dest_len)
return 0;
}
+static int cc_add_daemon_config(oconfig_item_t *ci)
+{
+ int ret, i;
+ struct ceph_daemon *array, *nd, cd;
+ memset(&cd, 0, sizeof(struct ceph_daemon));
+
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
+ {
+ WARNING("ceph plugin: `Daemon' blocks need exactly one string argument.");
+ return (-1);
+ }
+
+ ret = cc_handle_str(ci, cd.name, DATA_MAX_NAME_LEN);
+ if (ret)
+ return ret;
+
+ for (i=0; i < ci->children_num; i++)
+ {
+ oconfig_item_t *child = ci->children + i;
+
+ if (strcasecmp("SocketPath", child->key) == 0)
+ {
+ ret = cc_handle_str(child, cd.asok_path, sizeof(cd.asok_path));
+ if (ret)
+ return ret;
+ }
+ else
+ {
+ WARNING("ceph plugin: ignoring unknown option %s", child->key);
+ }
+ }
+ if (cd.name[0] == '\0')
+ {
+ ERROR("ceph plugin: you must configure a daemon name.\n");
+ return -EINVAL;
+ }
+ else if (cd.asok_path[0] == '\0')
+ {
+ ERROR("ceph plugin(name=%s): you must configure an administrative "
+ "socket path.\n", cd.name);
+ return -EINVAL;
+ }
+ else if (!((cd.asok_path[0] == '/')
+ || (cd.asok_path[0] == '.' && cd.asok_path[1] == '/')))
+ {
+ ERROR("ceph plugin(name=%s): administrative socket paths must begin with "
+ "'/' or './' Can't parse: '%s'\n", cd.name, cd.asok_path);
+ return -EINVAL;
+ }
+ array = realloc(g_daemons,
+ sizeof(struct ceph_daemon *) * (g_num_daemons + 1));
+ if (array == NULL)
+ {
+ /* The positive return value here indicates that this is a
+ * runtime error, not a configuration error. */
+ return ENOMEM;
+ }
+ g_daemons = (struct ceph_daemon**) array;
+ nd = malloc(sizeof(struct ceph_daemon));
+ if (!nd)
+ return ENOMEM;
+ memcpy(nd, &cd, sizeof(struct ceph_daemon));
+ g_daemons[g_num_daemons++] = nd;
+ return 0;
+}
+
static int ceph_config(oconfig_item_t *ci)
{
int ret, i;
- struct ceph_daemon *array, *nd, cd;
- memset(&cd, 0, sizeof(struct ceph_daemon));
for (i = 0; i < ci->children_num; ++i)
{
oconfig_item_t *child = ci->children + i;
- if (strcasecmp("Name", child->key) == 0)
+ if (strcasecmp("Daemon", child->key) == 0)
{
- ret = cc_handle_str(child, cd.name, DATA_MAX_NAME_LEN);
- if (ret)
- return ret;
- }
- else if (strcasecmp("SocketPath", child->key) == 0)
- {
- ret = cc_handle_str(child, cd.asok_path, sizeof(cd.asok_path));
+ ret = cc_add_daemon_config(child);
if (ret)
return ret;
}
WARNING("ceph plugin: ignoring unknown option %s", child->key);
}
}
- if (cd.name[0] == '\0')
- {
- ERROR("ceph plugin: you must configure a daemon name.\n");
- return -EINVAL;
- }
- else if (cd.asok_path[0] == '\0')
- {
- ERROR("ceph plugin(name=%s): you must configure an administrative "
- "socket path.\n", cd.name);
- return -EINVAL;
- }
- else if (!((cd.asok_path[0] == '/')
- || (cd.asok_path[0] == '.' && cd.asok_path[1] == '/')))
- {
- ERROR("ceph plugin(name=%s): administrative socket paths must begin with "
- "'/' or './' Can't parse: '%s'\n", cd.name, cd.asok_path);
- return -EINVAL;
- }
- array = realloc(g_daemons,
- sizeof(struct ceph_daemon *) * (g_num_daemons + 1));
- if (array == NULL)
- {
- /* The positive return value here indicates that this is a
- * runtime error, not a configuration error. */
- return ENOMEM;
- }
- g_daemons = (struct ceph_daemon**) array;
- nd = malloc(sizeof(struct ceph_daemon));
- if (!nd)
- return ENOMEM;
- memcpy(nd, &cd, sizeof(struct ceph_daemon));
- g_daemons[g_num_daemons++] = nd;
return 0;
}