From: Dmitry Mishin <dim@parallels.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/8] Unify 'del' functions
Date: Fri, 10 Dec 2010 12:00:07 +0300 [thread overview]
Message-ID: <1291971613-13076-3-git-send-email-dim@parallels.com> (raw)
In-Reply-To: <1291971613-13076-1-git-send-email-dim@parallels.com>
No need to keep 2 copies with almost the same logic inside - better to add if..
else clause.
Signed-off-by: Dmitry Mishin <dim@parallels.com>
---
config/tools/ccs_tool/ccs_tool.c | 2 +-
config/tools/ccs_tool/editconf.c | 68 ++-----------------------------------
config/tools/ccs_tool/editconf.h | 1 -
3 files changed, 5 insertions(+), 66 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 824da6d..12d447c 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -232,7 +232,7 @@ static int tool_main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "delservice")){
- del_service(argc-1, argv+1);
+ del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "addfence")){
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index b33f288..a4ef407 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -130,15 +130,6 @@ static void delnode_usage(const char *name)
exit(0);
}
-static void delservice_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name>\n", prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
static void addnodeid_usage(const char *name)
{
fprintf(stderr, "Add node IDs to all nodes in the config file that don't have them.\n");
@@ -1067,7 +1058,10 @@ void del_node(int argc, char **argv)
increment_version(root_element);
- del_clusternode(root_element, &ninfo);
+ if (!strcmp(argv[0], "delnode"))
+ del_clusternode(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delservice"))
+ del_clusterservice(root_element, &ninfo);
/* Write it out */
save_file(doc, &ninfo);
@@ -1240,60 +1234,6 @@ void add_service(int argc, char **argv)
}
-void del_service(int argc, char **argv)
-{
- struct option_info ninfo;
- int opt;
- xmlDoc *doc;
- xmlNode *root_element;
-
- memset(&ninfo, 0, sizeof(ninfo));
- ninfo.tell_ccsd = 1;
-
- while ( (opt = getopt_long(argc, argv, "o:c:CFh?", delservice_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case 'C':
- ninfo.tell_ccsd = 0;
- break;
-
- case 'F':
- ninfo.force_ccsd = 1;
- break;
-
- case '?':
- default:
- delservice_usage(argv[0]);
- }
- }
-
- /* Get service name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- delservice_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
-
- increment_version(root_element);
-
- del_clusterservice(root_element, &ninfo);
-
- /* Write it out */
- save_file(doc, &ninfo);
-}
-
void list_services(int argc, char **argv)
{
xmlNode *cur_service;
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index be8945e..0090ab6 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -3,7 +3,6 @@ void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
-void del_service(int argc, char **argv);
void del_fence(int argc, char **argv);
void list_nodes(int argc, char **argv);
void list_services(int argc, char **argv);
--
1.7.1
next prev parent reply other threads:[~2010-12-10 9:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 9:00 [Cluster-devel] [PATCH 0/8] ccs_tool enhancement Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 1/8] Add "service" object manipulations Dmitry Mishin
2010-12-10 9:00 ` Dmitry Mishin [this message]
2010-12-10 9:00 ` [Cluster-devel] [PATCH 3/8] Add "script" " Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 4/8] Unify parsing of options Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 5/8] Added "ip" object manipulations Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 6/8] Added 'fs' " Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 7/8] Added 'failoverdomain' " Dmitry Mishin
2010-12-10 9:00 ` [Cluster-devel] [PATCH 8/8] Added ability to reference domains from services Dmitry Mishin
2010-12-10 9:12 ` [Cluster-devel] [PATCH 0/8] ccs_tool enhancement Fabio M. Di Nitto
2010-12-10 9:37 ` Dmitry Mishin
2010-12-10 9:36 ` Fabio M. Di Nitto
-- strict thread matches above, loose matches on Subject: below --
2010-12-10 13:42 [Cluster-devel] [PATCH 0/8] [STABLE31] sccs_tool enhancement Dmitry Mishin
2010-12-10 13:42 ` [Cluster-devel] [PATCH 2/8] Unify 'del' functions Dmitry Mishin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291971613-13076-3-git-send-email-dim@parallels.com \
--to=dim@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).