[SCM] CTDB repository - branch master updated -
ctdb-1.0.57-28-g647003d
Ronnie Sahlberg
sahlberg at samba.org
Mon Sep 22 15:39:38 GMT 2008
The branch, master has been updated
via 647003da975d4823abe8ed2bfb46153d68ea0fb0 (commit)
from a06abf6bff6c4d379453e5063d8de1a6542c982a (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 647003da975d4823abe8ed2bfb46153d68ea0fb0
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Tue Sep 23 01:38:28 2008 +1000
Check that a database exists first before we dump its content (and
implicitely also create it) using 'ctdb catdb'
-----------------------------------------------------------------------
Summary of changes:
doc/onnode.1 | 333 ++++++++++------------------------------------------------
tools/ctdb.c | 34 ++++++
2 files changed, 88 insertions(+), 279 deletions(-)
Changeset truncated at 500 lines:
diff --git a/doc/onnode.1 b/doc/onnode.1
index 0ebf532..a4e6014 100644
--- a/doc/onnode.1
+++ b/doc/onnode.1
@@ -1,349 +1,132 @@
.\" Title: onnode
-.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
-.\" Generator: DocBook XSL Stylesheets v1.74.0 <http://docbook.sf.net/>
-.\" Date: 07/11/2008
-.\" Manual: [FIXME: manual]
-.\" Source: [FIXME: source]
-.\" Language: English
+.\" Author:
+.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
+.\" Date: 09/23/2008
+.\" Manual:
+.\" Source:
.\"
-.TH "ONNODE" "1" "07/11/2008" "[FIXME: source]" "[FIXME: manual]"
-.\" -----------------------------------------------------------------
-.\" * (re)Define some macros
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" toupper - uppercase a string (locale-aware)
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de toupper
-.tr aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
-\\$*
-.tr aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SH-xref - format a cross-reference to an SH section
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de SH-xref
-.ie n \{\
-.\}
-.toupper \\$*
-.el \{\
-\\$*
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SH - level-one heading that works better for non-TTY output
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de1 SH
-.\" put an extra blank line of space above the head in non-TTY output
-.if t \{\
-.sp 1
-.\}
-.sp \\n[PD]u
-.nr an-level 1
-.set-an-margin
-.nr an-prevailing-indent \\n[IN]
-.fi
-.in \\n[an-margin]u
-.ti 0
-.HTML-TAG ".NH \\n[an-level]"
-.it 1 an-trap
-.nr an-no-space-flag 1
-.nr an-break-flag 1
-\." make the size of the head bigger
-.ps +3
-.ft B
-.ne (2v + 1u)
-.ie n \{\
-.\" if n (TTY output), use uppercase
-.toupper \\$*
-.\}
-.el \{\
-.nr an-break-flag 0
-.\" if not n (not TTY), use normal case (not uppercase)
-\\$1
-.in \\n[an-margin]u
-.ti 0
-.\" if not n (not TTY), put a border/line under subheading
-.sp -.6
-\l'\n(.lu'
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" SS - level-two heading that works better for non-TTY output
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de1 SS
-.sp \\n[PD]u
-.nr an-level 1
-.set-an-margin
-.nr an-prevailing-indent \\n[IN]
-.fi
-.in \\n[IN]u
-.ti \\n[SN]u
-.it 1 an-trap
-.nr an-no-space-flag 1
-.nr an-break-flag 1
-.ps \\n[PS-SS]u
-\." make the size of the head bigger
-.ps +2
-.ft B
-.ne (2v + 1u)
-.if \\n[.$] \&\\$*
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" BB/BE - put background/screen (filled box) around block of text
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de BB
-.if t \{\
-.sp -.5
-.br
-.in +2n
-.ll -2n
-.gcolor red
-.di BX
-.\}
-..
-.de EB
-.if t \{\
-.if "\\$2"adjust-for-leading-newline" \{\
-.sp -1
-.\}
-.br
-.di
-.in
-.ll
-.gcolor
-.nr BW \\n(.lu-\\n(.i
-.nr BH \\n(dn+.5v
-.ne \\n(BHu+.5v
-.ie "\\$2"adjust-for-leading-newline" \{\
-\M[\\$1]\h'1n'\v'+.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
-.\}
-.el \{\
-\M[\\$1]\h'1n'\v'-.5v'\D'P \\n(BWu 0 0 \\n(BHu -\\n(BWu 0 0 -\\n(BHu'\M[]
-.\}
-.in 0
-.sp -.5v
-.nf
-.BX
-.in
-.sp .5v
-.fi
-.\}
-..
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" BM/EM - put colored marker in margin next to block of text
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.de BM
-.if t \{\
-.br
-.ll -2n
-.gcolor red
-.di BX
-.\}
-..
-.de EM
-.if t \{\
-.br
-.di
-.ll
-.gcolor
-.nr BH \\n(dn
-.ne \\n(BHu
-\M[\\$1]\D'P -.75n 0 0 \\n(BHu -(\\n[.i]u - \\n(INu - .75n) 0 0 -\\n(BHu'\M[]
-.in 0
-.nf
-.BX
-.in
-.fi
-.\}
-..
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
+.TH "ONNODE" "1" "09/23/2008" "" ""
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "Name"
-onnode \- run commands on ctdb nodes
-.SH "Synopsis"
-.fam C
-.HP \w'\fBonnode\ [OPTION]\ \&.\&.\&.\ NODES\ COMMAND\ \&.\&.\&.\fR\ 'u
-\fBonnode [OPTION] \&.\&.\&. NODES COMMAND \&.\&.\&.\fR
-.fam
+.SH "NAME"
+onnode - run commands on ctdb nodes
+.SH "SYNOPSIS"
+.HP 38
+\fBonnode [OPTION] \.\.\. NODES COMMAND \.\.\.\fR
.SH "DESCRIPTION"
.PP
-onnode is a utility to run commands on a specific node of a CTDB cluster, or on all nodes\&.
+onnode is a utility to run commands on a specific node of a CTDB cluster, or on all nodes\.
+.PP
+The NODES option specifies which node to run a command on\. You can specify a numeric node number (from 0 to N\-1) or a descriptive node specification (see DESCRIPTIVE NODE SPECIFICATIONS below)\. You can also specify lists of nodes, separated by commas, and ranges of numeric node numbers, separated by dashes\. If nodes are specified multiple times then the command will be executed multiple times on those nodes\. The order of nodes is significant\.
+.PP
+The COMMAND can be any shell command\. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command\.
+.SH "DESCRIPTIVE NODE SPECIFICATIONS"
+.PP
+The following descriptive node specification can be used in place of numeric node numbers:
+.PP
+all
+.RS 4
+All nodes\.
+.RE
+.PP
+ok | healthy
+.RS 4
+All nodes that are not disconnected, banned, disabled or unhealthy\.
+.RE
.PP
-The NODES option specifies which node to run a command on\&. You can specify a numeric node number (from 0 to N\-1) or the special node \'all\'\&. You can also specify lists of nodes, separated by commas, and ranges of numeric node numbers, separated by dashes\&. If nodes are specified multiple times then the command will be executed multiple times on those nodes\&. The order of nodes is significant\&.
+con | connected
+.RS 4
+All nodes that are not disconnected\.
+.RE
.PP
-The COMMAND can be any shell command\&. The onnode utility uses ssh or rsh to connect to the remote nodes and run the command\&.
+rm | recmaster
+.RS 4
+The current recovery master\.
+.RE
.SH "OPTIONS"
.PP
\-c
.RS 4
-Execute COMMAND in the current working directory on the specified nodes\&.
+Execute COMMAND in the current working directory on the specified nodes\.
.RE
.PP
\-p
.RS 4
-Run COMMAND in parallel on the specified nodes\&. The default is to run COMMAND sequentially on each node\&.
+Run COMMAND in parallel on the specified nodes\. The default is to run COMMAND sequentially on each node\.
.RE
.PP
\-q
.RS 4
-Do not print node addresses\&. Normally, onnode prints informational node addresses if more than one node is specified\&. This overrides \-v\&.
+Do not print node addresses\. Normally, onnode prints informational node addresses if more than one node is specified\. This overrides \-v\.
.RE
.PP
\-v
.RS 4
-Print a node addresses even if only one node is specified\&. Normally, onnode prints informational node addresses when more than one node is specified\&.
+Print a node addresses even if only one node is specified\. Normally, onnode prints informational node addresses when more than one node is specified\.
.RE
.PP
\-h, \-\-help
.RS 4
-Show a short usage guide\&.
+Show a short usage guide\.
.RE
.SH "EXAMPLES"
.PP
The following command would show the process ID of ctdb on all nodes
.sp
-.if n \{\
.RS 4
-.\}
-.fam C
-.ps -1
.nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
onnode all pidof ctdbd
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
.fi
-.fam
-.ps +1
-.if n \{\
.RE
-.\}
.PP
The following command would show the last 5 lines of log on each node, preceded by the node\'s hostname
.sp
-.if n \{\
.RS 4
-.\}
-.fam C
-.ps -1
.nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
- onnode all "hostname; tail \-5 /var/log/log\&.ctdb"
+ onnode all "hostname; tail \-5 /var/log/log\.ctdb"
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
.fi
-.fam
-.ps +1
-.if n \{\
.RE
-.\}
.PP
-The following command would restart the ctdb service on all nodes\&.
+The following command would restart the ctdb service on all nodes\.
.sp
-.if n \{\
.RS 4
-.\}
-.fam C
-.ps -1
.nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
onnode all service ctdb restart
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
.fi
-.fam
-.ps +1
-.if n \{\
.RE
-.\}
.PP
-The following command would run \&./foo in the current working directory, in parallel, on nodes 0, 2, 3 and 4\&.
+The following command would run \./foo in the current working directory, in parallel, on nodes 0, 2, 3 and 4\.
.sp
-.if n \{\
.RS 4
-.\}
-.fam C
-.ps -1
.nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
- onnode \-c \-p 0,2\-4 \&./foo
+ onnode \-c \-p 0,2\-4 \./foo
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
.fi
-.fam
-.ps +1
-.if n \{\
.RE
-.\}
.SH "FILES"
.PP
/etc/ctdb/nodes
.RS 4
-Contains a list of each node\'s IP address or hostname\&.
+Contains a list of each node\'s IP address or hostname\.
.RE
.PP
-/etc/ctdb/onnode\&.conf
+/etc/ctdb/onnode\.conf
.RS 4
-If this file exists it is sourced by onnode\&. The main purpose is to allow the administrator to set $SSH to something other than "ssh"\&. In this case the \-t option is ignored\&. For example, the administrator may choose to use use rsh instead of ssh\&.
+If this file exists it is sourced by onnode\. The main purpose is to allow the administrator to set $SSH to something other than "ssh"\. In this case the \-t option is ignored\. For example, the administrator may choose to use use rsh instead of ssh\.
.RE
.SH "SEE ALSO"
.PP
ctdbd(1), ctdb(1),
-\m[blue]\fB\%http://ctdb.samba.org/\fR\m[]
+\fI\%http://ctdb.samba.org/\fR
.SH "COPYRIGHT/LICENSE"
.sp
-.if n \{\
.RS 4
-.\}
-.fam C
-.ps -1
.nf
-.if t \{\
-.sp -1
-.\}
-.BB lightgray adjust-for-leading-newline
-.sp -1
-
Copyright (C) Andrew Tridgell 2007
Copyright (C) Ronnie sahlberg 2007
Copyright (C) Martin Schwenke 2008
@@ -351,22 +134,14 @@ Copyright (C) Martin Schwenke 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
-your option) any later version\&.
+your option) any later version\.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\&. See the GNU
-General Public License for more details\&.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\. See the GNU
+General Public License for more details\.
You should have received a copy of the GNU General Public License
-along with this program; if not, see http://www\&.gnu\&.org/licenses/\&.
-.EB lightgray adjust-for-leading-newline
-.if t \{\
-.sp 1
-.\}
+along with this program; if not, see http://www\.gnu\.org/licenses/\.
.fi
-.fam
-.ps +1
-.if n \{\
.RE
-.\}
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 1fd61d9..1f537d9 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -52,6 +52,33 @@ static int control_version(struct ctdb_context *ctdb, int argc, const char **arg
}
#endif
+
+/*
+ check if a database exists
+*/
+static int db_exists(struct ctdb_context *ctdb, const char *db_name)
+{
+ int i, ret;
+ struct ctdb_dbid_map *dbmap=NULL;
+
+ ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.pnn, ctdb, &dbmap);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get dbids from node %u\n", options.pnn));
+ return -1;
+ }
+
+ for(i=0;i<dbmap->num;i++){
+ const char *name;
+
+ ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &name);
+ if (!strcmp(name, db_name)) {
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
/*
see if a process exists
*/
@@ -1485,6 +1512,13 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv)
}
db_name = argv[0];
+
+
+ if (db_exists(ctdb, db_name)) {
+ DEBUG(DEBUG_ERR,("Database '%s' does not exist\n", db_name));
+ return -1;
+ }
+
ctdb_db = ctdb_attach(ctdb, db_name, false, 0);
if (ctdb_db == NULL) {
--
CTDB repository
More information about the samba-cvs
mailing list