Commit 59ae2701 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Levin Zimmermann

client: Don't allow master_nodes and name to be present in options

Because list of masters and cluster name must be already present in
netloc and path. Previously e.g.

	neo://db@α,β,γ?master_nodes=a,b,c"

would mean to use master nodes {a,b,c} not {α,β,γ}. Now it is treated as
invalid URI to remove ambiguity. Same for cluster name.

/cc @levin.zimmermann
/reviewed-by @jm
/reviewed-on nexedi/neoppod!21

(cherry-picked from commit 22ccebd6)
parent af3b3def
......@@ -66,6 +66,10 @@ def _resolve_uri(uri):
neokw = OrderedDict()
neokw['master_nodes'] = ' '.join(master_list)
neokw['name'] = name
def setopt(k, v):
if k in ('master_nodes', 'name'):
raise ValueError("invalid uri: %s : invalid option %s" % (uri, k))
neokw[k] = v
# get options from query: only those that are defined by NEO schema go to
# storage - rest are returned as database options
......@@ -73,14 +77,14 @@ def _resolve_uri(uri):
neo_options = neo_zconf_options()
for k, v in OrderedDict(parse_qsl(query)).items():
if k in neo_options:
neokw[k] = v
setopt(k, v)
else:
# it might be option for storage, but not in canonical form e.g.
# read_only -> read-only (zodburi world settled on using "_" and
# ZConfig world on "-" as separators)
k2 = canonical_opt_name(k)
if k2 in neo_options:
neokw[k2] = v
setopt(k2, v)
# else keep this kv as db option
else:
......
......@@ -72,6 +72,10 @@ class ZODBURITests(unittest.TestCase):
# db @ master not fully specified
self.assertRaises(ValueError, _resolve_uri, "neo://master")
# master_nodes and name provided in options (they come in netloc)
self.assertRaises(ValueError, _resolve_uri, "neo://db@master?master_nodes=a,b,c")
self.assertRaises(ValueError, _resolve_uri, "neo://db@master?name=zzz")
# verify zodburi resolver produces expected zconfig
for uri, zconf_ok, dbkw_ok in testv:
zconf_ok = "%import neo.client\n<NEOStorage>\n" + zconf_ok + \
......
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