diff options
author | Adrian Likins <alikins@grimlock.devel.redhat.com> | 2008-03-04 13:27:52 -0500 |
---|---|---|
committer | Adrian Likins <alikins@grimlock.devel.redhat.com> | 2008-03-04 13:27:52 -0500 |
commit | 17db1a2cf51068e6b65ff06e23a98db72e5dff84 (patch) | |
tree | b004286517efab1fbda654418f7ca3c3c4cace55 /scripts | |
parent | 71c9f2abc68f38c90c667b14af256dbb0a14d930 (diff) | |
download | func-17db1a2cf51068e6b65ff06e23a98db72e5dff84.tar.gz func-17db1a2cf51068e6b65ff06e23a98db72e5dff84.tar.xz func-17db1a2cf51068e6b65ff06e23a98db72e5dff84.zip |
don't try to use the config classes to read the old config files, it
doesn't really work, istead do it the old fashioned way and use
ConfigParser directly.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/update-func | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/scripts/update-func b/scripts/update-func index 30fced5..663e3f1 100755 --- a/scripts/update-func +++ b/scripts/update-func @@ -21,6 +21,7 @@ import os import subprocess +import ConfigParser from func import commonconfig from func import config @@ -76,6 +77,19 @@ def certmaster_minion_has_cert_info(cmc_content): return False + +# dumb +def read_config(config_file, key): + cfg = ConfigParser.SafeConfigParser() + cfg.read(config_file) + + try: + return cfg.get("main", key) + except ConfigParser.NoOptionError: + return None + + + def migrate_minion_conf_settings(): # ugh, do I really want to parse these files? # guess I kind of have to... @@ -86,36 +100,50 @@ def migrate_minion_conf_settings(): fc_f = open(FUNC_MINION_CONF, "r") fc_c = fc_f.readlines() obs = False - for line in fc_c: - match = line.find("obsolete =") - if match != -1 and match == 0: - obs = True + + + # we can't rely on the new config class to read the old config + # files, so we do it the old fashioned way + if read_config(FUNC_MINION_CONF, "obsolete"): + obs = True if obs == True: return + cmc = cm_config.read_config(CERTMASTER_CONF, cm_commonconfig.CMConfig) cm_mc = cm_config.read_config(CERTMASTER_MINION_CONF, cm_commonconfig.MinionConfig) - cmc.cert_dir = fc.cert_dir - cmc.certmaster = fc.certmaster + cert_dir = read_config(FUNC_MINION_CONF, "cert_dir") + + if cert_dir: + cmc.cert_dir = cert_dir + cm_mc.cert_dir = cert_dir + + cert_master = read_config(FUNC_MINION_CONF, "certmaster") + + if cert_master: + cmc.certmaster = cert_master + cm_mc.certmaster = cert_master + + + + # also, the config class we current use config.py:BaseConfig kind of sucks + # for migration stuff. Basically, we can't read values that aren't defined, + # we can't right stuff that isnt define, etc. - cm_mc.cert_dir = fc.cert_dir - cm_mc.certmaster = fc.certmaster # there doesnt' seem to be an obvious way to # add something to a config obj/file without # changing the corresponding config class, # so this is a kluge + fc_f = open(FUNC_MINION_CONF, "a+") fc_f.write("obsolete = 1\n") fc_f.close() -# print "fc", fc -# print "dir(fc)", dir(fc) - cmc.write(open(CERTMASTER_CONF, 'w')) cm_mc.write(open(CERTMASTER_MINION_CONF, 'w')) |