[Ocfs2-tools-commits] jlbec commits r685 - trunk/o2cb_ctl
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Mar 18 16:44:08 CST 2005
Author: jlbec
Signed-off-by: manish
Date: 2005-03-18 16:44:06 -0600 (Fri, 18 Mar 2005)
New Revision: 685
Modified:
trunk/o2cb_ctl/o2cb_config.c
trunk/o2cb_ctl/o2cb_config.h
Log:
o Make the add_{node,cluster} APIs a little smarter.
Signed-off-by: manish
Modified: trunk/o2cb_ctl/o2cb_config.c
===================================================================
--- trunk/o2cb_ctl/o2cb_config.c 2005-03-18 21:41:26 UTC (rev 684)
+++ trunk/o2cb_ctl/o2cb_config.c 2005-03-18 22:44:06 UTC (rev 685)
@@ -82,13 +82,18 @@
gulong val;
gint rc;
+ rc = -EINVAL;
+ name = j_config_get_attribute(cfs, "name");
+ if (!name || !*name)
+ goto out_error;
+
/* NB: _add_node() gives us a node number, but we're going to
* override it, because we know better. */
- node = o2cb_cluster_add_node(cluster);
+ node = o2cb_cluster_add_node(cluster, name);
if (!node)
return -ENOMEM;
- num_s = name = addr = port_s = NULL;
+ num_s = addr = port_s = NULL;
rc = -EINVAL;
num_s = j_config_get_attribute(cfs, "number");
@@ -103,14 +108,6 @@
node->n_number = val;
rc = -EINVAL;
- name = j_config_get_attribute(cfs, "name");
- if (!name || !*name)
- goto out_error;
- rc = o2cb_node_set_name(node, name);
- if (rc)
- goto out_error;
-
- rc = -EINVAL;
addr = j_config_get_attribute(cfs, "ip_address");
if (!addr || !*addr)
goto out_error;
@@ -155,14 +152,10 @@
if (!match.value && !*match.value)
goto out_error;
- cluster = o2cb_config_add_cluster(config);
+ cluster = o2cb_config_add_cluster(config, match.value);
if (!cluster)
goto out_error;
- rc = o2cb_cluster_set_name(cluster, match.value);
- if (rc)
- goto out_error;
-
rc = -ENOMEM;
iter = j_config_get_stanzas(cf, "node", &match, 1);
if (!iter)
@@ -415,7 +408,8 @@
g_free(config);
}
-O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config)
+O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config,
+ const gchar *name)
{
O2CBCluster *cluster;
@@ -423,7 +417,7 @@
cluster = g_new(O2CBCluster, 1);
- cluster->c_name = NULL;
+ cluster->c_name = g_strdup(name);
cluster->c_num_nodes = 0;
cluster->c_nodes = NULL;
@@ -432,7 +426,7 @@
config->co_valid = TRUE;
return cluster;
-} /* o2cb_cluster_add_node() */
+} /* o2cb_cluster_add_cluster() */
O2CBCluster *o2cb_config_get_cluster_by_name(O2CBConfig *config,
const gchar *name)
@@ -528,7 +522,8 @@
return NULL;
} /* o2cb_cluster_get_node_by_name() */
-O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster)
+O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
+ const gchar *name)
{
O2CBNode *node;
@@ -536,7 +531,7 @@
node = g_new(O2CBNode, 1);
- node->n_name = NULL;
+ node->n_name = g_strdup(name);
node->n_addr = NULL;
node->n_port = 0;
node->n_number = cluster->c_num_nodes;
Modified: trunk/o2cb_ctl/o2cb_config.h
===================================================================
--- trunk/o2cb_ctl/o2cb_config.h 2005-03-18 21:41:26 UTC (rev 684)
+++ trunk/o2cb_ctl/o2cb_config.h 2005-03-18 22:44:06 UTC (rev 685)
@@ -34,7 +34,8 @@
gint o2cb_config_store(O2CBConfig *config, const gchar *filename);
void o2cb_config_free(O2CBConfig *config);
-O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config);
+O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config,
+ const gchar *name);
void o2cb_config_delete_cluster(O2CBConfig *config,
O2CBCluster *cluster);
JIterator *o2cb_config_get_clusters(O2CBConfig *config);
@@ -47,7 +48,8 @@
O2CBNode *o2cb_cluster_get_node(O2CBCluster *cluster, guint n);
O2CBNode *o2cb_cluster_get_node_by_name(O2CBCluster *cluster,
const gchar *name);
-O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster);
+O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
+ const gchar *name);
void o2cb_cluster_delete_node(O2CBCluster *cluster, O2CBNode *node);
gint o2cb_node_get_number(O2CBNode *node);
More information about the Ocfs2-tools-commits
mailing list