Commit 0e5c59e9 authored by Julien Muchembled's avatar Julien Muchembled

storage: revert "Add safeguards around --reset parameter." partially

Commit 03ae3309 broke unit tests.

This reverts check that unneeded options are passed, and only skips run()
when used from 'neostorage' script.
parent b0fe461d
...@@ -53,6 +53,10 @@ defaults = dict( ...@@ -53,6 +53,10 @@ defaults = dict(
) )
def main(args=None): def main(args=None):
# TODO: 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.
# We should drop support configation files to make such check useful.
(options, args) = parser.parse_args(args=args) (options, args) = parser.parse_args(args=args)
arguments = dict( arguments = dict(
uuid = options.uuid, uuid = options.uuid,
...@@ -65,19 +69,6 @@ def main(args=None): ...@@ -65,19 +69,6 @@ def main(args=None):
adapter = options.adapter, adapter = options.adapter,
wait = options.wait, 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((
'reset',
'adapter',
'database',
))
if forbidden:
raise ValueError('Cannot reset database when the following '
'parameters are also provided: ' + ' '.join(forbidden))
config = ConfigurationManager( config = ConfigurationManager(
defaults, defaults,
options.file, options.file,
...@@ -91,5 +82,5 @@ def main(args=None): ...@@ -91,5 +82,5 @@ def main(args=None):
# and then, load and run the application # and then, load and run the application
from neo.storage.app import Application from neo.storage.app import Application
app = Application(config) app = Application(config)
app.run() if not config.getReset():
app.run()
...@@ -41,19 +41,6 @@ class Application(object): ...@@ -41,19 +41,6 @@ class Application(object):
"""The storage node application.""" """The storage node application."""
def __init__(self, config): def __init__(self, config):
self.dm = buildDatabaseManager(config.getAdapter(),
(config.getDatabase(), config.getWait())
)
reset = config.getReset()
self.dm.setup(reset=reset)
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.
self.run = lambda: None
return
# set the cluster name # set the cluster name
self.name = config.getCluster() self.name = config.getCluster()
...@@ -61,6 +48,10 @@ class Application(object): ...@@ -61,6 +48,10 @@ class Application(object):
self.em = EventManager() self.em = EventManager()
self.nm = NodeManager(config.getDynamicMasterList()) self.nm = NodeManager(config.getDynamicMasterList())
self.tm = TransactionManager(self) self.tm = TransactionManager(self)
self.dm = buildDatabaseManager(config.getAdapter(),
(config.getDatabase(), config.getWait())
)
# load master nodes # load master nodes
master_addresses, connector_name = config.getMasters() master_addresses, connector_name = config.getMasters()
self.connector_handler = getConnectorHandler(connector_name) self.connector_handler = getConnectorHandler(connector_name)
...@@ -88,6 +79,7 @@ class Application(object): ...@@ -88,6 +79,7 @@ class Application(object):
# ready is True when operational and got all informations # ready is True when operational and got all informations
self.ready = False self.ready = False
self.dm.setup(reset=config.getReset())
self.loadConfiguration() self.loadConfiguration()
# force node uuid from command line argument, for testing purpose only # 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