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
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]
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__':