diff options
author | Rob Austein <sra@hactrn.net> | 2009-09-18 04:59:20 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-09-18 04:59:20 +0000 |
commit | 4d49afaa4e55370d82469fb0344bc47a6b5aaf32 (patch) | |
tree | 39a8da82340c636ca813fda6aefaad1f653e230a /myrpki | |
parent | dad110e047c0216f380bb1f1c974b4db5233443c (diff) |
Add "group" column to roas.csv, to support generation of multiple ROAs
with the same ASN.
svn path=/myrpki/examples/roas.csv; revision=2767
Diffstat (limited to 'myrpki')
-rw-r--r-- | myrpki/examples/roas.csv | 4 | ||||
-rw-r--r-- | myrpki/myrpki.py | 22 | ||||
-rw-r--r-- | myrpki/yamltest.py | 4 |
3 files changed, 17 insertions, 13 deletions
diff --git a/myrpki/examples/roas.csv b/myrpki/examples/roas.csv index 35672368..423a3a1b 100644 --- a/myrpki/examples/roas.csv +++ b/myrpki/examples/roas.csv @@ -1,6 +1,6 @@ -# Syntax: <prefix>/<length>-<maxlength> <asn> +# Syntax: <prefix>/<length>-<maxlength> <asn> <group> # # NB: Comment lines are not allowed in these files, this one is only # present to explain the example # -10.3.0.44/32 666 +10.3.0.44/32 666 Mom diff --git a/myrpki/myrpki.py b/myrpki/myrpki.py index 7f053237..52f1443d 100644 --- a/myrpki/myrpki.py +++ b/myrpki/myrpki.py @@ -88,13 +88,14 @@ class roa_request(object): v4re = re.compile("^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]+(-[0-9]+)?$", re.I) v6re = re.compile("^([0-9a-f]{0,4}:){0,15}[0-9a-f]{0,4}/[0-9]+(-[0-9]+)?$", re.I) - def __init__(self, asn): + def __init__(self, asn, group): self.asn = asn + self.group = group self.v4 = comma_set() self.v6 = comma_set() def __repr__(self): - s = "<%s asn %s" % (self.__class__.__name__, self.asn) + s = "<%s asn %s group %s" % (self.__class__.__name__, self.asn, self.group) if self.v4: s += " v4 %s" % self.v4 if self.v6: @@ -126,13 +127,14 @@ class roa_requests(dict): Database of ROA requests. """ - def add(self, asn, prefix): + def add(self, asn, group, prefix): """ - Add one <ASN, prefix> pair to ROA request database. + Add one <ASN, group, prefix> set to ROA request database. """ - if asn not in self: - self[asn] = roa_request(asn) - self[asn].add(prefix) + key = (asn, group) + if key not in self: + self[key] = roa_request(asn, group) + self[key].add(prefix) def xml(self, e): """ @@ -147,9 +149,9 @@ class roa_requests(dict): Parse ROA requests from CSV file. """ self = cls() - # format: p/n-m asn - for pnm, asn in csv_open(roa_csv_file): - self.add(asn = asn, prefix = pnm) + # format: p/n-m asn group + for pnm, asn, group in csv_open(roa_csv_file): + self.add(asn = asn, group = group, prefix = pnm) return self class child(object): diff --git a/myrpki/yamltest.py b/myrpki/yamltest.py index cb6bea07..f80420ac 100644 --- a/myrpki/yamltest.py +++ b/myrpki/yamltest.py @@ -359,9 +359,11 @@ class allocation(object): """ Write ROA CSV file. """ + group = self.name if self.is_root() else self.parent.name f = self.csvout(fn) for r in self.roa_requests: - f.writerows((p, r.asn) for p in (r.v4 + r.v6 if r.v4 and r.v6 else r.v4 or r.v6 or ())) + f.writerows((p, r.asn, group) + for p in (r.v4 + r.v6 if r.v4 and r.v6 else r.v4 or r.v6 or ())) def dump_clients(self, fn, db): """ |