def _get_hostname_of_node1(self, image): command = [ "sh", "-c", "[ $SLURM_NODEID -eq 1 ] && echo $(hostname); exit 0" ] out = util.run_command_in_container_with_slurm( image=image, command=command, options_of_srun_command=["-N2"], options_of_run_command=["--ssh"]) assert len(out) == 1 # expect one single line of output return out[0]
def _get_hostname_of_node1_though_ssh(self, image, hostname_node1): command = [ "sh", "-c", "if [ $SLURM_NODEID -eq 0 ]; then" " echo $(ssh {} hostname);" " ssh {} touch /done;" "else" " while [ ! -e /done ]; do" " sleep 1;" " done;" "fi".format(hostname_node1, hostname_node1) ] out = util.run_command_in_container_with_slurm( image=image, command=command, options_of_srun_command=["-N2"], options_of_run_command=["--ssh"]) assert len(out) == 1 # expect one single line of output return out[0]
def _get_prettyname_of_node1_through_ssh(self, image, hostname_node1): command = [ "sh", "-c", "if [ $SLURM_NODEID -eq 0 ]; then" " echo $(ssh {} cat /etc/os-release);" " ssh {} touch /done;" "else" " while [ ! -e /done ]; do" " sleep 1;" " done;" "fi".format(hostname_node1, hostname_node1) ] out = util.run_command_in_container_with_slurm( image=image, command=command, options_of_srun_command=["-N2"], options_of_run_command=["--ssh"]) assert len(out) == 1 # expect one single line of output return re.match(r".*PRETTY_NAME=\"([^\"]+)\" .*", out[0]).group(1)