X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=debian%2Fovs-monitor-ipsec;h=0c1d6a87a044aeaacdada3eae0df22a67a0b1dc1;hb=b153e667907ed68164a15207ad5f91ad4c39927c;hp=5aca0f7c9e26930181c656ec408868a10108a00b;hpb=b54bdbe993b89829aa33b7a207c61274b953faa5;p=sliver-openvswitch.git diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec old mode 100755 new mode 100644 index 5aca0f7c9..0c1d6a87a --- a/debian/ovs-monitor-ipsec +++ b/debian/ovs-monitor-ipsec @@ -25,7 +25,7 @@ # adding an interface to racoon.conf. -import getopt +import argparse import glob import logging import logging.handlers @@ -405,17 +405,6 @@ def prune_schema(schema): schema.tables = new_tables -def usage(): - print "usage: %s [OPTIONS] DATABASE" % sys.argv[0] - print "where DATABASE is a socket on which ovsdb-server is listening." - ovs.daemon.usage() - print """\ -Other options: - --root-prefix=DIR Use DIR as alternate root directory (for testing). - -h, --help Display this help message.""" - sys.exit(0) - - def update_ipsec(ipsec, interfaces, new_interfaces): for name, vals in interfaces.iteritems(): if name not in new_interfaces: @@ -446,32 +435,23 @@ def get_ssl_cert(data): return None -def main(argv): - try: - options, args = getopt.gnu_getopt( - argv[1:], 'h', ['help', 'root-prefix='] + ovs.daemon.LONG_OPTIONS) - except getopt.GetoptError, geo: - sys.stderr.write("%s: %s\n" % (ovs.util.PROGRAM_NAME, geo.msg)) - sys.exit(1) - - for key, value in options: - if key in ['-h', '--help']: - usage() - elif key == "--root-prefix": - global root_prefix - root_prefix = value - elif not ovs.daemon.parse_opt(key, value): - sys.stderr.write("%s: unhandled option %s\n" - % (ovs.util.PROGRAM_NAME, key)) - sys.exit(1) +def main(): + + parser = argparse.ArgumentParser() + parser.add_argument("database", metavar="DATABASE", + help="A socket on which ovsdb-server is listening.") + parser.add_argument("--root-prefix", metavar="DIR", + help="Use DIR as alternate root directory" + " (for testing).") - if len(args) != 1: - sys.stderr.write("%s: exactly one nonoption argument is required " - "(use --help for help)\n" % ovs.util.PROGRAM_NAME) - sys.exit(1) + ovs.daemon.add_args(parser) + args = parser.parse_args() + ovs.daemon.handle_args(args) - remote = args[0] + global root_prefix + root_prefix = args.root_prefix + remote = args.database schema_file = "%s/vswitch.ovsschema" % ovs.dirs.PKGDATADIR schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file)) prune_schema(schema) @@ -533,7 +513,7 @@ def main(argv): if __name__ == '__main__': try: - main(sys.argv) + main() except SystemExit: # Let system.exit() calls complete normally raise