aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myrpki.rototill/myirbe.py8
-rw-r--r--myrpki.rototill/myrpki.py38
-rw-r--r--myrpki.rototill/setup.py8
3 files changed, 33 insertions, 21 deletions
diff --git a/myrpki.rototill/myirbe.py b/myrpki.rototill/myirbe.py
index c792383f..2aa43c35 100644
--- a/myrpki.rototill/myirbe.py
+++ b/myrpki.rototill/myirbe.py
@@ -150,6 +150,8 @@ db = MySQLdb.connect(user = irdbd_cfg.get("sql-username"),
cur = db.cursor()
+entitydb = myrpki.EntityDB(cfg)
+
xmlfiles = []
# If [myrpki] section includes an "xml_filename" setting, run
@@ -418,13 +420,11 @@ for xmlfile in xmlfiles:
rpkid_query.extend(rpki.left_right.child_elt.make_pdu(
action = "destroy", self_handle = handle, child_handle = c) for c in child_pdus)
- # Publication setup, used to be inferred (badly) from parent setup,
- # now handled explictly via yet another freaking .csv file.
+ # Publication setup.
if run_pubd:
- # Need something like setup.py's entitydb() function. Wire in pathnames for now.
- for f in glob.iglob("entitydb/pubclients/*.xml"):
+ for f in entitydb.iterate("pubclients", "*.xml"):
c = myrpki.etree_read(f)
client_handle = c.get("client_handle")
diff --git a/myrpki.rototill/myrpki.py b/myrpki.rototill/myrpki.py
index f6cf00eb..f1d1fc29 100644
--- a/myrpki.rototill/myrpki.py
+++ b/myrpki.rototill/myrpki.py
@@ -86,6 +86,21 @@ class comma_set(set):
def __str__(self):
return ",".join(self)
+class EntityDB(object):
+ """
+ Wrapper for entitydb path lookups. Hmm, maybe some or all of the
+ entitydb glob stuff should end up here too? Later.
+ """
+
+ def __init__(self, cfg):
+ self.dir = cfg.get("entitydb_dir", "entitydb")
+
+ def __call__(self, *args):
+ return os.path.join(self.dir, *args)
+
+ def iterate(self, *args):
+ return glob.iglob(os.path.join(self.dir, *args))
+
class roa_request(object):
"""
Representation of a ROA request.
@@ -249,19 +264,16 @@ class children(dict):
c.xml(e)
@classmethod
- def from_csv(cls, children_csv_file, prefix_csv_file, asn_csv_file, fxcert):
+ def from_csv(cls, children_csv_file, prefix_csv_file, asn_csv_file, fxcert, entitydb):
"""
Parse child resources, certificates, and validity dates from CSV files.
"""
self = cls()
-
- # Need something like setup.py's entitydb() function. Wire in pathnames for now.
- for f in glob.iglob("entitydb/children/*.xml"):
+ for f in entitydb.iterate("children", "*.xml"):
c = etree_read(f)
self.add(handle = os.path.splitext(os.path.split(f)[-1])[0],
validity = c.get("valid_until"),
bpki_certificate = fxcert(c.findtext("bpki_child_ta")))
-
# childname p/n
for handle, pn in csv_open(prefix_csv_file):
self.add(handle = handle, prefix = pn)
@@ -362,16 +374,16 @@ class parents(dict):
c.xml(e)
@classmethod
- def from_csv(cls, parents_csv_file, fxcert):
+ def from_csv(cls, parents_csv_file, fxcert, entitydb):
"""
Parse parent data from CSV file.
"""
self = cls()
- # Need something like setup.py's entitydb() function. Wire in pathnames for now.
- for f in glob.iglob("entitydb/parents/*.xml"):
+ for f in entitydb.iterate("parents", "*.xml"):
h = os.path.splitext(os.path.split(f)[-1])[0]
p = etree_read(f)
- r = etree_read(f.replace("/parents/", "/repositories/"))
+ r = etree_read(f.replace(os.path.sep + "parents" + os.path.sep,
+ os.path.sep + "repositories" + os.path.sep))
assert r.get("type") == "confirmed"
self.add(handle = h,
service_uri = p.get("service_uri"),
@@ -663,6 +675,8 @@ def main(argv = ()):
global openssl
openssl = cfg.get("openssl", "openssl")
+ entitydb = EntityDB(cfg)
+
bpki = CA(cfg_file, bpki_dir)
try:
@@ -678,11 +692,13 @@ def main(argv = ()):
children_csv_file = children_csv_file,
prefix_csv_file = prefix_csv_file,
asn_csv_file = asn_csv_file,
- fxcert = bpki.fxcert).xml(e)
+ fxcert = bpki.fxcert,
+ entitydb = entitydb).xml(e)
parents.from_csv(
parents_csv_file = parents_csv_file,
- fxcert = bpki.fxcert).xml(e)
+ fxcert = bpki.fxcert,
+ entitydb = entitydb).xml(e)
PEMElement(e, "bpki_ca_certificate", bpki.cer)
PEMElement(e, "bpki_crl", bpki.crl)
diff --git a/myrpki.rototill/setup.py b/myrpki.rototill/setup.py
index 75f6aa6c..5e04a8fb 100644
--- a/myrpki.rototill/setup.py
+++ b/myrpki.rototill/setup.py
@@ -68,7 +68,7 @@ class main(rpki.cli.Cmd):
self.run_pubd = self.cfg.getboolean("run_pubd")
self.run_rootd = self.cfg.getboolean("run_rootd")
- self.entitydb_dir = self.cfg.get("entitydb_dir", "entitydb")
+ self.entitydb = myrpki.EntityDB(self.cfg)
if self.run_rootd and (not self.run_pubd or not self.run_rpkid):
raise RuntimeError, "Can't run rootd unless also running rpkid and pubd"
@@ -83,10 +83,6 @@ class main(rpki.cli.Cmd):
self.rsync_server = self.cfg.get("publication_rsync_server")
- def entitydb(self, *args):
- return os.path.join(self.entitydb_dir, *args)
-
-
def do_initialize(self, arg):
if arg:
raise RuntimeError, "This command takes no arguments"
@@ -196,7 +192,7 @@ class main(rpki.cli.Cmd):
try:
repo = None
- for f in glob.iglob(self.entitydb("repositories", "*.xml")):
+ for f in self.entitydb.iterate("repositories", "*.xml"):
r = myrpki.etree_read(f)
if r.get("type") == "confirmed":
if repo is not None: