diff options
author | Michael Elkins <melkins@tislabs.com> | 2013-04-03 22:29:34 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2013-04-03 22:29:34 +0000 |
commit | 8eb584c27a20975ad1f66c92b7cd8ce52e129b06 (patch) | |
tree | 0de857772a603f33e8464c632dab824dda6fc555 | |
parent | 07fa0b0c9dcb9c2b1b2e1ad982bf3005e2195e8e (diff) |
allow rpkigui-import-routes to be invoked with zero arguments, in which it will download the routeview.org data from the default URL
see #502
svn path=/trunk/; revision=5267
-rw-r--r-- | rpkid/portal-gui/scripts/rpkigui-import-routes.py | 9 | ||||
-rw-r--r-- | rpkid/rpki/gui/routeview/util.py | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/rpkid/portal-gui/scripts/rpkigui-import-routes.py b/rpkid/portal-gui/scripts/rpkigui-import-routes.py index 4e62bdb8..776a16e2 100644 --- a/rpkid/portal-gui/scripts/rpkigui-import-routes.py +++ b/rpkid/portal-gui/scripts/rpkigui-import-routes.py @@ -30,7 +30,7 @@ class BadArgument(Exception): if __name__ == '__main__': parser = optparse.OptionParser( - usage='%prog [options] PATH', + usage='%prog [options] [PATH]', description="""This tool is used to import the IPv4/6 BGP table dumps from routeviews.org into the RPKI Web Portal database. If the input file is a bzip2 compressed file, it will be decompressed @@ -54,10 +54,9 @@ automatically.""") BGPDUMP = os.path.expanduser(options.bgpdump) try: - if len(args) != 1: - raise BadArgument('no filename specified, or more than one filename specified') - filename = args[0] - import_routeviews_dump(filename) + if len(args) > 1: + raise BadArgument('more than one filename specified') + import_routeviews_dump(*args) except Exception as e: logging.exception(e) diff --git a/rpkid/rpki/gui/routeview/util.py b/rpkid/rpki/gui/routeview/util.py index 589a7714..44168be2 100644 --- a/rpkid/rpki/gui/routeview/util.py +++ b/rpkid/rpki/gui/routeview/util.py @@ -33,6 +33,8 @@ import rpki.gui.app.timestamp # globals logger = logging.getLogger(__name__) +# Eventually this can be retrived from rpki.conf +DEFAULT_URL = 'http://archive.routeviews.org/oix-route-views/oix-full-snapshot-latest.dat.bz2' def parse_text(f): last_prefix = None @@ -161,13 +163,13 @@ class PipeFailed(ProgException): pass -def import_routeviews_dump(filename, filetype='auto'): +def import_routeviews_dump(filename=DEFAULT_URL, filetype='auto'): """Load the oix-full-snapshot-latest.bz2 from routeview.org into the rpki.gui.routeview database. Arguments: - filename [required]: the full path to the downloaded file to parse + filename [optional]: the full path to the downloaded file to parse filetype [optional]: 'text' or 'mrt' |