def run(self, state): for spec in self.ndds: cmdline = ['python', '/usr/local/bin/ndd.py', '-p', self.ndd_port, '-i', spec.input_, '-o', spec.output] if spec.source: remote_source = cfg.get(self.config_url, spec.source)['name'] source = '{}@{}'.format(self.get_login(), remote_source) else: cmdline.extend(['--local']) remote_source = None source = self.local_addr cmdline.extend(['-s', source]) if spec.args: cmdline.extend(['-{}'.format(spec.args)]) for host in sorted(state.active_hosts, key=lambda host: host.props.get('switch')): if remote_source and host.name == remote_source: continue cmdline.extend( ['-d', '{}@{}'.format(self.get_login(), str(host.name))]) rv, _ = proc.run_process(cmdline, state.log) if rv != 0: for host in list(state.active_hosts): host.fail(self, 'failed to run ndd.py')
def step(self, state): absent_hosts = dict((host.sname, host) for host in state.active_hosts) rv, output = proc.run_process( ['sinfo', '-t', 'idle', '-h', '-o', '%n'], state.log) if rv == 0: for name in output.strip().split('\n'): if name in absent_hosts: del absent_hosts[name] return (True, absent_hosts.values()) else: return (False, None)
def step(self, state): absent_hosts = dict((host.sname, host) for host in state.active_hosts) rv, output = proc.run_process(['sinfo', '-t', 'idle', '-h', '-o', '%n'], state.log) if rv == 0: for name in output.strip().split('\n'): if name in absent_hosts: del absent_hosts[name] return (True, absent_hosts.values()) else: return (False, None)
def run(self, state): for src, dst in self.ndds: cmdline = ['python', '/usr/local/bin/ndd_slurm.py'] cmdline.extend(['-s', self.local_addr, '-i', src, '-o', dst]) for host in sorted(state.active_hosts, key=lambda host: host.props.get('switch')): cmdline.extend(['-d', str(host.sname)]) rv, _ = proc.run_process(cmdline, state.log) if rv != 0: for host in list(state.active_hosts): host.fail(self, 'failed to run ndd_slurm.py')
def run_scp(self, host, login, src, dst): return proc.run_process([ 'scp', '-o', 'PasswordAuthentication=no', src, '{}@{}:{}'.format( login, host, dst) ], host.state.log)
def run_scp(self, host, login, src, dst): return proc.run_process( ['scp', '-o', 'PasswordAuthentication=no', src, '{}@{}:{}'.format(login, host, dst)], host.state.log)