Browse Source

[963] add --quiet mode to b10-dbutil

Jelte Jansen 13 years ago
parent
commit
22a8be53ad

+ 7 - 2
src/bin/dbutil/b10-dbutil.8

@@ -31,9 +31,9 @@
 b10-dbutil \- Zone Database Maintenance Utility
 .SH "SYNOPSIS"
 .HP \w'\fBb10\-dbutil\ \-\-check\fR\ 'u
-\fBb10\-dbutil \-\-check\fR [\-\-verbose] [\fIdbfile\fR]
+\fBb10\-dbutil \-\-check\fR [\-\-verbose] [\-\-quiet] [\fIdbfile\fR]
 .HP \w'\fBb10\-dbutil\ \-\-upgrade\fR\ 'u
-\fBb10\-dbutil \-\-upgrade\fR [\-\-noconfirm] [\-\-verbose] [\fIdbfile\fR]
+\fBb10\-dbutil \-\-upgrade\fR [\-\-noconfirm] [\-\-verbose] [\-\-quiet] [\fIdbfile\fR]
 .SH "DESCRIPTION"
 .PP
 The
@@ -77,6 +77,11 @@ The upgrade function will upgrade a BIND 10 database \- no matter how old the sc
 Enable verbose mode\&. Each SQL command issued by the utility will be printed to stdout before it is executed\&.
 .RE
 .PP
+\fB\-\-quiet\fR
+.RS 4
+Enable quiet mode\&. No output is printed, except errors during command\-line argument parsing, or the user confirmation dialog\&.
+.RE
+.PP
 \fB\fIdbfile\fR\fR
 .RS 4
 Name of the database file to check of upgrade\&.

+ 13 - 0
src/bin/dbutil/b10-dbutil.xml

@@ -45,12 +45,14 @@
     <cmdsynopsis>
       <command>b10-dbutil --check</command>
         <arg>--verbose</arg>
+        <arg>--quiet</arg>
         <arg><replaceable choice='req'>dbfile</replaceable></arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>b10-dbutil --upgrade</command>
         <arg>--noconfirm</arg>
         <arg>--verbose</arg>
+        <arg>--quiet</arg>
         <arg><replaceable choice='req'>dbfile</replaceable></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
@@ -163,6 +165,17 @@
 
       <varlistentry>
         <term>
+         <option>--quiet</option>
+        </term>
+        <listitem>
+          <para>Enable quiet mode. No output is printed, except errors during
+            command-line argument parsing, or the user confirmation dialog.
+          </para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>
         <option><replaceable choice='req'>dbfile</replaceable></option>
         </term>
         <listitem>

+ 8 - 0
src/bin/dbutil/dbutil.py.in

@@ -509,6 +509,9 @@ def parse_command():
     parser.add_option("-v", "--verbose", action="store_true",
                       dest="verbose", default=False,
                       help="Print SQL statements as they are executed")
+    parser.add_option("-q", "--quiet", action="store_true",
+                      dest="quiet", default=False,
+                      help="Don't print any info, warnings or errors")
     (options, args) = parser.parse_args()
 
     # Set the database file on which to operate
@@ -543,6 +546,11 @@ if __name__ == "__main__":
     if options.verbose:
         isc.log.init("b10-dbutil", "DEBUG", 99)
         logger = isc.log.Logger("dbutil")
+    elif options.quiet:
+        # We don't use FATAL, so setting the logger to use
+        # it should essentially make it silent.
+        isc.log.init("b10-dbutil", "FATAL")
+        logger = isc.log.Logger("dbutil")
 
     db = Database(args[0])
     exit_code = EXIT_SUCCESS

+ 6 - 0
src/bin/dbutil/tests/dbutil_test.sh.in

@@ -443,6 +443,12 @@ copy_file $testdata/old_v1.sqlite3 $tempfile
 passzero $?
 rm -f $tempfile $backupfile
 
+echo "13.3 quiet flag"
+copy_file $testdata/old_v1.sqlite3 $tempfile
+../run_dbutil.sh --check --quiet $tempfile 2>&1 | grep dbutil
+failzero $?
+rm -f $tempfile $backupfile
+
 echo "13.3 Interactive prompt - yes"
 copy_file $testdata/old_v1.sqlite3 $tempfile
 ../run_dbutil.sh --upgrade $tempfile << .