From c4b33789a9b4ee5c172d8ef60a97b29f07063989 Mon Sep 17 00:00:00 2001 From: Brian Stinson Date: Oct 28 2015 16:24:07 +0000 Subject: update to pull the configuration information from /etc/bsadmin/bsadmin.conf --- diff --git a/scripts/koji-group-sync.py b/scripts/koji-group-sync.py index 334fe9f..2c98ccd 100755 --- a/scripts/koji-group-sync.py +++ b/scripts/koji-group-sync.py @@ -1,12 +1,8 @@ #!/usr/bin/python -from centos import AccountSystem -from centos import defaults +import ConfigParser +import sys -FAS_USERNAME = '' -FAS_PASSWORD = '' -GROUP_INCLUDE_PREFIX = 'sig-' -GROUP_FILE = '/etc/bsadmin/groups' -IGNORE_CERT_VALIDATION = True +from centos import AccountSystem def group_users(account_system_handle): @@ -22,7 +18,7 @@ def group_users(account_system_handle): return group_users -def write_file(group_membership, filename=GROUP_FILE): +def write_file(group_membership, filename): with open(filename, 'w') as groupfile: for groupname, users in group_membership.iteritems(): signame = groupname[len(GROUP_INCLUDE_PREFIX):] @@ -30,9 +26,23 @@ def write_file(group_membership, filename=GROUP_FILE): if __name__ == '__main__': - fas = AccountSystem(base_url=defaults.FAS_TOPURL, + config = ConfigParser.SafeConfigParser() + config.read('/etc/bsadmin/bsadmin.conf') + + try: + FAS_TOPURL = config.get('fas', 'topurl') + FAS_USERNAME = config.get('fas', 'username') + FAS_PASSWORD = config.get('fas', 'password') + IGNORE_CERT_VALIDATION = config.getboolean('fas', 'ignore_selfsigned') + GROUP_INCLUDE_PREFIX = config.get('fas', 'group_prefix') + GROUP_FILE = config.get('fas', 'group_file') + except ConfigParser.NoOptionError as e: + print >> sys.stderr, e.msg + sys.exit(-1) + + fas = AccountSystem(base_url=FAS_TOPURL, username=FAS_USERNAME, password=FAS_PASSWORD, insecure=IGNORE_CERT_VALIDATION) - write_file(group_users(fas)) + write_file(group_users(fas), GROUP_FILE)