aboutsummaryrefslogtreecommitdiff
path: root/scripts/irbe-cli.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2007-08-06 18:01:20 +0000
committerRob Austein <sra@hactrn.net>2007-08-06 18:01:20 +0000
commitb1a0abbb8293ff99a9bad633206dba6fb1dce959 (patch)
tree26560711f428bcef155813882051ea0eaa21bfde /scripts/irbe-cli.py
parent0fed927b8d69e2553344ef98f38b643eee0fd942 (diff)
Checkpoint
svn path=/scripts/irbe-cli.py; revision=828
Diffstat (limited to 'scripts/irbe-cli.py')
-rwxr-xr-xscripts/irbe-cli.py45
1 files changed, 13 insertions, 32 deletions
diff --git a/scripts/irbe-cli.py b/scripts/irbe-cli.py
index aa4e025b..e446c47a 100755
--- a/scripts/irbe-cli.py
+++ b/scripts/irbe-cli.py
@@ -11,20 +11,18 @@ class command(object):
booleans = ()
def getopt(self, argv):
- if self.options:
- opts, args = getopt.getopt(argv, "", [x[2:] + "=" for x in self.options] + [x[2:] for x in self.booleans])
- for o, a in opts:
- handler = getattr(self, o[2:], None)
- if handler is not None:
- handler(a)
- elif o in self.booleans:
- setattr(self.pdu, o, True)
- else:
- assert o in self.options
- setattr(self.pdu, o, a)
- return args
- else:
- return argv
+ opts, args = getopt.getopt(argv, "", [x + "=" for x in self.pdu.attributes] + [x for x in self.pdu.booleans])
+ for o, a in opts:
+ o = o[2:]
+ handler = getattr(self, o, None)
+ if handler is not None:
+ handler(a)
+ elif o in self.pdu.booleans:
+ setattr(self.pdu, o, True)
+ else:
+ assert o in self.pdu.attributes
+ setattr(self.pdu, o, a)
+ return args
def process(self, msg, argv):
argv = self.getopt(argv)
@@ -40,9 +38,6 @@ class command(object):
class self(command):
- options = ("--action", "--self_id", "--extension")
- booleans = ("--rekey", "--reissue", "--revoke", "--run_now", "--publish_world_now")
-
def __init__(self):
self.pdu = rpki.left_right.self_elt()
@@ -52,9 +47,6 @@ class self(command):
class bsc(command):
- options = ("--action", "--self_id", "--bsc_id", "--key_type", "--hash_alg", "--key_length", "--signing_cert")
- booleans = ("--generate_keypair",)
-
def __init__(self):
self.pdu = rpki.left_right.bsc_elt()
@@ -63,32 +55,21 @@ class bsc(command):
class parent(command):
- options = ("--action", "--self_id", "--parent_id", "--peer_ta", "--bsc_link", "--repository_link", "--sia_base", "--peer_contact")
- booleans = ("--rekey", "--revoke", "--reissue")
-
def __init__(self):
self.pdu = rpki.left_right.parent_elt()
class child(command):
- options = ("--action", "--self_id", "--child_id", "--peer_ta", "--bsc_link", "--child_db_id")
- booleans = ("--reissue",)
-
def __init__(self):
self.pdu = rpki.left_right.child_elt()
class repository(command):
- options = ("--action", "--self_id", "--repository", "--peer_ta", "--bsc_link", "--peer_contact")
-
def __init__(self):
self.pdu = rpki.left_right.repository_elt()
class route_origin(command):
- options = ("--action", "--self_id", "--route_origin_id", "--asn", "--ipv4", "--ipv6")
- booleans = ("--suppress_publication",)
-
def __init__(self):
self.pdu = rpki.left_right.route_origin_elt()
@@ -106,7 +87,7 @@ dispatch = dict((x.__name__, x) for x in (self, bsc, parent, child, repository,
def usage():
print "Usage:", sys.argv[0]
for k,v in dispatch.iteritems():
- print " ", " ".join((k,) + v.options + v.booleans)
+ print " ", k, " ".join(["--" + x + "=x" for x in v.attributes]), " ".join(["--" + x for x in v.booleans])
sys.exit(1)
rng = rpki.relaxng.RelaxNG("left-right-schema.rng")