cluster: RHEL56 - fence-agents: Add man pages for ucs, ifmib, rhevm
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: be158e9bd1c3c99475ff4f213c19b1732ab0f14d
Parent: c64fc3e1d5e8f9d92463c5bd500045e3cdf467db
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Dec 16 16:24:44 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Dec 16 16:26:32 2010 -0500
fence-agents: Add man pages for ucs, ifmib, rhevm
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
fence/man/Makefile | 3 +
fence/man/fence_cisco_ucs.8 | 251 +++++++++++++++++++++++++++++++++
fence/man/fence_ifmib.8 | 323 +++++++++++++++++++++++++++++++++++++++++++
fence/man/fence_rhevm.8 | 251 +++++++++++++++++++++++++++++++++
4 files changed, 828 insertions(+), 0 deletions(-)
diff --git a/fence/man/Makefile b/fence/man/Makefile
index 080410e..ad64c0c 100644
--- a/fence/man/Makefile
+++ b/fence/man/Makefile
@@ -39,6 +39,9 @@ TARGET8= \
fence_vmware.8 \
fence_xvm.8 \
fence_xvmd.8 \
+ fence_cisco_ucs.8 \
+ fence_ifmib.8 \
+ fence_rhevm.8 \
fenced.8
UNINSTALL=${top_srcdir}/scripts/uninstall.pl
diff --git a/fence/man/fence_cisco_ucs.8 b/fence/man/fence_cisco_ucs.8
new file mode 100644
index 0000000..6afa32b
--- /dev/null
+++ b/fence/man/fence_cisco_ucs.8
@@ -0,0 +1,251 @@
+
+.TH FENCE_AGENT 8 2009-10-20 "fence_cisco_ucs (Fence Agent)"
+.SH NAME
+fence_cisco_ucs - Fence agent for Cisco UCS
+.SH DESCRIPTION
+.P
+fence_cisco_ucs is an I/O Fencing agent which can be used with Cisco UCS to fence machines.
+.P
+fence_cisco_ucs accepts options on the command line as well
+as from stdin. Fenced sends parameters through stdin when it execs the
+agent. fence_cisco_ucs can be run by itself with command
+line options. This is useful for testing and for turning outlets on or off
+from scripts.
+
+Vendor URL: http://www.cisco.com
+.SH PARAMETERS
+
+
+.TP
+.B -o, --action=<action>
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B -a, --ip=<ip>
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B -l, --username=<name>
+.
+Login Name This parameter is always required.
+
+.TP
+.B -p, --password=<password>
+.
+Login password or passphrase
+
+.TP
+.B -S, --password-script=<script>
+.
+Script to retrieve password
+
+.TP
+.B -z, --ssl
+.
+SSL connection
+
+.TP
+.B -4, --inet4-only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B -6, --inet6-only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B -u, --ipport=<port>
+.
+TCP port to use for connection with device
+
+.TP
+.B -n, --plug=<id>
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B -v, --verbose
+.
+Verbose mode
+
+.TP
+.B -D, --debug-file=<debugfile>
+.
+Write debug information to given file
+
+.TP
+.B -V, --version
+.
+Display version information and exit
+
+.TP
+.B -h, --help
+.
+Display help and exit
+
+.TP
+.B -C, --separator=<char>
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B --power-wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 0)
+
+.TP
+.B --power-timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B --shell-timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B --retry-on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B --delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
+
+.SH ACTIONS
+
+
+.TP
+\fBon \fP
+Power on machine.
+
+.TP
+\fBoff \fP
+Power off machine.
+
+.TP
+\fBreboot \fP
+Reboot machine.
+
+.TP
+\fBstatus \fP
+This returns the status of the plug/virtual machine.
+
+.TP
+\fBlist \fP
+List available plugs with aliases/virtual machines if there is support for more then one device. Returns N/A otherwise.
+
+.TP
+\fBmonitor \fP
+Check if fencing device is running. List available plugs/virtual machines or get status of machine (if it does not support more).
+
+.TP
+\fBmetadata \fP
+ The operational behavior of this is not known.
+
+.SH STDIN PARAMETERS
+
+
+.TP
+.B action
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B ipaddr
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B login
+.
+Login Name This parameter is always required.
+
+.TP
+.B passwd
+.
+Login password or passphrase
+
+.TP
+.B passwd_script
+.
+Script to retrieve password
+
+.TP
+.B ssl
+.
+SSL connection
+
+.TP
+.B inet4_only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B inet6_only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B ipport
+.
+TCP port to use for connection with device
+
+.TP
+.B port
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B verbose
+.
+Verbose mode
+
+.TP
+.B debug
+.
+Write debug information to given file
+
+.TP
+.B version
+.
+Display version information and exit
+
+.TP
+.B help
+.
+Display help and exit
+
+.TP
+.B separator
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B power_wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 0)
+
+.TP
+.B power_timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B shell_timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B retry_on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
diff --git a/fence/man/fence_ifmib.8 b/fence/man/fence_ifmib.8
new file mode 100644
index 0000000..914d43a
--- /dev/null
+++ b/fence/man/fence_ifmib.8
@@ -0,0 +1,323 @@
+
+.TH FENCE_AGENT 8 2009-10-20 "fence_ifmib (Fence Agent)"
+.SH NAME
+fence_ifmib - Fence agent for IF MIB
+.SH DESCRIPTION
+.P
+fence_ifmib is an I/O Fencing agent which can be used with any SNMP IF-MIB capable device.
+.P
+It was written with managed ethernet switches in mind, in order to fence iSCSI SAN connections. However, there are many devices that support the IF-MIB interface. The agent uses IF-MIB::ifAdminStatus to control the state of an interface.
+.P
+fence_ifmib accepts options on the command line as well
+as from stdin. Fenced sends parameters through stdin when it execs the
+agent. fence_ifmib can be run by itself with command
+line options. This is useful for testing and for turning outlets on or off
+from scripts.
+
+Vendor URL: http://www.ietf.org/wg/concluded/ifmib.html
+.SH PARAMETERS
+
+
+.TP
+.B -o, --action=<action>
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B -a, --ip=<ip>
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B -l, --username=<name>
+.
+Login Name
+
+.TP
+.B -p, --password=<password>
+.
+Login password or passphrase
+
+.TP
+.B -S, --password-script=<script>
+.
+Script to retrieve password
+
+.TP
+.B -n, --plug=<id>
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B -d, --snmp-version=<ver>
+.
+Specifies SNMP version to use (1,2c,3)
+
+.TP
+.B -c, --community=<community>
+.
+Set the community string
+
+.TP
+.B -b, --snmp-auth-prot=<prot>
+.
+Set authentication protocol (MD5|SHA)
+
+.TP
+.B -E, --snmp-sec-level=<level>
+.
+Set security level (noAuthNoPriv|authNoPriv|authPriv)
+
+.TP
+.B -B, --snmp-priv-prot=<prot>
+.
+Set privacy protocol (DES|AES)
+
+.TP
+.B -P, --snmp-priv-passwd=<pass>
+.
+Set privacy protocol password
+
+.TP
+.B -R, --snmp-priv-passwd-script
+.
+Script to run to retrieve privacy password
+
+.TP
+.B -u, --udpport
+.
+UDP/TCP port to use for connection with device (Default Value: 161)
+
+.TP
+.B -4, --inet4-only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B -6, --inet6-only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B -v, --verbose
+.
+Verbose mode
+
+.TP
+.B -D, --debug-file=<debugfile>
+.
+Write debug information to given file
+
+.TP
+.B -V, --version
+.
+Display version information and exit
+
+.TP
+.B -h, --help
+.
+Display help and exit
+
+.TP
+.B -C, --separator=<char>
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B --power-timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B --shell-timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B --login-timeout
+.
+Wait X seconds for cmd prompt after login (Default Value: 5)
+
+.TP
+.B --power-wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 0)
+
+.TP
+.B --retry-on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B --delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
+
+.SH ACTIONS
+
+
+.TP
+\fBon \fP
+Power on machine.
+
+.TP
+\fBoff \fP
+Power off machine.
+
+.TP
+\fBreboot \fP
+Reboot machine.
+
+.TP
+\fBstatus \fP
+This returns the status of the plug/virtual machine.
+
+.TP
+\fBlist \fP
+List available plugs with aliases/virtual machines if there is support for more then one device. Returns N/A otherwise.
+
+.TP
+\fBmonitor \fP
+Check if fencing device is running. List available plugs/virtual machines or get status of machine (if it does not support more).
+
+.TP
+\fBmetadata \fP
+ The operational behavior of this is not known.
+
+.SH STDIN PARAMETERS
+
+
+.TP
+.B action
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B ipaddr
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B login
+.
+Login Name
+
+.TP
+.B passwd
+.
+Login password or passphrase
+
+.TP
+.B passwd_script
+.
+Script to retrieve password
+
+.TP
+.B port
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B snmp_version
+.
+Specifies SNMP version to use (1,2c,3)
+
+.TP
+.B community
+.
+Set the community string
+
+.TP
+.B snmp_auth_prot
+.
+Set authentication protocol (MD5|SHA)
+
+.TP
+.B snmp_sec_level
+.
+Set security level (noAuthNoPriv|authNoPriv|authPriv)
+
+.TP
+.B snmp_priv_prot
+.
+Set privacy protocol (DES|AES)
+
+.TP
+.B snmp_priv_passwd
+.
+Set privacy protocol password
+
+.TP
+.B snmp_priv_passwd_script
+.
+Script to run to retrieve privacy password
+
+.TP
+.B udpport
+.
+UDP/TCP port to use for connection with device (Default Value: 161)
+
+.TP
+.B inet4_only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B inet6_only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B verbose
+.
+Verbose mode
+
+.TP
+.B debug
+.
+Write debug information to given file
+
+.TP
+.B version
+.
+Display version information and exit
+
+.TP
+.B help
+.
+Display help and exit
+
+.TP
+.B separator
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B power_timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B shell_timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B login_timeout
+.
+Wait X seconds for cmd prompt after login (Default Value: 5)
+
+.TP
+.B power_wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 0)
+
+.TP
+.B retry_on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
diff --git a/fence/man/fence_rhevm.8 b/fence/man/fence_rhevm.8
new file mode 100644
index 0000000..ce2e259
--- /dev/null
+++ b/fence/man/fence_rhevm.8
@@ -0,0 +1,251 @@
+
+.TH FENCE_AGENT 8 2009-10-20 "fence_rhevm (Fence Agent)"
+.SH NAME
+fence_rhevm - Fence agent for RHEV-M REST API
+.SH DESCRIPTION
+.P
+fence_rhevm is an I/O Fencing agent which can be used with RHEV-M REST API to fence virtual machines.
+.P
+fence_rhevm accepts options on the command line as well
+as from stdin. Fenced sends parameters through stdin when it execs the
+agent. fence_rhevm can be run by itself with command
+line options. This is useful for testing and for turning outlets on or off
+from scripts.
+
+Vendor URL: http://www.redhat.com
+.SH PARAMETERS
+
+
+.TP
+.B -o, --action=<action>
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B -a, --ip=<ip>
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B -l, --username=<name>
+.
+Login Name This parameter is always required.
+
+.TP
+.B -p, --password=<password>
+.
+Login password or passphrase
+
+.TP
+.B -S, --password-script=<script>
+.
+Script to retrieve password
+
+.TP
+.B -z, --ssl
+.
+SSL connection
+
+.TP
+.B -4, --inet4-only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B -6, --inet6-only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B -u, --ipport=<port>
+.
+TCP port to use for connection with device
+
+.TP
+.B -n, --plug=<id>
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B -v, --verbose
+.
+Verbose mode
+
+.TP
+.B -D, --debug-file=<debugfile>
+.
+Write debug information to given file
+
+.TP
+.B -V, --version
+.
+Display version information and exit
+
+.TP
+.B -h, --help
+.
+Display help and exit
+
+.TP
+.B -C, --separator=<char>
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B --power-wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 1)
+
+.TP
+.B --power-timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B --shell-timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B --retry-on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B --delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
+
+.SH ACTIONS
+
+
+.TP
+\fBon \fP
+Power on machine.
+
+.TP
+\fBoff \fP
+Power off machine.
+
+.TP
+\fBreboot \fP
+Reboot machine.
+
+.TP
+\fBstatus \fP
+This returns the status of the plug/virtual machine.
+
+.TP
+\fBlist \fP
+List available plugs with aliases/virtual machines if there is support for more then one device. Returns N/A otherwise.
+
+.TP
+\fBmonitor \fP
+Check if fencing device is running. List available plugs/virtual machines or get status of machine (if it does not support more).
+
+.TP
+\fBmetadata \fP
+ The operational behavior of this is not known.
+
+.SH STDIN PARAMETERS
+
+
+.TP
+.B action
+.
+Fencing Action (Default Value: reboot)
+
+.TP
+.B ipaddr
+.
+IP Address or Hostname This parameter is always required.
+
+.TP
+.B login
+.
+Login Name This parameter is always required.
+
+.TP
+.B passwd
+.
+Login password or passphrase
+
+.TP
+.B passwd_script
+.
+Script to retrieve password
+
+.TP
+.B ssl
+.
+SSL connection
+
+.TP
+.B inet4_only
+.
+Forces agent to use IPv4 addresses only
+
+.TP
+.B inet6_only
+.
+Forces agent to use IPv6 addresses only
+
+.TP
+.B ipport
+.
+TCP port to use for connection with device
+
+.TP
+.B port
+.
+Physical plug number or name of virtual machine This parameter is always required.
+
+.TP
+.B verbose
+.
+Verbose mode
+
+.TP
+.B debug
+.
+Write debug information to given file
+
+.TP
+.B version
+.
+Display version information and exit
+
+.TP
+.B help
+.
+Display help and exit
+
+.TP
+.B separator
+.
+Separator for CSV created by operation list (Default Value: ,)
+
+.TP
+.B power_wait
+.
+Wait X seconds after issuing ON/OFF (Default Value: 1)
+
+.TP
+.B power_timeout
+.
+Test X seconds for status change after ON/OFF (Default Value: 20)
+
+.TP
+.B shell_timeout
+.
+Wait X seconds for cmd prompt after issuing command (Default Value: 3)
+
+.TP
+.B retry_on
+.
+Count of attempts to retry power on (Default Value: 1)
+
+.TP
+.B delay
+.
+Wait X seconds before fencing is started (Default Value: 0)
13 years, 4 months
cluster: STABLE31 - Fixed hep for 'addservice' command
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 3d4a7dfc91ce99fe879855c952f4a60875d6397d
Parent: 7018f0c23a7782b21be33a4e3eb21b7a60146c1d
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 17 14:54:51 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Fri Dec 17 13:17:54 2010 +0100
Fixed hep for 'addservice' command
Sorry, missed it in 'addservice' addition patch series.
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/editconf.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index a443831..9477d4e 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -236,6 +236,13 @@ static void addnode_usage(const char *name)
static void addservice_usage(const char *name)
{
fprintf(stderr, "Usage: %s %s [options] <servicename>\n", prog_name, name);
+ fprintf(stderr, " -a --autostart Start the service on boot\n");
+ fprintf(stderr, " -d --domain Failover domain for the service\n");
+ fprintf(stderr, " -x --exclusive Do not run other services on the same server\n");
+ fprintf(stderr, " -r --recovery Recovery policy\n");
+ fprintf(stderr, " -f --fs Filesystem resource for the service\n");
+ fprintf(stderr, " -s --script Script resource for the service\n");
+ fprintf(stderr, " -i --ip IP address resource for the service\n");
config_usage(1);
help_usage();
13 years, 4 months
cluster: STABLE31 - qdisk: Assume 1 vote if not specified in cluster.conf
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 7018f0c23a7782b21be33a4e3eb21b7a60146c1d
Parent: e39bb6348295c8d3f69b2d1fd30691a67c40445c
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Dec 15 13:28:42 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Dec 15 13:36:34 2010 -0500
qdisk: Assume 1 vote if not specified in cluster.conf
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/qdisk/main.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 6a9b821..617a705 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1386,10 +1386,11 @@ auto_qdisk_votes(int desc)
"/cluster/clusternodes/clusternode[%d]/@votes", ret);
name = NULL;
- if (ccs_get(desc, buf, &name) != 0)
- break;
+ if (ccs_get(desc, buf, &name) == 0)
+ votes = atoi(name);
+ else
+ votes = 1;
- votes=atoi(name);
if (votes != 1) {
free(name);
13 years, 4 months
cluster: STABLE31 - Added ability to reference domains from services
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: e39bb6348295c8d3f69b2d1fd30691a67c40445c
Parent: 612d65819bc6e840483bb3b4f1ac9f10a7e5d0fb
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:37 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:04:11 2010 +0100
Added ability to reference domains from services
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/editconf.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index 516b338..a443831 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -44,6 +44,7 @@ struct option_info
const char *exclusive;
const char *recovery;
const char *fs;
+ const char *domain;
const char *script;
const char *mountpoint;
const char *type;
@@ -696,6 +697,7 @@ static void add_clusterservice(xmlNode *root_element, struct option_info *ninfo,
{
xmlNode *rm;
xmlNode *rs;
+ xmlNode *fdomains;
xmlNode *newnode;
xmlNode *newfs = NULL;
@@ -712,6 +714,7 @@ static void add_clusterservice(xmlNode *root_element, struct option_info *ninfo,
ninfo->configfile);
rs = findnode(rm, "resources");
+ fdomains = findnode(rm, "failoverdomains");
if (ninfo->fs && (!rs || !find_fs_resource(rs, ninfo->fs)))
die("fs resource %s doesn't exist in %s\n", ninfo->fs,
ninfo->configfile);
@@ -721,11 +724,16 @@ static void add_clusterservice(xmlNode *root_element, struct option_info *ninfo,
if (ninfo->ip_addr && (!rs || !find_ip_resource(rs, ninfo->ip_addr)))
die("ip resource %s doesn't exist in %s\n", ninfo->ip_addr,
ninfo->configfile);
+ if (ninfo->domain && (!fdomains || !find_fdomain_resource(fdomains, ninfo->domain)))
+ die("failover domain %s doesn't exist in %s\n", ninfo->domain,
+ ninfo->configfile);
/* Add the new service */
newnode = xmlNewNode(NULL, BAD_CAST "service");
xmlSetProp(newnode, BAD_CAST "name", BAD_CAST ninfo->name);
xmlSetProp(newnode, BAD_CAST "autostart", BAD_CAST ninfo->autostart);
+ if (ninfo->domain)
+ xmlSetProp(newnode, BAD_CAST "domain", BAD_CAST ninfo->domain);
if (ninfo->exclusive)
xmlSetProp(newnode, BAD_CAST "exclusive",
BAD_CAST ninfo->exclusive);
@@ -1137,6 +1145,7 @@ struct option create_options[] =
struct option addservice_options[] =
{
{ "autostart", required_argument, NULL, 'a'},
+ { "domain", required_argument, NULL, 'd'},
{ "exclusive", required_argument, NULL, 'x'},
{ "recovery", required_argument, NULL, 'r'},
{ "fs", required_argument, NULL, 'f'},
@@ -1530,7 +1539,7 @@ void add_service(int argc, char **argv)
ninfo.autostart = "1";
ninfo.recovery = "relocate";
- while ( (opt = getopt_long(argc, argv, "a:x:r:f:o:c:s:i:CFh?", addservice_options, NULL)) != EOF)
+ while ( (opt = getopt_long(argc, argv, "a:d:x:r:f:o:c:s:i:CFh?", addservice_options, NULL)) != EOF)
{
switch(opt)
{
@@ -1539,6 +1548,10 @@ void add_service(int argc, char **argv)
ninfo.autostart = optarg;
break;
+ case 'd':
+ ninfo.domain = strdup(optarg);
+ break;
+
case 'x':
validate_int_arg(opt, optarg);
ninfo.exclusive = optarg;
13 years, 4 months
cluster: STABLE31 - Added 'failoverdomain' object manipulations
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 612d65819bc6e840483bb3b4f1ac9f10a7e5d0fb
Parent: ee6d8eb5ad118c239009174627d9a4b4a99edb5e
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:36 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:04:05 2010 +0100
Added 'failoverdomain' object manipulations
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/ccs_tool.c | 21 +++-
config/tools/ccs_tool/editconf.c | 281 +++++++++++++++++++++++++++++++++++++-
config/tools/ccs_tool/editconf.h | 2 +
3 files changed, 294 insertions(+), 10 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 92a7dac..28bbadc 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -257,6 +257,14 @@ static int tool_main(int argc, char *argv[])
del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "addfdomain")){
+ add_fdomain(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
+ else if(!strcmp(argv[optind], "delfdomain")){
+ del_node(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "addfence")){
add_fence(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -289,6 +297,10 @@ static int tool_main(int argc, char *argv[])
list_fs(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "lsfdomains")){
+ list_fdomains(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "create")){
create_skeleton(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -339,9 +351,12 @@ static void tool_print_usage(FILE *stream){
" addip <name> Add an IP address resource\n"
" delip <name> Delete an IP address resource\n"
" lsip List IP address resources\n"
- " addfs <name> Add an IP address resource\n"
- " delfs <name> Delete an IP address resource\n"
- " lsfs List IP address resources\n"
+ " addfs <name> Add an filesystem resource\n"
+ " delfs <name> Delete an filesystem resource\n"
+ " lsfs List filesystem resources\n"
+ " addfdomain <name> Add an failover domain\n"
+ " delfdomain <name> Delete an failover domain\n"
+ " lsfdomains List failover domains\n"
" create Create a skeleton config file\n"
" addnodeids Assign node ID numbers to all nodes\n"
"\n");
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index ac522d8..516b338 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -25,6 +25,12 @@ do { \
} while (0)
+#define INT_TO_CHAR(x, str) \
+ if (str && atoi((const char *)str)) \
+ x = '*'; \
+ else \
+ x = ' ';
+
struct option_info
{
const char *name;
@@ -45,10 +51,13 @@ struct option_info
const char *options;
const char *configfile;
const char *outputfile;
+ const char **failover_nodes;
int do_delete;
int force_fsck;
int force_unmount;
int self_fence;
+ int ordered;
+ int restricted;
};
static void config_usage(int rw)
@@ -170,6 +179,20 @@ static void addfs_usage(const char *name)
exit(0);
}
+static void addfdomain_usage(const char *name)
+{
+ fprintf(stderr, "Usage: %s %s [options] <name> <node1> ... <nodeN>\n",
+ prog_name, name);
+ fprintf(stderr, " -p --ordered Allows you to specify a preference order\n");
+ fprintf(stderr, " among the members of a failover domain\n");
+ fprintf(stderr, " -r --restricted Allows you to restrict the members that can\n");
+ fprintf(stderr, " run a particular cluster service.\n");
+ 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");
@@ -454,7 +477,7 @@ static xmlNode *do_find_node(xmlNode *root, const char *nodename,
strcmp((char *)cur_node->name, elem_name) == 0)
{
xmlChar *name = xmlGetProp(cur_node, BAD_CAST attrib_name);
- if (strcmp((char *)name, nodename) == 0)
+ if (name && strcmp((char *)name, nodename) == 0)
return cur_node;
}
}
@@ -496,6 +519,11 @@ static xmlNode *find_fs_resource(xmlNode *root, const char *name)
return do_find_node(root, name, "fs", "name");
}
+static xmlNode *find_fdomain_resource(xmlNode *root, const char *name)
+{
+ return do_find_node(root, name, "failoverdomain", "name");
+}
+
static xmlNode *find_script_resource(xmlNode *root, const char *name)
{
return do_find_node(root, name, "script", "name");
@@ -521,6 +549,24 @@ static xmlNode *find_fs_ref(xmlNode *root, const char *name)
return do_find_resource_ref(root, name, "fs");
}
+static xmlNode *find_fdomain_ref(xmlNode *root, const char *name)
+{
+ xmlNode *cur_node;
+
+ for (cur_node = root->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp((char *)cur_node->name, "service") == 0)
+ {
+ xmlChar *domain = xmlGetProp(cur_node, BAD_CAST "domain");
+ if (domain && strcmp(name, (char *)domain) == 0)
+ return cur_node;
+ }
+ }
+
+ return NULL;
+}
+
/* Print name=value pairs for a (n XML) node.
* "ignore" is a string to ignore if present as a property (probably already printed on the main line)
*/
@@ -751,6 +797,56 @@ static void add_clusterfs(xmlNode *root_element, struct option_info *ninfo,
xmlAddChild(rs, node);
}
+static void add_clusterfdomain(xmlNode *root_element, struct option_info *ninfo,
+ int argc, char **argv, int optindex)
+{
+ xmlNode *rm;
+ xmlNode *fdomains;
+ xmlNode *node;
+ xmlNode *cn;
+ int i = 0;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo->configfile);
+
+ fdomains = findnode(rm, "failoverdomains");
+ if (!fdomains)
+ die("Can't find \"failoverdomains\" %s\n", ninfo->configfile);
+
+ cn = findnode(root_element, "clusternodes");
+ if (!cn)
+ die("Can't find \"clusternodes\" in %s\n", ninfo->configfile);
+
+ /* Check it doesn't already exist */
+ if (find_fdomain_resource(fdomains, ninfo->name))
+ die("failover domain %s already exists\n", ninfo->name);
+
+ /* Check that nodes are defined */
+ while (ninfo->failover_nodes[i]) {
+ if (!find_node(cn, ninfo->failover_nodes[i]))
+ die("Can't find node %s in %s.\n",
+ ninfo->failover_nodes[i], ninfo->configfile);
+ i++;
+ }
+
+ /* Add the new failover domain */
+ node = xmlNewNode(NULL, BAD_CAST "failoverdomain");
+ xmlSetProp(node, BAD_CAST "name", BAD_CAST ninfo->name);
+ _xmlSetIntProp(node, "ordered", ninfo->ordered);
+ _xmlSetIntProp(node, "restricted", ninfo->restricted);
+
+ i = 0;
+ while (ninfo->failover_nodes[i]) {
+ xmlNode *fnode = xmlNewNode(NULL, BAD_CAST "failoverdomainnode");
+ xmlSetProp(fnode, BAD_CAST "name", BAD_CAST ninfo->failover_nodes[i]);
+ _xmlSetIntProp(fnode, "priority", i + 1);
+ xmlAddChild(node, fnode);
+ i++;
+ }
+ xmlAddChild(fdomains, node);
+}
+
static xmlDoc *open_configfile(struct option_info *ninfo)
{
xmlDoc *doc;
@@ -934,6 +1030,45 @@ static void del_clusterfs(xmlNode *root_element, struct option_info *ninfo)
xmlUnlinkNode(node);
}
+static void del_clusterfdomain(xmlNode *root_element, struct option_info *ninfo)
+{
+ xmlNode *rm, *fdomains;
+ xmlNode *node;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ {
+ fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ fdomains = findnode(rm, "failoverdomains");
+ if (!fdomains)
+ {
+ fprintf(stderr, "Can't find \"failoverdomains\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ /* Check that not used */
+ node = find_fdomain_ref(rm, ninfo->name);
+ if (node)
+ {
+ fprintf(stderr, "failover domain %s is referenced in service in %s,"
+ " please remove reference first.\n", ninfo->name,
+ ninfo->configfile);
+ exit(1);
+ }
+
+ node = find_fdomain_resource(fdomains, ninfo->name);
+ if (!node)
+ {
+ fprintf(stderr, "failover domain %s does not exist in %s\n", ninfo->name, ninfo->configfile);
+ exit(1);
+ }
+
+ xmlUnlinkNode(node);
+}
+
struct option addnode_options[] =
{
{ "votes", required_argument, NULL, 'v'},
@@ -957,6 +1092,15 @@ struct option addfs_options[] =
{ NULL, 0, NULL, 0 },
};
+struct option addfdomain_options[] =
+{
+ { "outputfile", required_argument, NULL, 'o'},
+ { "configfile", required_argument, NULL, 'c'},
+ { "ordered", no_argument, NULL, 'p'},
+ { "restricted", no_argument, NULL, 'r'},
+ { NULL, 0, NULL, 0 },
+};
+
struct option commonw_options[] =
{
{ "outputfile", required_argument, NULL, 'o'},
@@ -1287,6 +1431,8 @@ void del_node(int argc, char **argv)
del_clusterip(root_element, &ninfo);
else if (!strcmp(argv[0], "delfs"))
del_clusterfs(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delfdomain"))
+ del_clusterfdomain(root_element, &ninfo);
/* Write it out */
save_file(doc, &ninfo);
@@ -1683,6 +1829,64 @@ void add_fs(int argc, char **argv)
xmlCleanupParser();
}
+void add_fdomain(int argc, char **argv)
+{
+ struct option_info ninfo;
+ xmlDoc *doc;
+ xmlNode *root_element;
+ int opt, i;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "pro:c:CFh?", addfdomain_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'p':
+ ninfo.ordered = 1;
+ break;
+
+ case 'r':
+ ninfo.restricted = 1;
+ break;
+
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+
+ case 'o':
+ ninfo.outputfile = strdup(optarg);
+ break;
+
+ case '?':
+ default:
+ addfdomain_usage(argv[0]);
+ }
+ }
+
+ if (optind < argc - 1) {
+ ninfo.name = strdup(argv[optind]);
+ ninfo.failover_nodes = (const char **)malloc(sizeof(char *) * (argc - optind));
+ for (i = 0; i < argc - optind - 1; i++)
+ ninfo.failover_nodes[i] = strdup(argv[i + optind + 1]);
+ ninfo.failover_nodes[i] = NULL;
+ } else
+ addfdomain_usage(argv[0]);
+
+ doc = open_configfile(&ninfo);
+
+ root_element = xmlDocGetRootElement(doc);
+
+ increment_version(root_element);
+
+ add_clusterfdomain(root_element, &ninfo, argc, argv, optind);
+
+ /* Write it out */
+ save_file(doc, &ninfo);
+ /* Shutdown libxml */
+ xmlCleanupParser();
+}
+
void create_skeleton(int argc, char **argv)
{
char *fencename = NULL;
@@ -2066,17 +2270,80 @@ void list_fs(int argc, char **argv)
BAD_CAST "mountpoint");
char f, u, s;
-#define INT_TO_CHAR(x, str) \
- if (str && atoi((const char *)str)) \
- x = '*'; \
- else \
- x = ' ';
INT_TO_CHAR(f, force_fsck)
INT_TO_CHAR(u, force_unmount)
INT_TO_CHAR(s, self_fence)
-#undef INT_TO_CHAR
printf("%-16.16s %-5.5s %c%c%c %-19.19s %s\n", name, type, f, u,
s, device, mnt);
}
}
}
+
+void list_fdomains(int argc, char **argv)
+{
+ xmlNode *cur_node, *fnode;
+ xmlNode *root_element;
+ xmlNode *rm, *fdomains;
+ xmlDocPtr doc;
+ struct option_info ninfo;
+ int opt;
+ int verbose=0;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case '?':
+ default:
+ list_usage(argv[0]);
+ }
+ }
+ doc = open_configfile(&ninfo);
+ root_element = xmlDocGetRootElement(doc);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo.configfile);
+
+ fdomains = findnode(rm, "failoverdomains");
+ if (!fdomains)
+ die("Can't find \"failoverdomains\" in %s\n", ninfo.configfile);
+
+ printf("Name OR Nodes\n");
+ for (cur_node = fdomains->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp((char *)cur_node->name, "failoverdomain") == 0)
+ {
+ xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
+ xmlChar *ordered = xmlGetProp(cur_node, BAD_CAST "ordered");
+ xmlChar *restricted = xmlGetProp(cur_node, BAD_CAST "restricted");
+ char o, r;
+ int first_node = 1;
+
+ INT_TO_CHAR(o, ordered)
+ INT_TO_CHAR(r, restricted)
+ printf("%-16.16s %c%c ", name, o, r);
+ for (fnode = cur_node->children; fnode; fnode = fnode->next)
+ if (fnode->type == XML_ELEMENT_NODE &&
+ strcmp((char *)fnode->name, "failoverdomainnode") == 0)
+ {
+ xmlChar *fname = xmlGetProp(fnode, BAD_CAST "name");
+ if (first_node) {
+ printf("%s", fname);
+ first_node = 0;
+ } else
+ printf(",%s", fname);
+ }
+ printf("\n");
+ }
+ }
+}
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index 3d1f5c2..7edd52f 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -4,6 +4,7 @@ void add_service(int argc, char **argv);
void add_script(int argc, char **argv);
void add_ip(int argc, char **argv);
void add_fs(int argc, char **argv);
+void add_fdomain(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
void del_fence(int argc, char **argv);
@@ -13,4 +14,5 @@ void list_fences(int argc, char **argv);
void list_scripts(int argc, char **argv);
void list_ips(int argc, char **argv);
void list_fs(int argc, char **argv);
+void list_fdomains(int argc, char **argv);
void create_skeleton(int argc, char **argv);
13 years, 4 months
cluster: STABLE31 - Added 'fs' object manipulations
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: ee6d8eb5ad118c239009174627d9a4b4a99edb5e
Parent: b0abb7690eecba37c2212773adb5f00c3f60434a
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:35 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:03:59 2010 +0100
Added 'fs' object manipulations
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/ccs_tool.c | 15 ++
config/tools/ccs_tool/editconf.c | 264 ++++++++++++++++++++++++++++++++++++++
config/tools/ccs_tool/editconf.h | 2 +
3 files changed, 281 insertions(+), 0 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 9df5445..92a7dac 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -249,6 +249,14 @@ static int tool_main(int argc, char *argv[])
del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "addfs")){
+ add_fs(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
+ else if(!strcmp(argv[optind], "delfs")){
+ del_node(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "addfence")){
add_fence(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -277,6 +285,10 @@ static int tool_main(int argc, char *argv[])
list_ips(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "lsfs")){
+ list_fs(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "create")){
create_skeleton(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -327,6 +339,9 @@ static void tool_print_usage(FILE *stream){
" addip <name> Add an IP address resource\n"
" delip <name> Delete an IP address resource\n"
" lsip List IP address resources\n"
+ " addfs <name> Add an IP address resource\n"
+ " delfs <name> Delete an IP address resource\n"
+ " lsfs List IP address resources\n"
" create Create a skeleton config file\n"
" addnodeids Assign node ID numbers to all nodes\n"
"\n");
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index 9f7709b..ac522d8 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -40,9 +40,15 @@ struct option_info
const char *fs;
const char *script;
const char *mountpoint;
+ const char *type;
+ const char *device;
+ const char *options;
const char *configfile;
const char *outputfile;
int do_delete;
+ int force_fsck;
+ int force_unmount;
+ int self_fence;
};
static void config_usage(int rw)
@@ -148,6 +154,22 @@ static void addip_usage(const char *name)
exit(0);
}
+static void addfs_usage(const char *name)
+{
+ fprintf(stderr, "Usage: %s %s [options] <name> <device> <mountpoint>\n",
+ prog_name, name);
+ fprintf(stderr, " -t --type Type of the filesystem (ext3, ext4, etc.)\n");
+ fprintf(stderr, " Default type is ext3.\n");
+ fprintf(stderr, " -p --options Mount options\n");
+ fprintf(stderr, " -k --force_fsck Force fsck before mount\n");
+ fprintf(stderr, " -u --force_unmount Call umount with force flag\n");
+ fprintf(stderr, " -s --self_fence Use 'self_fence' feature\n");
+ 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");
@@ -323,6 +345,13 @@ static void increment_version(xmlNode *root_element)
xmlSetProp(root_element, BAD_CAST "config_version", BAD_CAST newver);
}
+static void _xmlSetIntProp(xmlNode *element, const char *property, const int value)
+{
+ char buf[32];
+ snprintf(buf, sizeof(buf), "%d", value);
+ xmlSetProp(element, BAD_CAST property, BAD_CAST buf);
+}
+
static xmlNode *findnode(xmlNode *root, const char *name)
{
xmlNode *cur_node;
@@ -487,6 +516,11 @@ static xmlNode *find_ip_ref(xmlNode *root, const char *name)
return do_find_resource_ref(root, name, "ip");
}
+static xmlNode *find_fs_ref(xmlNode *root, const char *name)
+{
+ return do_find_resource_ref(root, name, "fs");
+}
+
/* Print name=value pairs for a (n XML) node.
* "ignore" is a string to ignore if present as a property (probably already printed on the main line)
*/
@@ -684,6 +718,39 @@ static void add_clusterservice(xmlNode *root_element, struct option_info *ninfo,
}
}
+static void add_clusterfs(xmlNode *root_element, struct option_info *ninfo,
+ int argc, char **argv, int optindex)
+{
+ xmlNode *rm;
+ xmlNode *rs;
+ xmlNode *node;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo->configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" %s\n", ninfo->configfile);
+
+ /* Check it doesn't already exist */
+ if (find_fs_resource(rs, ninfo->name))
+ die("fs %s already exists\n", ninfo->name);
+
+ /* Add the new fs resource */
+ node = xmlNewNode(NULL, BAD_CAST "fs");
+ xmlSetProp(node, BAD_CAST "device", BAD_CAST ninfo->device);
+ _xmlSetIntProp(node, "force_fsck", ninfo->force_fsck);
+ _xmlSetIntProp(node, "force_unmount", ninfo->force_unmount);
+ xmlSetProp(node, BAD_CAST "fstype", BAD_CAST ninfo->type);
+ xmlSetProp(node, BAD_CAST "mountpoint", BAD_CAST ninfo->mountpoint);
+ xmlSetProp(node, BAD_CAST "name", BAD_CAST ninfo->name);
+ xmlSetProp(node, BAD_CAST "options", (ninfo->options) ?
+ BAD_CAST ninfo->options : BAD_CAST "");
+ _xmlSetIntProp(node, "self_fence", ninfo->self_fence);
+ xmlAddChild(rs, node);
+}
+
static xmlDoc *open_configfile(struct option_info *ninfo)
{
xmlDoc *doc;
@@ -828,6 +895,45 @@ static void del_clusterip(xmlNode *root_element, struct option_info *ninfo)
xmlUnlinkNode(node);
}
+static void del_clusterfs(xmlNode *root_element, struct option_info *ninfo)
+{
+ xmlNode *rm, *rs;
+ xmlNode *node;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ {
+ fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ {
+ fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ /* Check that not used */
+ node = find_fs_ref(rm, ninfo->name);
+ if (node)
+ {
+ fprintf(stderr, "fs %s is referenced in service in %s,"
+ " please remove reference first.\n", ninfo->name,
+ ninfo->configfile);
+ exit(1);
+ }
+
+ node = find_fs_resource(rs, ninfo->name);
+ if (!node)
+ {
+ fprintf(stderr, "fs %s does not exist in %s\n", ninfo->name, ninfo->configfile);
+ exit(1);
+ }
+
+ xmlUnlinkNode(node);
+}
+
struct option addnode_options[] =
{
{ "votes", required_argument, NULL, 'v'},
@@ -839,6 +945,18 @@ struct option addnode_options[] =
{ NULL, 0, NULL, 0 },
};
+struct option addfs_options[] =
+{
+ { "type", required_argument, NULL, 't'},
+ { "options", required_argument, NULL, 'p'},
+ { "outputfile", required_argument, NULL, 'o'},
+ { "configfile", required_argument, NULL, 'c'},
+ { "force_fsck", no_argument, NULL, 'k'},
+ { "force_unmount", no_argument, NULL, 'u'},
+ { "self_fence", no_argument, NULL, 's'},
+ { NULL, 0, NULL, 0 },
+};
+
struct option commonw_options[] =
{
{ "outputfile", required_argument, NULL, 'o'},
@@ -1167,6 +1285,8 @@ void del_node(int argc, char **argv)
del_clusterscript(root_element, &ninfo);
else if (!strcmp(argv[0], "delip"))
del_clusterip(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delfs"))
+ del_clusterfs(root_element, &ninfo);
/* Write it out */
save_file(doc, &ninfo);
@@ -1492,6 +1612,77 @@ void add_ip(int argc, char **argv)
xmlCleanupParser();
}
+void add_fs(int argc, char **argv)
+{
+ struct option_info ninfo;
+ xmlDoc *doc;
+ xmlNode *root_element;
+ int opt;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "t:p:o:c:CFh?kus", addfs_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 't':
+ ninfo.type = strdup(optarg);
+ break;
+
+ case 'p':
+ ninfo.options = strdup(optarg);
+ break;
+
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+
+ case 'o':
+ ninfo.outputfile = strdup(optarg);
+ break;
+
+ case 'k':
+ ninfo.force_fsck = 1;
+ break;
+
+ case 'u':
+ ninfo.force_unmount = 1;
+ break;
+
+ case 's':
+ ninfo.self_fence = 1;
+ break;
+
+ case '?':
+ default:
+ addfs_usage(argv[0]);
+ }
+ }
+
+ if (optind < argc - 2) {
+ ninfo.name = strdup(argv[optind]);
+ ninfo.device = strdup(argv[optind + 1]);
+ ninfo.mountpoint = strdup(argv[optind + 2]);
+ } else
+ addfs_usage(argv[0]);
+
+ if (!ninfo.type)
+ ninfo.type = "ext3";
+
+ doc = open_configfile(&ninfo);
+
+ root_element = xmlDocGetRootElement(doc);
+
+ increment_version(root_element);
+
+ add_clusterfs(root_element, &ninfo, argc, argv, optind);
+
+ /* Write it out */
+ save_file(doc, &ninfo);
+ /* Shutdown libxml */
+ xmlCleanupParser();
+}
+
void create_skeleton(int argc, char **argv)
{
char *fencename = NULL;
@@ -1816,3 +2007,76 @@ void list_ips(int argc, char **argv)
}
}
}
+
+void list_fs(int argc, char **argv)
+{
+ xmlNode *cur_node;
+ xmlNode *root_element;
+ xmlNode *rm, *rs;
+ xmlDocPtr doc;
+ struct option_info ninfo;
+ int opt;
+ int verbose=0;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case '?':
+ default:
+ list_usage(argv[0]);
+ }
+ }
+ doc = open_configfile(&ninfo);
+ root_element = xmlDocGetRootElement(doc);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo.configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" in %s\n", ninfo.configfile);
+
+ printf("Name Type FUS Device Mountpoint\n");
+ for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp((char *)cur_node->name, "fs") == 0)
+ {
+ xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
+ xmlChar *type = xmlGetProp(cur_node, BAD_CAST "fstype");
+ xmlChar *force_fsck = xmlGetProp(cur_node,
+ BAD_CAST "force_fsck");
+ xmlChar *force_unmount = xmlGetProp(cur_node,
+ BAD_CAST "force_unmount");
+ xmlChar *self_fence = xmlGetProp(cur_node,
+ BAD_CAST "self_fence");
+ xmlChar *device = xmlGetProp(cur_node,
+ BAD_CAST "device");
+ xmlChar *mnt = xmlGetProp(cur_node,
+ BAD_CAST "mountpoint");
+
+ char f, u, s;
+#define INT_TO_CHAR(x, str) \
+ if (str && atoi((const char *)str)) \
+ x = '*'; \
+ else \
+ x = ' ';
+ INT_TO_CHAR(f, force_fsck)
+ INT_TO_CHAR(u, force_unmount)
+ INT_TO_CHAR(s, self_fence)
+#undef INT_TO_CHAR
+ printf("%-16.16s %-5.5s %c%c%c %-19.19s %s\n", name, type, f, u,
+ s, device, mnt);
+ }
+ }
+}
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index a1119d7..3d1f5c2 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -3,6 +3,7 @@ void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
void add_script(int argc, char **argv);
void add_ip(int argc, char **argv);
+void add_fs(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
void del_fence(int argc, char **argv);
@@ -11,4 +12,5 @@ void list_services(int argc, char **argv);
void list_fences(int argc, char **argv);
void list_scripts(int argc, char **argv);
void list_ips(int argc, char **argv);
+void list_fs(int argc, char **argv);
void create_skeleton(int argc, char **argv);
13 years, 4 months
cluster: STABLE31 - Added "ip" object manipulations
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: b0abb7690eecba37c2212773adb5f00c3f60434a
Parent: 0a5157723b6c7b47935b2c7231dbf7f0d5372a48
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:34 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:03:52 2010 +0100
Added "ip" object manipulations
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/ccs_tool.c | 17 ++++-
config/tools/ccs_tool/editconf.c | 155 +++++++++++++++++++++++++++++++++++++-
config/tools/ccs_tool/editconf.h | 2 +
3 files changed, 172 insertions(+), 2 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 9726da2..9df5445 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -241,6 +241,14 @@ static int tool_main(int argc, char *argv[])
del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "addip")){
+ add_ip(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
+ else if(!strcmp(argv[optind], "delip")){
+ del_node(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "addfence")){
add_fence(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -265,6 +273,10 @@ static int tool_main(int argc, char *argv[])
list_scripts(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "lsip")){
+ list_ips(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "create")){
create_skeleton(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -311,7 +323,10 @@ static void tool_print_usage(FILE *stream){
" delfence <fencedev> Delete a fence device\n"
" addscript <name> Add a script resource\n"
" delscript <name> Delete a script resource\n"
- " lsscript List script resources\n"
+ " lsscript List script resources\n"
+ " addip <name> Add an IP address resource\n"
+ " delip <name> Delete an IP address resource\n"
+ " lsip List IP address resources\n"
" create Create a skeleton config file\n"
" addnodeids Assign node ID numbers to all nodes\n"
"\n");
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index 9d81593..9f7709b 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -138,6 +138,16 @@ static void addscript_usage(const char *name)
exit(0);
}
+static void addip_usage(const char *name)
+{
+ fprintf(stderr, "Usage: %s %s [options] <IP_address>\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");
@@ -469,7 +479,12 @@ static xmlNode *find_script_ref(xmlNode *root, const char *name)
static xmlNode *find_ip_resource(xmlNode *root, const char *name)
{
- return do_find_node(root, name, "ip", "name");
+ return do_find_node(root, name, "ip", "address");
+}
+
+static xmlNode *find_ip_ref(xmlNode *root, const char *name)
+{
+ return do_find_resource_ref(root, name, "ip");
}
/* Print name=value pairs for a (n XML) node.
@@ -774,6 +789,45 @@ static void del_clusterscript(xmlNode *root_element, struct option_info *ninfo)
xmlUnlinkNode(node);
}
+static void del_clusterip(xmlNode *root_element, struct option_info *ninfo)
+{
+ xmlNode *rm, *rs;
+ xmlNode *node;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ {
+ fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ {
+ fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ /* Check that not used */
+ node = find_ip_ref(rm, ninfo->name);
+ if (node)
+ {
+ fprintf(stderr, "IP %s is referenced in service in %s,"
+ " please remove reference first.\n", ninfo->name,
+ ninfo->configfile);
+ exit(1);
+ }
+
+ node = find_ip_resource(rs, ninfo->name);
+ if (!node)
+ {
+ fprintf(stderr, "IP %s does not exist in %s\n", ninfo->name, ninfo->configfile);
+ exit(1);
+ }
+
+ xmlUnlinkNode(node);
+}
+
struct option addnode_options[] =
{
{ "votes", required_argument, NULL, 'v'},
@@ -1111,6 +1165,8 @@ void del_node(int argc, char **argv)
del_clusterservice(root_element, &ninfo);
else if (!strcmp(argv[0], "delscript"))
del_clusterscript(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delip"))
+ del_clusterip(root_element, &ninfo);
/* Write it out */
save_file(doc, &ninfo);
@@ -1390,6 +1446,52 @@ void add_script(int argc, char **argv)
xmlCleanupParser();
}
+void add_ip(int argc, char **argv)
+{
+ struct option_info ninfo;
+ xmlDoc *doc;
+ xmlNode *root_element;
+ xmlNode *rm, *rs, *node;
+
+ if (parse_commonw_options(argc, argv, &ninfo))
+ addip_usage(argv[0]);
+
+ if (optind < argc)
+ ninfo.ip_addr = strdup(argv[optind]);
+ else
+ addip_usage(argv[0]);
+
+ doc = open_configfile(&ninfo);
+
+ root_element = xmlDocGetRootElement(doc);
+
+ increment_version(root_element);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" %s\n", ninfo.configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" %s\n", ninfo.configfile);
+
+ /* Check it doesn't already exist */
+ if (find_ip_resource(rs, ninfo.ip_addr))
+ die("IP %s already exists\n", ninfo.ip_addr);
+
+ /* Add it */
+ node = xmlNewNode(NULL, BAD_CAST "ip");
+ xmlSetProp(node, BAD_CAST "address", BAD_CAST ninfo.ip_addr);
+ xmlSetProp(node, BAD_CAST "monitor_link", BAD_CAST "1");
+ xmlAddChild(rs, node);
+
+ /* Write it out */
+ save_file(doc, &ninfo);
+
+ /* Shutdown libxml */
+ xmlCleanupParser();
+}
+
void create_skeleton(int argc, char **argv)
{
char *fencename = NULL;
@@ -1663,3 +1765,54 @@ void list_scripts(int argc, char **argv)
}
}
}
+
+void list_ips(int argc, char **argv)
+{
+ xmlNode *cur_node;
+ xmlNode *root_element;
+ xmlNode *rm, *rs;
+ xmlDocPtr doc;
+ struct option_info ninfo;
+ int opt;
+ int verbose=0;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case '?':
+ default:
+ list_usage(argv[0]);
+ }
+ }
+ doc = open_configfile(&ninfo);
+ root_element = xmlDocGetRootElement(doc);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo.configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" in %s\n", ninfo.configfile);
+
+ printf("IP\n");
+ for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp((char *)cur_node->name, "ip") == 0)
+ {
+ xmlChar *ip = xmlGetProp(cur_node, BAD_CAST "address");
+
+ printf("%s\n", ip);
+ }
+ }
+}
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index c83af1d..a1119d7 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -2,6 +2,7 @@ void add_node(int argc, char **argv);
void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
void add_script(int argc, char **argv);
+void add_ip(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
void del_fence(int argc, char **argv);
@@ -9,4 +10,5 @@ void list_nodes(int argc, char **argv);
void list_services(int argc, char **argv);
void list_fences(int argc, char **argv);
void list_scripts(int argc, char **argv);
+void list_ips(int argc, char **argv);
void create_skeleton(int argc, char **argv);
13 years, 4 months
cluster: STABLE31 - Unify parsing of options
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 0a5157723b6c7b47935b2c7231dbf7f0d5372a48
Parent: 7b43e51272eb8727ab3f121d7bd0f08d09e21051
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:33 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:03:46 2010 +0100
Unify parsing of options
This patch unifies options parsing for operations, which changes config and
supports only standard options.
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/editconf.c | 125 ++++++++++---------------------------
1 files changed, 34 insertions(+), 91 deletions(-)
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index e431bb3..9d81593 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -785,14 +785,7 @@ struct option addnode_options[] =
{ NULL, 0, NULL, 0 },
};
-struct option delnode_options[] =
-{
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { NULL, 0, NULL, 0 },
-};
-
-struct option addfence_options[] =
+struct option commonw_options[] =
{
{ "outputfile", required_argument, NULL, 'o'},
{ "configfile", required_argument, NULL, 'c'},
@@ -838,12 +831,32 @@ struct option addservice_options[] =
{ NULL, 0, NULL, 0 },
};
-struct option delservice_options[] =
+static int parse_commonw_options(int argc, char **argv,
+ struct option_info *ninfo)
{
- { "outputfile", required_argument, NULL, 'o'},
- { "configfile", required_argument, NULL, 'c'},
- { NULL, 0, NULL, 0 },
-};
+ int opt;
+
+ memset(ninfo, 0, sizeof(*ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "o:c:CFh?", commonw_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo->configfile = strdup(optarg);
+ break;
+
+ case 'o':
+ ninfo->outputfile = strdup(optarg);
+ break;
+
+ case '?':
+ default:
+ return 1;
+ }
+ }
+ return 0;
+}
static int next_nodeid(int startid, int *nodeids, int nodecount)
{
@@ -1074,29 +1087,11 @@ void add_node(int argc, char **argv)
void del_node(int argc, char **argv)
{
struct option_info ninfo;
- int opt;
xmlDoc *doc;
xmlNode *root_element;
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "o:c:CFh?", delnode_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- delnode_usage(argv[0]);
- }
- }
+ if (parse_commonw_options(argc, argv, &ninfo))
+ delnode_usage(argv[0]);
/* Get node name parameter */
if (optind < argc)
@@ -1350,32 +1345,14 @@ void list_services(int argc, char **argv)
void add_script(int argc, char **argv)
{
struct option_info ninfo;
- int opt;
xmlDoc *doc;
xmlNode *root_element;
xmlNode *rm, *rs, *node;
char *name;
char *sc_file;
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "o:c:CFh?", addfence_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- addscript_usage(argv[0]);
- }
- }
+ if (parse_commonw_options(argc, argv, &ninfo))
+ addscript_usage(argv[0]);
if (argc - optind < 2)
addscript_usage(argv[0]);
@@ -1515,26 +1492,9 @@ void add_fence(int argc, char **argv)
char *fencename;
char *agentname;
struct option_info ninfo;
- int opt;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "c:o:CFh?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
- case '?':
- default:
- addfence_usage(argv[0]);
- }
- }
+ if (parse_commonw_options(argc, argv, &ninfo))
+ addfence_usage(argv[0]);
if (argc - optind < 2)
addfence_usage(argv[0]);
@@ -1577,26 +1537,9 @@ void del_fence(int argc, char **argv)
xmlDocPtr doc;
char *fencename;
struct option_info ninfo;
- int opt;
-
- memset(&ninfo, 0, sizeof(ninfo));
- while ( (opt = getopt_long(argc, argv, "c:o:CFhv?", list_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- delfence_usage(argv[0]);
- }
- }
+ if (parse_commonw_options(argc, argv, &ninfo))
+ delfence_usage(argv[0]);
if (argc - optind < 1)
delfence_usage(argv[0]);
13 years, 4 months
cluster: STABLE31 - Add "script" object manipulations
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 7b43e51272eb8727ab3f121d7bd0f08d09e21051
Parent: 8e40d4619198c34f6dadf6197bc7fa7b4598e6ce
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:32 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:03:39 2010 +0100
Add "script" object manipulations
Script object is used when one needs to perform some actions on service
relocation event. This patch adds ability to add, delete and list scripts in
cluster config.
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/ccs_tool.c | 15 +++
config/tools/ccs_tool/editconf.c | 192 ++++++++++++++++++++++++++++++++++++++
config/tools/ccs_tool/editconf.h | 2 +
3 files changed, 209 insertions(+), 0 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 8062549..9726da2 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -233,6 +233,14 @@ static int tool_main(int argc, char *argv[])
del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "addscript")){
+ add_script(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
+ else if(!strcmp(argv[optind], "delscript")){
+ del_node(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "addfence")){
add_fence(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -253,6 +261,10 @@ static int tool_main(int argc, char *argv[])
list_fences(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
+ else if(!strcmp(argv[optind], "lsscript")){
+ list_scripts(argc-1, argv+1);
+ exit(EXIT_SUCCESS);
+ }
else if(!strcmp(argv[optind], "create")){
create_skeleton(argc-1, argv+1);
exit(EXIT_SUCCESS);
@@ -297,6 +309,9 @@ static void tool_print_usage(FILE *stream){
" lsfence List fence devices\n"
" addfence <fencedev> Add a new fence device\n"
" delfence <fencedev> Delete a fence device\n"
+ " addscript <name> Add a script resource\n"
+ " delscript <name> Delete a script resource\n"
+ " lsscript List script resources\n"
" create Create a skeleton config file\n"
" addnodeids Assign node ID numbers to all nodes\n"
"\n");
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index d68f395..e431bb3 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -128,6 +128,16 @@ static void delnode_usage(const char *name)
exit(0);
}
+static void addscript_usage(const char *name)
+{
+ fprintf(stderr, "Usage: %s %s [options] <name> <path_to_script>\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");
@@ -412,6 +422,26 @@ static xmlNode *do_find_node(xmlNode *root, const char *nodename,
return NULL;
}
+static xmlNode *do_find_resource_ref(xmlNode *root, const char *name,
+ const char *res_type)
+{
+ xmlNode *cur_node;
+ xmlNode *res = NULL;
+
+ for (cur_node = root->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE &&
+ strcmp((char *)cur_node->name, "service") == 0)
+ {
+ res = do_find_node(cur_node, name, res_type, "ref");
+ if (res)
+ break;
+ }
+ }
+
+ return res;
+}
+
static xmlNode *find_node(xmlNode *clusternodes, const char *nodename)
{
return do_find_node(clusternodes, nodename, "clusternode", "name");
@@ -432,6 +462,11 @@ static xmlNode *find_script_resource(xmlNode *root, const char *name)
return do_find_node(root, name, "script", "name");
}
+static xmlNode *find_script_ref(xmlNode *root, const char *name)
+{
+ return do_find_resource_ref(root, name, "script");
+}
+
static xmlNode *find_ip_resource(xmlNode *root, const char *name)
{
return do_find_node(root, name, "ip", "name");
@@ -700,6 +735,45 @@ static void del_clusterservice(xmlNode *root_element, struct option_info *ninfo)
xmlUnlinkNode(oldnode);
}
+static void del_clusterscript(xmlNode *root_element, struct option_info *ninfo)
+{
+ xmlNode *rm, *rs;
+ xmlNode *node;
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ {
+ fprintf(stderr, "Can't find \"rm\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ {
+ fprintf(stderr, "Can't find \"resources\" in %s\n", ninfo->configfile);
+ exit(1);
+ }
+
+ /* Check that not used */
+ node = find_script_ref(rm, ninfo->name);
+ if (node)
+ {
+ fprintf(stderr, "Script %s is referenced in service in %s,"
+ " please remove reference first.\n", ninfo->name,
+ ninfo->configfile);
+ exit(1);
+ }
+
+ node = find_script_resource(rs, ninfo->name);
+ if (!node)
+ {
+ fprintf(stderr, "Script %s does not exist in %s\n", ninfo->name, ninfo->configfile);
+ exit(1);
+ }
+
+ xmlUnlinkNode(node);
+}
+
struct option addnode_options[] =
{
{ "votes", required_argument, NULL, 'v'},
@@ -1040,6 +1114,8 @@ void del_node(int argc, char **argv)
del_clusternode(root_element, &ninfo);
else if (!strcmp(argv[0], "delservice"))
del_clusterservice(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delscript"))
+ del_clusterscript(root_element, &ninfo);
/* Write it out */
save_file(doc, &ninfo);
@@ -1271,6 +1347,72 @@ void list_services(int argc, char **argv)
}
}
+void add_script(int argc, char **argv)
+{
+ struct option_info ninfo;
+ int opt;
+ xmlDoc *doc;
+ xmlNode *root_element;
+ xmlNode *rm, *rs, *node;
+ char *name;
+ char *sc_file;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "o:c:CFh?", addfence_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+
+ case 'o':
+ ninfo.outputfile = strdup(optarg);
+ break;
+
+ case '?':
+ default:
+ addscript_usage(argv[0]);
+ }
+ }
+
+ if (argc - optind < 2)
+ addscript_usage(argv[0]);
+
+ doc = open_configfile(&ninfo);
+
+ root_element = xmlDocGetRootElement(doc);
+
+ increment_version(root_element);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" %s\n", ninfo.configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" %s\n", ninfo.configfile);
+
+ /* First param is the script name - check it doesn't already exist */
+ name = argv[optind++];
+ if (find_script_resource(rs, name))
+ die("Script %s already exists\n", name);
+ sc_file = argv[optind++];
+
+ /* Add it */
+ node = xmlNewNode(NULL, BAD_CAST "script");
+ xmlSetProp(node, BAD_CAST "file", BAD_CAST sc_file);
+ xmlSetProp(node, BAD_CAST "name", BAD_CAST name);
+ xmlAddChild(rs, node);
+
+ /* Write it out */
+ save_file(doc, &ninfo);
+
+ /* Shutdown libxml */
+ xmlCleanupParser();
+}
+
void create_skeleton(int argc, char **argv)
{
char *fencename = NULL;
@@ -1528,3 +1670,53 @@ void list_fences(int argc, char **argv)
}
}
+void list_scripts(int argc, char **argv)
+{
+ xmlNode *cur_node;
+ xmlNode *root_element;
+ xmlNode *rm, *rs;
+ xmlDocPtr doc;
+ struct option_info ninfo;
+ int opt;
+ int verbose=0;
+
+ memset(&ninfo, 0, sizeof(ninfo));
+
+ while ( (opt = getopt_long(argc, argv, "c:hv?", list_options, NULL)) != EOF)
+ {
+ switch(opt)
+ {
+ case 'c':
+ ninfo.configfile = strdup(optarg);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ case '?':
+ default:
+ list_usage(argv[0]);
+ }
+ }
+ doc = open_configfile(&ninfo);
+ root_element = xmlDocGetRootElement(doc);
+
+ rm = findnode(root_element, "rm");
+ if (!rm)
+ die("Can't find \"rm\" in %s\n", ninfo.configfile);
+
+ rs = findnode(rm, "resources");
+ if (!rs)
+ die("Can't find \"resources\" in %s\n", ninfo.configfile);
+
+ printf("Name Path\n");
+ for (cur_node = rs->children; cur_node; cur_node = cur_node->next)
+ {
+ if (cur_node->type == XML_ELEMENT_NODE && strcmp((char *)cur_node->name, "script") == 0)
+ {
+ xmlChar *name = xmlGetProp(cur_node, BAD_CAST "name");
+ xmlChar *path = xmlGetProp(cur_node, BAD_CAST "file");
+
+ printf("%-16s %s\n", name, path);
+ }
+ }
+}
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index 0090ab6..c83af1d 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -1,10 +1,12 @@
void add_node(int argc, char **argv);
void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
+void add_script(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(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);
void list_fences(int argc, char **argv);
+void list_scripts(int argc, char **argv);
void create_skeleton(int argc, char **argv);
13 years, 4 months
cluster: STABLE31 - Unify 'del' functions
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8e40d4619198c34f6dadf6197bc7fa7b4598e6ce
Parent: 38b2f70644bad9fb01c61e51e839a1b95efea09e
Author: Dmitry Mishin <dim(a)parallels.com>
AuthorDate: Fri Dec 10 16:42:31 2010 +0300
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Dec 15 09:03:31 2010 +0100
Unify 'del' functions
No need to keep 2 copies with almost the same logic inside - better to add if..
else clause.
Signed-off-by: Dmitry Mishin <dim(a)parallels.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
config/tools/ccs_tool/ccs_tool.c | 2 +-
config/tools/ccs_tool/editconf.c | 59 ++-----------------------------------
config/tools/ccs_tool/editconf.h | 1 -
3 files changed, 5 insertions(+), 57 deletions(-)
diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 2fe6f78..8062549 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -230,7 +230,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 d63dc37..d68f395 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -128,15 +128,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");
@@ -1045,7 +1036,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);
@@ -1209,51 +1203,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));
-
- 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 '?':
- 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);
13 years, 4 months