def worker(username_host_tuple): """ <Purpose> Worker thread that makes calls to remote_shellexec <Arguments> username_host_tuple: username_host_tuple[0] is username: the username to log in as username_host_tuple[1] is host: the remote hostname/ip to install on. <Exceptions> None. <Side Effects> None. <Returns> None. """ username = '******' #username_host_tuple[0] host = username_host_tuple # build up a command string that'll download and install seattle cmd_list = [] # 1. Remove old file, and download the file cmd_list.append('cd seattle_repy; ./uninstall.sh; cd ~; rm -rf seattle_repy') cmd_list.append('rm -rf seattle_linux.tgz') cmd_list.append('wget https://seattlegeni.cs.washington.edu/geni/download/flibble/seattle_linux.tgz') #cmd_list.append('wget --no-check-certificate https://blackbox.cs.washington.edu/geni/html/tukwila/seattle_linux.tgz') # 2. Untar cmd_list.append('tar -xf seattle_linux.tgz') # 3. Change into seattle_repy directory and execute python install.sh to start seattle cmd_list.append('cd seattle_repy; ./install.sh > /dev/null 2> /dev/null < /dev/null&') # merge into a command string cmd_str = '; '.join(cmd_list) out, err, retcode = deploy_network.remote_shellexec(cmd_str, username, host) format_print(out, err)
def threadable_cleanup_final(remote_machines): """ <Purpose> Cleans the files created by this script from the remote machine <Arguments> remote_machines: a list containing a single tuple of (user, remotehost) <Exceptions> None. <Side Effects> <Returns> None. """ # Assume single element if it's not a list if type(remote_machines) != type([]): remote_machines = [remote_machines] # for every machine in our list... for machine_tuple in remote_machines: username = machine_tuple[0] machine = machine_tuple[1] deploy_logging.log('Final cleanup', 'Final cleanup of ' + machine) # build up our list of files/folders we need to delete cmd_list = [] cmd_list.append('rm -rf runlocaltests.py') cmd_list.append('rm -rf hashes.dict') cmd_list.append('rm -rf ' + machine + '.deployrun.log') cmd_list.append('rm -rf ' + machine + '.deployrun.err.log') cmd_list.append('rm -rf testprocess.py') cmd_list.append('rm -rf verifyfiles.mix') cmd_list.append('rm -rf ' + machine + '.tgz') cmd_list.append('rm -rf deploy.tar') cmd_list.append('rm -rf cleanup_deploy.py') #TODO: cleanup custom scripts as well here? # merge the commands into a string that we'll execute cmd_str = '; '.join(cmd_list) ssh_stdout, ssh_stderr, ssh_errcode = deploy_network.remote_shellexec( cmd_str, username, str(machine)) deploy_logging.print_to_log('Detailed cleanup', ssh_stdout, ssh_stderr, ssh_errcode) return
def threadable_cleanup_final(remote_machines): """ <Purpose> Cleans the files created by this script from the remote machine <Arguments> remote_machines: a list containing a single tuple of (user, remotehost) <Exceptions> None. <Side Effects> <Returns> None. """ # Assume single element if it's not a list if type(remote_machines) != type([]): remote_machines = [remote_machines] # for every machine in our list... for machine_tuple in remote_machines: username = machine_tuple[0] machine = machine_tuple[1] deploy_logging.log('Final cleanup', 'Final cleanup of '+machine) # build up our list of files/folders we need to delete cmd_list = [] cmd_list.append('rm -rf runlocaltests.py') cmd_list.append('rm -rf hashes.dict') cmd_list.append('rm -rf '+machine+'.deployrun.log') cmd_list.append('rm -rf '+machine+'.deployrun.err.log') cmd_list.append('rm -rf testprocess.py') cmd_list.append('rm -rf verifyfiles.mix') cmd_list.append('rm -rf '+machine+'.tgz') cmd_list.append('rm -rf deploy.tar') cmd_list.append('rm -rf cleanup_deploy.py') #TODO: cleanup custom scripts as well here? # merge the commands into a string that we'll execute cmd_str = '; '.join(cmd_list) ssh_stdout, ssh_stderr, ssh_errcode = deploy_network.remote_shellexec(cmd_str, username, str(machine)) deploy_logging.print_to_log('Detailed cleanup', ssh_stdout, ssh_stderr, ssh_errcode) return
def worker(cmd, username, host): """ <Purpose> Worker thread that makes calls to remote_shellexec and increments the running thread counter until the thread has finished. <Arguments> cmd: the command string to execute on the machine username: the username to log in as host: the remote hostname/ip to install on. <Exceptions> None. <Side Effects> None. <Returns> None. """ global thread_counter, thread_lock # do an atomic add on the number of threads running thread_lock.acquire() thread_counter += 1 thread_lock.release() out, err, retcode = deploy_network.remote_shellexec(cmd, username, host) format_print('|\n\n Log from node: '+host+'\n'+out, err) # do an atomic subtract on the number of threads running thread_lock.acquire() thread_counter -= 1 thread_lock.release()
def worker(cmd, username, host): """ <Purpose> Worker thread that makes calls to remote_shellexec and increments the running thread counter until the thread has finished. <Arguments> cmd: the command string to execute on the machine username: the username to log in as host: the remote hostname/ip to install on. <Exceptions> None. <Side Effects> None. <Returns> None. """ global thread_counter, thread_lock # do an atomic add on the number of threads running thread_lock.acquire() thread_counter += 1 thread_lock.release() out, err, retcode = deploy_network.remote_shellexec(cmd, username, host) format_print('|\n\n Log from node: ' + host + '\n' + out, err) # do an atomic subtract on the number of threads running thread_lock.acquire() thread_counter -= 1 thread_lock.release()