X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=conf_files.py;h=4903b3f8de788a6090f064183889df97579a758c;hb=refs%2Fheads%2F1.5;hp=d349de0d743c0af5cbc2976b10bfff8d77d6e19f;hpb=a53c6df31a0acdd9a0081d6ded652f6b0d734e54;p=nodemanager.git diff --git a/conf_files.py b/conf_files.py index d349de0..4903b3f 100644 --- a/conf_files.py +++ b/conf_files.py @@ -13,8 +13,9 @@ import tools class conf_files: - def __init__(self, config): + def __init__(self, config, noscripts=False): self.config = config + self.noscripts = noscripts self.cond = threading.Condition() self.data = None @@ -26,9 +27,9 @@ class conf_files: except IOError: return None def system(self, cmd): - if cmd: + if not self.noscripts and cmd: logger.log('conf_files: running command %s' % cmd) - return os.system(cmd) + return tools.fork_as(None, os.system, cmd) else: return 0 def update_conf_file(self, cf_rec): @@ -41,7 +42,11 @@ class conf_files: uid = pwd.getpwnam(cf_rec['file_owner'])[2] gid = grp.getgrnam(cf_rec['file_group'])[2] url = 'https://%s/%s' % (self.config.PLC_BOOT_HOST, cf_rec['source']) - contents = curlwrapper.retrieve(url, self.config.cacert) + try: + contents = curlwrapper.retrieve(url, self.config.cacert) + except curlwrapper.CurlException: + logger.log('conf_files: failed to retrieve %s from %s, skipping' % (dest, url)) + return if not cf_rec['always_update'] and sha.new(contents).digest() == self.checksum(dest): return if self.system(cf_rec['preinstall_cmd']): @@ -91,6 +96,7 @@ if __name__ == '__main__': parser = optparse.OptionParser() parser.add_option('-f', '--config', action='store', dest='config', default='/etc/planetlab/plc_config', help='PLC configuration file') parser.add_option('-k', '--session', action='store', dest='session', default='/etc/planetlab/session', help='API session key (or file)') + parser.add_option('--noscripts', action='store_true', dest='noscripts', default=False, help='Do not run pre- or post-install scripts') (options, args) = parser.parse_args() # Load /etc/planetlab/plc_config @@ -107,6 +113,6 @@ if __name__ == '__main__': from plcapi import PLCAPI plc = PLCAPI(config.plc_api_uri, config.cacert, auth = session) - main = conf_files(config) + main = conf_files(config, options.noscripts) data = plc.GetSlivers() main.run_once(data)