[Checkins]
SVN: gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/
Adding a command for reload the zeo.conf
Dirceu Pereira Tiegs
dirceutiegs at gmail.com
Thu Jul 31 20:49:11 EDT 2008
Log message for revision 89112:
Adding a command for reload the zeo.conf
Changed:
U gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/scripts/controller.py
U gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/storage.py
U gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/tests/test_basics.py
-=-
Modified: gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/scripts/controller.py
===================================================================
--- gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/scripts/controller.py 2008-08-01 00:20:31 UTC (rev 89111)
+++ gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/scripts/controller.py 2008-08-01 00:49:09 UTC (rev 89112)
@@ -35,6 +35,8 @@
add <ip:port:storage> -- Add a storage
+ reload </path/to/zeo.conf> -- Reload a specified zeo.conf file
+
"""
import optparse
@@ -80,11 +82,15 @@
except ValueError:
sys.exit("Usage: IP:PORT:STORAGE")
+ def cmd_reload(self, path):
+ print self.raid.raid_reload(path)
+
def main(host="127.0.0.1", port=8100, storage="1"):
usage = "usage: %prog [options] command [command-options]"
description = ("Connect to a RAIDStorage on a ZEO server and perform "
"maintenance tasks. Available commands: status, details, "
- "recover <STORAGE>, disable <STORAGE>, add <IP:PORT:STORAGE>")
+ "recover <STORAGE>, disable <STORAGE>, add <IP:PORT:STORAGE>"
+ "reload </PATH/TO/ZEO.CONF>")
parser = optparse.OptionParser(usage=usage, description=description)
parser.add_option("-S", "--storage", default=storage,
Modified: gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/storage.py 2008-08-01 00:20:31 UTC (rev 89111)
+++ gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/storage.py 2008-08-01 00:49:09 UTC (rev 89112)
@@ -540,7 +540,7 @@
# This method isn't officially part of the interface but it is supported.
methods = dict.fromkeys(
['raid_recover', 'raid_status', 'raid_disable', 'raid_details',
- 'raid_add_storage'])
+ 'raid_add_storage', 'raid_reload'])
return methods
# IRAIDStorage
@@ -583,6 +583,25 @@
self.raid_recover(name)
return 'added %s:%s:%s' % (ip, port, name)
+ def raid_reload(self, path):
+ s = ""
+ zeoconf = open(path, 'r').read()
+ temp_storage = ZODB.config.storageFromString(zeoconf)
+ storages_to_remove = [o for o in self.openers.items() if o[0] not in temp_storage.openers]
+ for storage in storages_to_remove:
+ self.raid_disable(storage[0])
+ s += "removed %s\n" % storage[0]
+ storages_to_add = [o for o in temp_storage.openers.items() if o[0] not in self.openers]
+ for storage in storages_to_add:
+ name = storage[0]
+ self.openers[name] = storage[1]
+ self._open_storage(name)
+ self.storages_degraded.append(name)
+ self.raid_recover(name)
+ s += "added %s\n" % name
+ del temp_storage
+ return s
+
# internal
def _open_storage(self, name):
Modified: gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/tests/test_basics.py
===================================================================
--- gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/tests/test_basics.py 2008-08-01 00:20:31 UTC (rev 89111)
+++ gocept.zeoraid/branches/dirceu-addstoragetool/src/gocept/zeoraid/tests/test_basics.py 2008-08-01 00:49:09 UTC (rev 89112)
@@ -1187,7 +1187,8 @@
raid_disable=None,
raid_recover=None,
raid_status=None,
- raid_add_storage=None),
+ raid_add_storage=None,
+ raid_reload=None),
methods)
def test_getExtensionMethods_degrading(self):
More information about the Checkins
mailing list