diff options
author | Rob Austein <sra@hactrn.net> | 2013-04-19 02:22:57 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-04-19 02:22:57 +0000 |
commit | ddfb8c4eb8139b94e1031c6f8555aee4b6287afb (patch) | |
tree | 159b3fce49ac6594fc2ea0b1c327bdd973a990f0 | |
parent | de186b4393ce25cdfb51b1c3240e0326c85890cf (diff) |
Add option to allow setting initial resource validity when configuring
child in rpkic, and teach yamltest to use it.
svn path=/trunk/; revision=5301
-rw-r--r-- | rpkid/rpki/irdb/zookeeper.py | 11 | ||||
-rw-r--r-- | rpkid/rpki/rpkic.py | 7 | ||||
-rw-r--r-- | rpkid/tests/yamltest.py | 6 |
3 files changed, 17 insertions, 7 deletions
diff --git a/rpkid/rpki/irdb/zookeeper.py b/rpkid/rpki/irdb/zookeeper.py index 6b72a8a8..86aabb08 100644 --- a/rpkid/rpki/irdb/zookeeper.py +++ b/rpkid/rpki/irdb/zookeeper.py @@ -457,7 +457,7 @@ class Zookeeper(object): @django.db.transaction.commit_on_success - def configure_child(self, filename, child_handle = None): + def configure_child(self, filename, child_handle = None, valid_until = None): """ Configure a new child of this RPKI entity, given the child's XML identity file as an input. Extracts the child's data from the @@ -472,7 +472,12 @@ class Zookeeper(object): if child_handle is None: child_handle = c.get("handle") - valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) + if valid_until is None: + valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) + else: + valid_until = rpki.sundial.datetime.fromXMLtime(valid_until) + if valid_until < rpki.sundial.now(): + raise PastExpiration, "Specified new expiration time %s has passed" % valid_until self.log("Child calls itself %r, we call it %r" % (c.get("handle"), child_handle)) @@ -791,7 +796,7 @@ class Zookeeper(object): if valid_until is None: valid_until = rpki.sundial.now() + rpki.sundial.timedelta(days = 365) else: - valid_until = rpki.sundial.fromXMLtime(valid_until) + valid_until = rpki.sundial.datetime.fromXMLtime(valid_until) if valid_until < rpki.sundial.now(): raise PastExpiration, "Specified new expiration time %s has passed" % valid_until diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py index c5a9a919..8085db43 100644 --- a/rpkid/rpki/rpkic.py +++ b/rpkid/rpki/rpkic.py @@ -273,15 +273,18 @@ class main(Cmd): """ child_handle = None + valid_until = None - opts, argv = getopt.getopt(arg.split(), "", ["child_handle="]) + opts, argv = getopt.getopt(arg.split(), "", ["child_handle=", "valid_until="]) for o, a in opts: if o == "--child_handle": child_handle = a + elif o == "--valid_until": + valid_until = a if len(argv) != 1: raise BadCommandSyntax("Expecting filename of child's identity XML") - r, child_handle = self.zoo.configure_child(argv[0], child_handle) + r, child_handle = self.zoo.configure_child(argv[0], child_handle, valid_until) r.save("%s.%s.parent-response.xml" % (self.zoo.handle, child_handle), sys.stdout) self.zoo.synchronize_ca() diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py index 6c950645..9d77a34c 100644 --- a/rpkid/tests/yamltest.py +++ b/rpkid/tests/yamltest.py @@ -486,7 +486,7 @@ class allocation(object): if profile: cmd.append("--profile") cmd.append(self.path("rpkic.%s.prof" % rpki.sundial.now())) - cmd.extend(a for a in args if a is not None) + cmd.extend(str(a) for a in args if a is not None) print 'Running "%s"' % " ".join(cmd) env = os.environ.copy() env["YAMLTEST_RPKIC_COUNTER"] = self.next_rpkic_counter() @@ -750,7 +750,9 @@ try: d.path("%s.repository-response.xml" % d.client_handle)) print else: - d.parent.run_rpkic("configure_child", d.path("%s.identity.xml" % d.name)) + d.parent.run_rpkic("configure_child", + "--valid_until", d.resources.valid_until, + 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))) |