aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2012-04-17 21:44:22 +0000
committerRob Austein <sra@hactrn.net>2012-04-17 21:44:22 +0000
commit875f38a74c16e1d6694dd0915207aea2ad3f80e0 (patch)
treece7ae8a36e1518a9a6df3d706f08448bc4652592
parentd4ce92dec82cbede358c36a98af13eed0bd19cfd (diff)
Synchronize with daemons automatically after rpkic commands where
doing so makes sense. This closes #236. svn path=/trunk/; revision=4433
-rw-r--r--rpkid/rpki/rpkic.py25
-rw-r--r--rpkid/tests/yamltest.py83
2 files changed, 64 insertions, 44 deletions
diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py
index dbaee3bb..f69f201d 100644
--- a/rpkid/rpki/rpkic.py
+++ b/rpkid/rpki/rpkic.py
@@ -234,6 +234,7 @@ class main(rpki.cli.Cmd):
r, child_handle = self.zoo.configure_child(argv[0], child_handle)
r.save("%s.%s.parent-response.xml" % (self.zoo.handle, child_handle), sys.stdout)
+ self.zoo.synchronize()
def do_delete_child(self, arg):
@@ -243,6 +244,7 @@ class main(rpki.cli.Cmd):
try:
self.zoo.delete_child(arg)
+ self.zoo.synchronize()
except rpki.irdb.Child.DoesNotExist:
print "No such child \"%s\"" % arg
@@ -260,6 +262,12 @@ class main(rpki.cli.Cmd):
service. If a publication offer or referral is present, we
generate a request-for-service message to that repository, in case
the user wants to avail herself of the referral or offer.
+
+ We do NOT attempt automatic synchronization with rpkid at the
+ completion of this command, because synchronization at this point
+ will usually fail due to the repository not being set up yet. If
+ you know what you are doing and for some reason really want to
+ synchronize here, run the synchronize command yourself.
"""
parent_handle = None
@@ -283,6 +291,7 @@ class main(rpki.cli.Cmd):
try:
self.zoo.delete_parent(arg)
+ self.zoo.synchronize()
except rpki.irdb.Parent.DoesNotExist:
print "No such parent \"%s\"" % arg
@@ -312,6 +321,11 @@ class main(rpki.cli.Cmd):
r, client_handle = self.zoo.configure_publication_client(argv[0], sia_base)
r.save("%s.repository-response.xml" % client_handle.replace("/", "."), sys.stdout)
+ # Don't attempt to synchronize self-publication case, we'll do it
+ # in do_configure_repository() and it'd just confuse us now.
+ if client_handle != self.zoo.handle:
+ self.zoo.synchronize()
+
def do_delete_publication_client(self, arg):
"""
@@ -320,6 +334,7 @@ class main(rpki.cli.Cmd):
try:
self.zoo.delete_publication_client(arg).delete()
+ self.zoo.synchronize()
except rpki.irdb.Client.DoesNotExist:
print "No such client \"%s\"" % arg
@@ -348,6 +363,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax, "Need to specify filename for repository.xml on command line"
self.zoo.configure_repository(argv[0], parent_handle)
+ self.zoo.synchronize()
def do_delete_repository(self, arg):
"""
@@ -359,6 +375,7 @@ class main(rpki.cli.Cmd):
try:
self.zoo.delete_repository(arg)
+ self.zoo.synchronize()
except rpki.irdb.Repository.DoesNotExist:
print "No such repository \"%s\"" % arg
@@ -372,6 +389,7 @@ class main(rpki.cli.Cmd):
"""
self.zoo.delete_self()
+ self.zoo.synchronize()
def do_renew_child(self, arg):
@@ -390,6 +408,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax, "Need to specify child handle"
self.zoo.renew_children(argv[0], valid_until)
+ self.zoo.synchronize(self.zoo.handle)
def complete_renew_child(self, *args):
return self.irdb_handle_complete(rpki.irdb.Child, *args)
@@ -411,6 +430,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax, "Unexpected arguments"
self.zoo.renew_children(None, valid_until)
+ self.zoo.synchronize(self.zoo.handle)
def do_load_prefixes(self, arg):
@@ -424,6 +444,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax("Need to specify prefixes.csv filename")
self.zoo.load_prefixes(argv[0])
+ self.zoo.synchronize(self.zoo.handle)
def do_show_child_resources(self, arg):
@@ -457,6 +478,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax("Need to specify asns.csv filename")
self.zoo.load_asns(argv[0])
+ self.zoo.synchronize(self.zoo.handle)
def do_load_roa_requests(self, arg):
@@ -470,6 +492,7 @@ class main(rpki.cli.Cmd):
raise BadCommandSyntax("Need to specify roa.csv filename")
self.zoo.load_roa_requests(argv[0])
+ self.zoo.synchronize(self.zoo.handle)
def do_synchronize(self, arg):
@@ -483,4 +506,4 @@ class main(rpki.cli.Cmd):
if arg:
raise BadCommandSyntax("Unexpected argument(s): %r" % arg)
- self.zoo.synchronize()
+ self.zoo.synchronize(self.zoo.handle)
diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py
index 79ddaea3..32434147 100644
--- a/rpkid/tests/yamltest.py
+++ b/rpkid/tests/yamltest.py
@@ -485,8 +485,9 @@ time.tzset()
cfg_file = None
pidfile = None
keep_going = False
+skip_config = False
-opts, argv = getopt.getopt(sys.argv[1:], "c:hkp:?", ["config=", "help", "keep_going", "pidfile="])
+opts, argv = getopt.getopt(sys.argv[1:], "c:hkp:s?", ["config=", "help", "keep_going", "pidfile=", "skip_config"])
for o, a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
@@ -497,6 +498,8 @@ for o, a in opts:
keep_going = True
elif o in ("-p", "--pidfile"):
pidfile = a
+ elif o in ("-s", "--skip_config"):
+ skip_config = True
# We can't usefully process more than one YAML file at a time, so
# whine if there's more than one argument left.
@@ -576,7 +579,7 @@ try:
v4 = rpki.resource_set.resource_set_ipv4("0.0.0.0/0"),
v6 = rpki.resource_set.resource_set_ipv6("::/0"))
- root_key = rpki.x509.RSA.generate()
+ root_key = rpki.x509.RSA.generate(quiet = True)
root_uri = "rsync://localhost:%d/rpki/" % db.root.pubd.rsync_port
@@ -612,34 +615,6 @@ try:
for d in db:
print
- print "Configuring", d.name
- print
- if d.is_root:
- assert not d.is_hosted
- d.run_rpkic("configure_publication_client",
- d.path("%s.%s.repository-request.xml" % (d.name, d.name)))
- print
- d.run_rpkic("configure_repository",
- d.path("%s.repository-response.xml" % d.client_handle))
- print
- else:
- d.parent.run_rpkic("configure_child", d.path("%s.identity.xml" % d.name))
- print
- d.run_rpkic("configure_parent",
- d.parent.path("%s.%s.parent-response.xml" % (d.parent.name, d.name)))
- print
- d.pubd.run_rpkic("configure_publication_client",
- d.path("%s.%s.repository-request.xml" % (d.name, d.parent.name)))
- print
- d.run_rpkic("configure_repository",
- d.pubd.path("%s.repository-response.xml" % d.client_handle))
- print
- d.parent.run_rpkic("synchronize")
- print
- if d.pubd is not d.parent.host:
- d.pubd.run_rpkic("synchronize")
- print
-
print "Running daemons for", d.name
if d.is_root:
progs.append(d.run_rootd())
@@ -649,21 +624,43 @@ try:
if d.runs_pubd:
progs.append(d.run_pubd())
progs.append(d.run_rsyncd())
- if d.is_root or not d.is_hosted or d.runs_pubd:
- print "Giving", d.name, "daemons time to start up"
- time.sleep(20)
- print
- assert all(p.poll() is None for p in progs)
- # In theory we now only need to synchronize the new entity once.
- d.run_rpkic("synchronize")
+ print
+ print "Giving daemons time to start up"
+ time.sleep(20)
+ assert all(p.poll() is None for p in progs)
+
+ if skip_config:
+
+ print "Skipping configure_*, you'll have to do that yourself"
- # Run through list again, to be sure we catch hosted cases.
- # In theory this is no longer necessary.
- if False:
- for i in xrange(3):
- for d in db:
- d.run_rpkic("synchronize")
+ else:
+
+ for d in db:
+
+ print
+ print "Configuring", d.name
+ print
+ if d.is_root:
+ assert not d.is_hosted
+ d.run_rpkic("configure_publication_client",
+ d.path("%s.%s.repository-request.xml" % (d.name, d.name)))
+ print
+ d.run_rpkic("configure_repository",
+ d.path("%s.repository-response.xml" % d.client_handle))
+ print
+ else:
+ d.parent.run_rpkic("configure_child", d.path("%s.identity.xml" % d.name))
+ print
+ d.run_rpkic("configure_parent",
+ d.parent.path("%s.%s.parent-response.xml" % (d.parent.name, d.name)))
+ print
+ d.pubd.run_rpkic("configure_publication_client",
+ d.path("%s.%s.repository-request.xml" % (d.name, d.parent.name)))
+ print
+ d.run_rpkic("configure_repository",
+ d.pubd.path("%s.repository-response.xml" % d.client_handle))
+ print
# Load all the CSV files
for d in db: