summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-13 14:30:28 +0100
committerLars Wirzenius <liw@liw.fi>2013-10-13 14:30:28 +0100
commitb9f89930a95bff65d66ed18981042fdc8f41ecc4 (patch)
tree33b28670c61014e4d84c583dde8ae46aa81c28a3
parent91ee040b10b2bc3a9df790841a99d70397bf0548 (diff)
downloadobnam-b9f89930a95bff65d66ed18981042fdc8f41ecc4.tar.gz
Avoid "obnam clients" requiring an existing client
Patch by Itamar Turner-Trauring.
-rw-r--r--NEWS3
-rw-r--r--obnamlib/plugins/show_plugin.py10
-rwxr-xr-xtests/anyone-list-clients.script23
-rw-r--r--tests/anyone-list-clients.stdout1
4 files changed, 33 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index f400fb0c..1c67fe15 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ Version 1.6, released UNRELEASED
* New option `--ssh-command` to set the command Obnam runs
when invoking ssh. patch by Lars Kruse.
+* `obnam clients` can now be used without being an existing client.
+ Patch by Itamar Turner-Trauring.
+
Bug fixes:
* Fix "obnam list-toplevels" so it doesn't give an error when it's
diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py
index 8e9bffb1..1b94ffc5 100644
--- a/obnamlib/plugins/show_plugin.py
+++ b/obnamlib/plugins/show_plugin.py
@@ -64,15 +64,17 @@ class ShowPlugin(obnamlib.ObnamPlugin):
metavar='AGE',
default=obnamlib.DEFAULT_NAGIOS_WARN_AGE)
- def open_repository(self):
+ def open_repository(self, require_client=True):
self.app.settings.require('repository')
- self.app.settings.require('client-name')
+ if require_client:
+ self.app.settings.require('client-name')
self.repo = self.app.open_repository()
- self.repo.open_client(self.app.settings['client-name'])
+ if require_client:
+ self.repo.open_client(self.app.settings['client-name'])
def clients(self, args):
'''List clients using the repository.'''
- self.open_repository()
+ self.open_repository(require_client=False)
for client_name in self.repo.list_clients():
self.app.output.write('%s\n' % client_name)
self.repo.fs.close()
diff --git a/tests/anyone-list-clients.script b/tests/anyone-list-clients.script
new file mode 100755
index 00000000..164cd2da
--- /dev/null
+++ b/tests/anyone-list-clients.script
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Copyright 2013 Lars Wirzenius
+#
+# 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.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# The clients command can be run even by a client not in the list of clients
+# that previously did a backup.
+
+set -eu
+
+$SRCDIR/tests/backup
+$SRCDIR/obnam -r $DATADIR/repo --client=someotherclient clients
diff --git a/tests/anyone-list-clients.stdout b/tests/anyone-list-clients.stdout
new file mode 100644
index 00000000..7bc2971e
--- /dev/null
+++ b/tests/anyone-list-clients.stdout
@@ -0,0 +1 @@
+rainyday