added: launch_ssh: fake execution of commands
This commit is contained in:
parent
3adc1f569d
commit
87d9c1487a
24
nodes.py
24
nodes.py
@ -119,19 +119,20 @@ class Node(object):
|
|||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
command=''
|
command=''
|
||||||
)
|
)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
logging.error("node: %s, ip: %s, cmdfile: %s,"
|
logging.error("node: %s, ip: %s, cmdfile: %s,"
|
||||||
" code: %s, error message: %s" %
|
" code: %s, error message: %s" %
|
||||||
(self.node_id, self.ip, f, code, errs))
|
(self.node_id, self.ip, f, code, errs))
|
||||||
dfile = os.path.join(ddir, 'node-%s-%s-%s' %
|
dfile = os.path.join(ddir, 'node-%s-%s-%s' %
|
||||||
(self.node_id, self.ip, os.path.basename(f)))
|
(self.node_id, self.ip, os.path.basename(f)))
|
||||||
logging.info('outfile: %s' % dfile)
|
logging.info('outfile: %s' % dfile)
|
||||||
self.mapcmds[os.path.basename(f)] = dfile
|
self.mapcmds[os.path.basename(f)] = dfile
|
||||||
try:
|
if not fake:
|
||||||
with open(dfile, 'w') as df:
|
try:
|
||||||
df.write(outs)
|
with open(dfile, 'w') as df:
|
||||||
except:
|
df.write(outs)
|
||||||
logging.error("Can't write to file %s" % dfile)
|
except:
|
||||||
|
logging.error("Can't write to file %s" % dfile)
|
||||||
|
|
||||||
def du_logs(self, label, sshopts, odir='info', timeout=15):
|
def du_logs(self, label, sshopts, odir='info', timeout=15):
|
||||||
logging.info('node:%s(%s), filelist: %s' %
|
logging.info('node:%s(%s), filelist: %s' %
|
||||||
@ -367,7 +368,7 @@ class Nodes(object):
|
|||||||
for node in self.nodes.values():
|
for node in self.nodes.values():
|
||||||
logging.debug('%s' % node.files[ckey])
|
logging.debug('%s' % node.files[ckey])
|
||||||
|
|
||||||
def launch_ssh(self, odir='info', timeout=15):
|
def launch_ssh(self, odir='info', timeout=15, fake=false):
|
||||||
lock = flock.FLock('/tmp/timmy-cmds.lock')
|
lock = flock.FLock('/tmp/timmy-cmds.lock')
|
||||||
if not lock.lock():
|
if not lock.lock():
|
||||||
logging.warning('Unable to obtain lock, skipping "cmds"-part')
|
logging.warning('Unable to obtain lock, skipping "cmds"-part')
|
||||||
@ -384,7 +385,8 @@ class Nodes(object):
|
|||||||
self.sshvars,
|
self.sshvars,
|
||||||
self.sshopts,
|
self.sshopts,
|
||||||
odir,
|
odir,
|
||||||
self.timeout,))
|
self.timeout,
|
||||||
|
fake))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
t.start()
|
t.start()
|
||||||
for t in threads:
|
for t in threads:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user