From b553d99a3e28444c6d65df1085ac06b1ba8f2d7d Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Thu, 11 Jan 2007 23:46:22 +0000 Subject: [PATCH] - add --noscripts option to skip running pre-, post-, and error commands --- conf_files.init | 5 +++-- conf_files.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/conf_files.init b/conf_files.init index 887d4fe..c8fc664 100644 --- a/conf_files.init +++ b/conf_files.init @@ -5,14 +5,15 @@ # chkconfig: 3 20 80 # description: Updates node configuration files at startup # -# $Id: nm.init,v 1.1 2006/11/13 20:04:44 mlhuang Exp $ +# $Id: conf_files.init,v 1.1 2006/11/18 18:43:18 mlhuang Exp $ # Source function library. . /etc/init.d/functions case "$1" in start|restart|reload) - action $"Updating node configuration files: " python /usr/share/NodeManager/conf_files.py + shift + action $"Updating node configuration files: " python /usr/share/NodeManager/conf_files.py $* ;; *) echo $"Usage: $0 {start|restart}" diff --git a/conf_files.py b/conf_files.py index d349de0..a7d70e8 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,7 +27,7 @@ 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) else: return 0 @@ -91,6 +92,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', 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 +109,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) -- 2.43.0