Commit 55ca6714 authored by Vincent Pelletier's avatar Vincent Pelletier

Add the possibility to provide a UUID to a node upon startup. Mostly usefull...

Add the possibility to provide a UUID to a node upon startup. Mostly usefull in functional tests where we want to map a process to its UUID.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1141 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 631f2363
......@@ -50,7 +50,7 @@ class Dispatcher:
class Application(object):
"""The storage node application."""
def __init__(self, filename, section):
def __init__(self, filename, section, uuid=None):
config = ConfigurationManager(filename, section)
self.name = config.getName()
......@@ -69,7 +69,7 @@ class Application(object):
# The partition table is initialized after getting the number of
# partitions.
self.pt = None
self.uuid = None
self.uuid = uuid
self.primary_master_node = None
self.ptid = None
self.monitoring_handler = MasterMonitoringEventHandler(self)
......
......@@ -41,7 +41,7 @@ REQUIRED_NODE_NUMBER = 1
class Application(object):
"""The master node application."""
def __init__(self, filename, section):
def __init__(self, filename, section, uuid=None):
config = ConfigurationManager(filename, section)
self.connector_handler = getConnectorHandler(config.getConnector())
......@@ -77,7 +77,9 @@ class Application(object):
self.cluster_state = None
# Generate an UUID for self
self.uuid = self.getNewUUID(protocol.MASTER_NODE_TYPE)
if uuid is None:
uuid = self.getNewUUID(protocol.MASTER_NODE_TYPE)
self.uuid = uuid
# The last OID.
self.loid = None
......
......@@ -39,10 +39,10 @@ from neo.bootstrap import BootstrapManager
class Application(object):
"""The storage node application."""
def __init__(self, filename, section, reset=False):
def __init__(self, filename, section, reset=False, uuid=None):
config = ConfigurationManager(filename, section)
self.uuid = None
self.uuid = uuid
self.name = config.getName()
logging.debug('the name is %s', self.name)
self.connector_handler = getConnectorHandler(config.getConnector())
......
......@@ -22,6 +22,8 @@ from optparse import OptionParser
from neo import setupLog
parser = OptionParser()
parser.add_option('-u', '--uuid', help='specify an UUID to use for this ' \
'process')
parser.add_option('-v', '--verbose', action = 'store_true',
help = 'print verbose messages')
parser.add_option('-c', '--config', help = 'specify a configuration file')
......@@ -31,10 +33,13 @@ parser.add_option('-l', '--logfile', help = 'specify a logging file')
(options, args) = parser.parse_args()
config = options.config or 'neo.conf'
section = options.section or 'admin'
uuid = options.uuid
if uuid is not None:
uuid = bin(uuid)
logfile = options.logfile or None
setupLog(section, logfile, options.verbose)
from neo.admin.app import Application
app = Application(config, section)
app = Application(config, section, uuid)
app.run()
......@@ -20,8 +20,11 @@
from optparse import OptionParser
from neo import setupLog
from neo.util import bin
parser = OptionParser()
parser.add_option('-u', '--uuid', help='specify an UUID to use for this ' \
'process')
parser.add_option('-v', '--verbose', action = 'store_true',
help = 'print verbose messages')
parser.add_option('-c', '--config', help = 'specify a configuration file')
......@@ -31,10 +34,13 @@ parser.add_option('-l', '--logfile', help = 'specify a logging file')
(options, args) = parser.parse_args()
config = options.config or 'neo.conf'
section = options.section or 'master'
uuid = options.uuid
if uuid is not None:
uuid = bin(uuid)
logfile = options.logfile or None
setupLog(section, logfile, options.verbose)
from neo.master.app import Application
app = Application(config, section)
app = Application(config, section, uuid)
app.run()
......@@ -23,6 +23,9 @@ from neo import setupLog
parser = OptionParser()
parser.add_option('-u', '--uuid', help='specify an UUID to use for this ' \
'process. Previously assigned UUID takes precedence (ie ' \
'you should always use -R with this switch)')
parser.add_option('-v', '--verbose', action = 'store_true',
help = 'print verbose messages')
parser.add_option('-c', '--config', help = 'specify a configuration file')
......@@ -34,10 +37,13 @@ parser.add_option('-R', '--reset', action = 'store_true',
(options, args) = parser.parse_args()
config = options.config or 'neo.conf'
section = options.section or 'storage'
uuid = options.uuid
if uuid is not None:
uuid = bin(uuid)
logfile = options.logfile or None
setupLog(section, logfile, options.verbose)
from neo.storage.app import Application
app = Application(config, section, options.reset)
app = Application(config, section, options.reset, uuid=uuid)
app.run()
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