diff options
author | Marko Kreen | 2013-03-20 15:54:39 +0000 |
---|---|---|
committer | Marko Kreen | 2013-03-20 15:54:39 +0000 |
commit | 770a843296c06e66da8103cae3eef1209c11e278 (patch) | |
tree | 041cd2e0c2df9d68c7ed0124637906070d36e434 | |
parent | 805ff65a57bea4a8cdc0bee677cc406581b5114f (diff) |
londiste create: load node name and initial provider also from config
-rw-r--r-- | python/londiste/playback.py | 20 | ||||
-rw-r--r-- | python/pgq/cascade/admin.py | 33 |
2 files changed, 39 insertions, 14 deletions
diff --git a/python/londiste/playback.py b/python/londiste/playback.py index 3deea68a..f264363d 100644 --- a/python/londiste/playback.py +++ b/python/londiste/playback.py @@ -276,10 +276,6 @@ class Replicator(CascadedWorker): # target database db = dbname=somedb host=127.0.0.1 - # public connect string for target node, which other nodes use - # to access this one. - #public_node_location = - # how many tables can be copied in parallel #parallel_copies = 1 @@ -294,6 +290,22 @@ class Replicator(CascadedWorker): # workaround for hashtext change between 8.3 and 8.4 #compare_sql = select count(1) as cnt, sum(('x'||substr(md5(t.*::text),1,16))::bit(64)::bigint) as chksum from only _TABLE_ t #compare_fmt = %(cnt)d rows, checksum=%(chksum)s + + ## Parameters for initial node creation: create-root/branch/leaf ## + + # These parameters can be given on either command-line or in config + # command-line values override config values. Those values are + # used only during create time, otherwise they are loaded from database. + + # Name for local node. + #node_name = + + # public connect string for local node, which other nodes will use + # to connect to this one. + #public_node_location = + + # connect string for existing node to use as provider + #initial_provider_location = """ # batch info diff --git a/python/pgq/cascade/admin.py b/python/pgq/cascade/admin.py index 8bf004e8..4fbd2f48 100644 --- a/python/pgq/cascade/admin.py +++ b/python/pgq/cascade/admin.py @@ -143,32 +143,45 @@ class CascadeAdmin(skytools.AdminScript): db = self.get_database("db") self.install_code(db) - def cmd_create_root(self, node_name, *args): - return self.create_node('root', node_name, args) + def cmd_create_root(self, *args): + return self.create_node('root', args) def cmd_create_branch(self, node_name, *args): - return self.create_node('branch', node_name, args) + return self.create_node('branch', args) def cmd_create_leaf(self, node_name, *args): - return self.create_node('leaf', node_name, args) + return self.create_node('leaf', args) - def create_node(self, node_type, node_name, args): + def create_node(self, node_type, args): """Generic node init.""" - provider_loc = self.options.provider if node_type not in ('root', 'branch', 'leaf'): raise Exception('unknown node type') - # load public location + # load node name + if len(args) > 0: + node_name = args[0] + else: + node_name = self.cf.get('node_name', '') + if not node_name: + raise UsageError('Node public location must be given either in command line or config') + + # load node public location if len(args) > 1: - raise UsageError('Too many args, only public connect string allowed') - elif len(args) == 1: - node_location = args[0] + node_location = args[1] else: node_location = self.cf.get('public_node_location', '') if not node_location: raise UsageError('Node public location must be given either in command line or config') + if len(args) > 2: + raise UsageError('Too many args, only node name and public connect string allowed') + + # load provider + provider_loc = self.options.provider + if not provider_loc: + provider_loc = self.cf.get('initial_provider_location', '') + # check if sane ok = 0 for k, v in skytools.parse_connect_string(node_location): |