add re_glob function from yum to utils. --- func/overlord/client.py | 20 ++++++++++++++++++-- func/utils.py | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/func/overlord/client.py b/func/overlord/client.py index 4e924c6..64622c4 100644 --- a/func/overlord/client.py +++ b/func/overlord/client.py @@ -155,7 +155,12 @@ class Minions(object): if self.cm_config.peering: peer_gloob = "%s/%s.%s" % (self.cm_config.peerroot, each_gloob, self.cm_config.cert_extension) certs += glob.glob(peer_gloob) - + + # if we can't match this gloob and the gloob is not REALLY a glob + # let the gloob be the hostname we try to connect to. + if not certs and not func_utils.re_glob(each_gloob): + tmp_hosts.add(each_gloob) + for cert in certs: tmp_certs.add(cert) # use basename to trim off any excess /'s, fix @@ -290,7 +295,10 @@ class PuppetMinions(Minions): for line in fo.readlines(): if re.match('\s*(#|$)', line): continue - (serial, before, after, cn) = line.split() + try: + (serial, before, after, cn) = line.split() + except ValueError: + continue before = time.strftime('%s', time.strptime(before, time_format)) if now < int(before): continue @@ -314,8 +322,15 @@ class PuppetMinions(Minions): pempath = '%s/%s.pem' % (self.overlord_config.puppet_signed_certs_dir, hostname) if not os.path.exists(pempath): continue + matched_gloob = False if fnmatch.fnmatch(hostname, each_gloob): + matched_gloob = True tmp_hosts.add(hostname) + + # if we can't match this gloob and the gloob is not REALLY a glob + # let the gloob be the hostname we try to connect to. + if not matched_gloob and not func_utils.re_glob(each_gloob): + tmp_hosts.add(each_gloob) # don't return certs path - just hosts return tmp_hosts,tmp_certs @@ -345,6 +360,7 @@ class PuppetMinions(Minions): return serials + # does the hostnamegoo actually expand to anything? def is_minion(minion_string): minions = Minions(minion_string) diff --git a/func/utils.py b/func/utils.py index 1c4d94c..a9f302b 100644 --- a/func/utils.py +++ b/func/utils.py @@ -165,9 +165,9 @@ def get_fresh_method_instance(function_ref): except Exception,e: #something went wrong so we return the normal reference value return function_ref - try: + try: return getattr(fresh_instance,function_ref.__name__) - except AttributeError: + except AttributeError: return getattr(fresh_instance,function_ref._name_) def should_log(args): @@ -210,6 +210,16 @@ def deep_base64(ds, mode = 0): return ds +_re_compiled_glob_match = None +def re_glob(s): + """ Tests if a string is a shell wildcard. """ + # TODO/FIXME maybe consider checking if it is a stringsType before going on - otherwise + # returning None + global _re_compiled_glob_match + if _re_compiled_glob_match is None: + _re_compiled_glob_match = re.compile('[*?]|\[.+\]').search + return _re_compiled_glob_match(s) + #################### PROGRESS BAR ################################## # The code below can be used for progress bar purposes as we will do #it is a combination of http://code.activestate.com/recipes/168639/ and -- 1.7.0.1 _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list