aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpkid/rpki/irdb/zookeeper.py6
-rw-r--r--rpkid/rpki/rpkic.py9
-rw-r--r--rpkid/tests/yamltest.py17
3 files changed, 23 insertions, 9 deletions
diff --git a/rpkid/rpki/irdb/zookeeper.py b/rpkid/rpki/irdb/zookeeper.py
index 83fd8665..7dedeb7e 100644
--- a/rpkid/rpki/irdb/zookeeper.py
+++ b/rpkid/rpki/irdb/zookeeper.py
@@ -606,7 +606,7 @@ class Zookeeper(object):
@django.db.transaction.commit_on_success
- def configure_publication_client(self, filename, sia_base = None):
+ def configure_publication_client(self, filename, sia_base = None, flat = False):
"""
Configure publication server to know about a new client, given the
client's request-for-service message as input. Reads the client's
@@ -619,6 +619,10 @@ class Zookeeper(object):
client_ta = rpki.x509.X509(Base64 = client.findtext("bpki_client_ta"))
+ if sia_base is None and flat:
+ self.log("Flat publication structure forced, homing client at top-level")
+ sia_base = "rsync://%s/%s/%s/" % (self.rsync_server, self.rsync_module, client.get("handle"))
+
if sia_base is None and client.get("handle") == self.handle and self.resource_ca.certificate == client_ta:
self.log("This looks like self-hosted publication")
sia_base = "rsync://%s/%s/%s/" % (self.rsync_server, self.rsync_module, self.handle)
diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py
index afae0d90..4959d8c8 100644
--- a/rpkid/rpki/rpkic.py
+++ b/rpkid/rpki/rpkic.py
@@ -322,16 +322,19 @@ class main(rpki.cli.Cmd):
"""
sia_base = None
+ flat = False
- opts, argv = getopt.getopt(arg.split(), "", ["sia_base="])
+ opts, argv = getopt.getopt(arg.split(), "", ["flat", "sia_base="])
for o, a in opts:
- if o == "--sia_base":
+ if o == "--flat":
+ flat = True
+ elif o == "--sia_base":
sia_base = a
if len(argv) != 1:
raise BadCommandSyntax, "Need to specify filename for client.xml"
- r, client_handle = self.zoo.configure_publication_client(argv[0], sia_base)
+ r, client_handle = self.zoo.configure_publication_client(argv[0], sia_base, flat)
r.save("%s.repository-response.xml" % client_handle.replace("/", "."), sys.stdout)
try:
diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py
index 12fd7f85..acac876b 100644
--- a/rpkid/tests/yamltest.py
+++ b/rpkid/tests/yamltest.py
@@ -352,9 +352,10 @@ class allocation(object):
"""
path = []
s = self
- while not s.runs_pubd:
- path.append(s)
- s = s.parent
+ if not flat_publication:
+ while not s.runs_pubd:
+ path.append(s)
+ s = s.parent
path.append(s)
return ".".join(i.name for i in reversed(path))
@@ -430,7 +431,8 @@ class allocation(object):
"""
Run rpkic for this entity.
"""
- cmd = (prog_rpkic, "-i", self.name, "-c", self.path("rpki.conf")) + args
+ cmd = [prog_rpkic, "-i", self.name, "-c", self.path("rpki.conf")]
+ cmd.extend(a for a in args if a is not None)
print 'Running "%s"' % " ".join(cmd)
subprocess.check_call(cmd, cwd = self.host.path())
@@ -488,14 +490,17 @@ cfg_file = None
pidfile = None
keep_going = False
skip_config = False
+flat_publication = False
-opts, argv = getopt.getopt(sys.argv[1:], "c:hkp:s?", ["config=", "help", "keep_going", "pidfile=", "skip_config"])
+opts, argv = getopt.getopt(sys.argv[1:], "c:fhkp:s?", ["config=", "flat_publication", "help", "keep_going", "pidfile=", "skip_config"])
for o, a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
sys.exit(0)
if o in ("-c", "--config"):
cfg_file = a
+ elif o in ("-f", "--flat_publication"):
+ flat_publication = True
elif o in ("-k", "--keep_going"):
keep_going = True
elif o in ("-p", "--pidfile"):
@@ -646,6 +651,7 @@ try:
if d.is_root:
assert not d.is_hosted
d.run_rpkic("configure_publication_client",
+ "--flat" if flat_publication else None,
d.path("%s.%s.repository-request.xml" % (d.name, d.name)))
print
d.run_rpkic("configure_repository",
@@ -658,6 +664,7 @@ try:
d.parent.path("%s.%s.parent-response.xml" % (d.parent.name, d.name)))
print
d.pubd.run_rpkic("configure_publication_client",
+ "--flat" if flat_publication else None,
d.path("%s.%s.repository-request.xml" % (d.name, d.parent.name)))
print
d.run_rpkic("configure_repository",