diff options
author | Michael Elkins <melkins@tislabs.com> | 2013-09-19 21:03:58 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2013-09-19 21:03:58 +0000 |
commit | 4849858a5217693302793925f48ed12dfe3137a2 (patch) | |
tree | 15cc76d05edb5308ab5f6a1b42efb58305743666 | |
parent | b2e2790a58cca9063e51a89fc6d913fb0f6f0511 (diff) |
new cli script rpkigui-query-routes to query the web portal's routeview/rcynic db for route validity
svn path=/trunk/; revision=5500
-rwxr-xr-x | rpkid/portal-gui/scripts/rpkigui-query-routes | 56 | ||||
-rw-r--r-- | rpkid/setup.py | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/rpkid/portal-gui/scripts/rpkigui-query-routes b/rpkid/portal-gui/scripts/rpkigui-query-routes new file mode 100755 index 00000000..5431db20 --- /dev/null +++ b/rpkid/portal-gui/scripts/rpkigui-query-routes @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +# Copyright (C) 2013 SPARTA, Inc. a Parsons Company +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +__version__ = '$Id$' + +import sys +import optparse + +from rpki.gui.script_util import setup +setup() + +from rpki.gui.routeview import models as rv +from rpki.resource_set import resource_range_ip + +parser = optparse.OptionParser( + usage='%prog [options] PREFIX', + description='query the rpki web portal database for routes covering a ' + 'prefix specified as an argument, and display the validity and covering ' + 'ROAs for each route', + version=__version__, +) +options, args = parser.parse_args() + +if len(args) == 0: + print 'error: Specify an address/prefix' + sys.exit(1) + +# allow bare IP addresses +if '/' not in args[0]: + args[0] = args[0] + '/32' + +r = resource_range_ip.parse_str(args[0]) + +qs = rv.RouteOrigin.objects.filter( + prefix_min__lte=r.min, + prefix_max__gte=r.max +) + +for route in qs: + print route.as_resource_range(), route.asn, route.status + for pfx in route.roa_prefixes: + for roa in pfx.roas.all(): + print ' ', pfx.as_roa_prefix(), roa.asid, roa.repo.uri diff --git a/rpkid/setup.py b/rpkid/setup.py index 678d5f61..7850d6d4 100644 --- a/rpkid/setup.py +++ b/rpkid/setup.py @@ -62,6 +62,7 @@ setup(name = "rpkitoolkit", "rpki-sql-backup", "rpki-sql-setup", "portal-gui/scripts/rpki-manage", + "portal-gui/scripts/rpkigui-query-routes", "irbe_cli"]), (autoconf.libexecdir, ["irdbd", |