Commit 03ae3309 authored by Vincent Pelletier's avatar Vincent Pelletier

Add safeguards around --reset parameter.

Do not actually start storage node when told to reset database content.
Refuse to reset database content when non-required parameters are provided.
parent 6e2124a3
......@@ -65,6 +65,19 @@ def main(args=None):
adapter = options.adapter,
wait = options.wait,
if arguments['reset']:
# Forbid using "reset" along with any unneeded argument.
# "reset" is too dangerous to let user a chance of accidentally
# letting it slip through in a long option list.
forbidden = set(x for x, y in arguments.iteritems()
if y).difference((
if forbidden:
raise ValueError('Cannot reset database when the following '
'parameters are also provided: ' + ' '.join(forbidden))
config = ConfigurationManager(
......@@ -41,6 +41,19 @@ class Application(object):
"""The storage node application."""
def __init__(self, config): = buildDatabaseManager(config.getAdapter(),
(config.getDatabase(), config.getWait())
reset = config.getReset()
if reset:
# Abort ctor and prevent instance from running.
# This is done to prevent mistakes where user would use a storage
# started with reset option, and restart that storage later without
# dropping that option. = lambda: None
# set the cluster name = config.getCluster()
......@@ -48,10 +61,6 @@ class Application(object):
self.em = EventManager()
self.nm = NodeManager(config.getDynamicMasterList()) = TransactionManager(self) = buildDatabaseManager(config.getAdapter(),
(config.getDatabase(), config.getWait())
# load master nodes
master_addresses, connector_name = config.getMasters()
self.connector_handler = getConnectorHandler(connector_name)
......@@ -79,7 +88,6 @@ class Application(object):
# ready is True when operational and got all informations
self.ready = False
# force node uuid from command line argument, for testing purpose only
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment