From f32e4dbdee0249760f10c353eb50b6b7308f1b5c Mon Sep 17 00:00:00 2001 From: Thanasis Naskos Date: Thu, 12 Mar 2015 15:40:14 +0200 Subject: [PATCH] send files to nodes --- GstarCluster.py | 16 +++++++++++++--- JustSendFiles.py | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 JustSendFiles.py diff --git a/GstarCluster.py b/GstarCluster.py index bf53a71..4e6e927 100755 --- a/GstarCluster.py +++ b/GstarCluster.py @@ -117,12 +117,12 @@ class GstarCluster(object): stdin, stdout, stderr = ssh.exec_command('mount /media/datasets') # sending experiment execution files - stdin, stdout, stderr = ssh.exec_command('mkdir /root/gstar') + stdin, stdout, stderr = ssh.exec_command('mkdir /root/gstar_master') transport = paramiko.Transport((node.ip_address, 22)) transport.connect(username = 'root', password = 'secretpw') transport.open_channel("session", node.ip_address, "localhost") sftp = paramiko.SFTPClient.from_transport(transport) - experiment_assets = [os.path.join(root, name) for root, dirs, files in os.walk("./templates/gstar") for name in files] + experiment_assets = [os.path.join(root, name) for root, dirs, files in os.walk("./templates/gstar_master") for name in files] for expasset in experiment_assets: sftp.put(expasset,expasset.replace("./templates","/root")) sftp.close() @@ -134,7 +134,17 @@ class GstarCluster(object): # Make a /etc/hosts file as you go hosts.write(node.ip_address + "\t" + host_template + str(i) +"\n") - + # sending experiment execution files + stdin, stdout, stderr = ssh.exec_command('mkdir /root/gstar') + transport = paramiko.Transport((node.ip_address, 22)) + transport.connect(username = 'root', password = 'secretpw') + transport.open_channel("session", node.ip_address, "localhost") + sftp = paramiko.SFTPClient.from_transport(transport) + experiment_assets = [os.path.join(root, name) for root, dirs, files in os.walk("./templates/gstar") for name in files] + for expasset in experiment_assets: + sftp.put(expasset,expasset.replace("./templates","/root")) + sftp.close() + # Set hostname on the machine stdin, stdout, stderr = ssh.exec_command('echo \"'+host_template+str(i)+"\" > /etc/hostname") stdin, stdout, stderr = ssh.exec_command('hostname \"'+host_template+str(i)+"\"") diff --git a/JustSendFiles.py b/JustSendFiles.py new file mode 100644 index 0000000..05f3b86 --- /dev/null +++ b/JustSendFiles.py @@ -0,0 +1,27 @@ +import GanetiCluster, paramiko, os + + +class JustSendFiles(object): + + def __init__(self): + eucacluster = GanetiCluster.GanetiCluster('Coordinator.properties') + instances = eucacluster.describe_instances() + i = 0 + for instance in instances: + ssh = paramiko.SSHClient() + transport = paramiko.Transport((instance.ip_address, 22)) + transport.connect(username = 'root', password = 'secretpw') + transport.open_channel("session", instance.ip_address, "localhost") + sftp = paramiko.SFTPClient.from_transport(transport) + if i==0: #master + experiment_assets = [os.path.join(root, name) for root, dirs, files in os.walk("./templates/gstar_master") for name in files] + else: #worker + experiment_assets = [os.path.join(root, name) for root, dirs, files in os.walk("./templates/gstar") for name in files] + for expasset in experiment_assets: + sftp.put(expasset,expasset.replace("./templates","/root")) + sftp.close() + i = i+1 + + +if __name__ == "__main__": + sendthem = JustSendFiles() -- 2.2.2