From: Baris Metin Date: Wed, 9 Jun 2010 13:52:19 +0000 (+0200) Subject: add no_password option X-Git-Tag: foo~121 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ea79931a1dadb47b0c437c7f49c62e59be653cd7;p=infrastructure.git add no_password option --- diff --git a/scripts/export-omf.py b/scripts/export-omf.py index e3a0586..1f0517b 100755 --- a/scripts/export-omf.py +++ b/scripts/export-omf.py @@ -20,8 +20,10 @@ def getPersons(filter={}): class OmfUserBase: - def __init__ (self,filename): - self.filename = filename + def __init__ (self, options, filename): + self.filename=filename + self.options=options + def save_person (self, file, person, sites_by_id, pubkeys_by_id): # do not expose people without a key @@ -36,7 +38,8 @@ class OmfUserBase: print >>file, "site=%s"%sites_by_id[site_id]['name'] if 'pi' in person['roles']: print >>file, "pi=yes" - print >>file, "password=%s"%person['password'] + if not self.options.no_password: + print >>file, "password=%s"%person['password'] for key_id in person['key_ids']: print >>file, "ssh=%s"%pubkeys_by_id[key_id] @@ -61,8 +64,17 @@ class OmfUserBase: def main (): - output=sys.argv[1] - userbase=OmfUserBase(output) + parser = OptionParser (usage="%prog [options] OUTPUT_FILE") + parser.add_option ("-n","--no-password", action="store_true", + dest="no_password", default=False, help="Don't include encrypted passwords") + options,args = parser.parse_args() + + try: + output = args[0] + except IndexError: + parser.error("no output file") + + userbase=OmfUserBase(options, output) userbase.save() if __name__ == '__main__':