[Ocfs2-tools-commits] jlbec commits r1076 - branches/global-heartbeat/o2cb_ctl

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Sep 6 21:48:14 CDT 2005


Author: jlbec
Date: 2005-09-06 21:48:13 -0500 (Tue, 06 Sep 2005)
New Revision: 1076

Modified:
   branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c
Log:

o Add remove



Modified: branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c
===================================================================
--- branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c	2005-09-07 01:55:25 UTC (rev 1075)
+++ branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c	2005-09-07 02:48:13 UTC (rev 1076)
@@ -582,6 +582,74 @@
     return rc;
 }
 
+static gint hbconf_remove(HBConfContext *ctxt)
+{
+    gint rc = 0;
+    JIterator *iter;
+    JConfigStanza *cfs;
+    JConfigMatch *match;
+
+    if (!ctxt->c_dev && !ctxt->c_uuid)
+    {
+        fprintf(stderr,
+                PROGNAME ": Missing arguments.\n");
+        print_usage(-EINVAL);
+    }
+
+    if (ctxt->c_dev && ctxt->c_uuid)
+    {
+        fprintf(stderr,
+                PROGNAME ": Only specify one of \'-d\' and \'-u\'.\n");
+        print_usage(-EINVAL);
+    }
+
+    if (ctxt->c_dev)
+    {
+        if (!ctxt->c_layout)
+        {
+            fprintf(stderr,
+                    PROGNAME ": Layout required to remove by device.\n");
+            rc = -EINVAL;
+            goto out;
+        }
+
+        rc = dev_to_uuid(ctxt->c_layout, ctxt->c_dev, &ctxt->c_uuid);
+        if (rc)
+            goto out;
+    }
+
+    match = j_config_match_build(1, "uuid", ctxt->c_uuid);
+    iter = j_config_get_stanzas(ctxt->c_cf, "region", match, 1);
+    g_free(match);
+    if (!j_iterator_has_more(iter))
+    {
+        fprintf(stderr,
+                PROGNAME ": Region \"%s\" is not configured.\n",
+                ctxt->c_uuid);
+        rc = -ENOENT;
+    }
+
+    while (j_iterator_has_more(iter))
+    {
+        cfs = (JConfigStanza *)j_iterator_get_next(iter);
+        j_config_delete_stanza(ctxt->c_cf, cfs);
+    }
+    j_iterator_free(iter);
+    if (rc)
+        goto out;
+
+    rc = hbconf_config_store(ctxt, HB_CONFIG_FILE);
+    if (rc)
+    {
+        fprintf(stderr,
+                PROGNAME ": Error storing \"%s\": %s\n",
+                HB_CONFIG_FILE, strerror(-rc));
+    }
+
+out:
+    return rc;
+}
+
 static void print_usage(gint rc)
 {
     FILE *output = rc ? stderr : stdout;
@@ -590,7 +658,7 @@
             "Usage: " PROGNAME " -M [-c <cluster>] [-o|-z]\n"
             "       " PROGNAME " -M -c <cluster> -m <mode>\n"
             "       " PROGNAME " -A -c <cluster> -l <layout> {-u <uuid> | -d <device>}\n"
-            "       " PROGNAME " -R -c <cluster>\n");
+            "       " PROGNAME " -R {-u <uuid> | -d <device>}\n");
 
     exit(rc);
 }
@@ -736,6 +804,10 @@
             rc = hbconf_add(&ctxt);
             break;
 
+        case HBCONF_OP_REMOVE:
+            rc = hbconf_remove(&ctxt);
+            break;
+
         default:
             fprintf(stderr, PROGNAME ": Can't get here!  op %d\n",
                     ctxt.c_op);



More information about the Ocfs2-tools-commits mailing list