diff --git a/CLnode.py b/CLnode.py index 0c11c05..3a6f738 100644 --- a/CLnode.py +++ b/CLnode.py @@ -92,6 +92,7 @@ def copy(self): # Then extracts it and runs the setup script def deploy(self,payload,sshKey,launch=False): # TODO: error handeling + # remove SIG with ssh-keygen -f "/home/madmaze/.ssh/known_hosts" -R ec2-184-73-46-186.compute-1.amazonaws.com print "\n============================================" print "Deploing",self.instID,"/",self.instName print "=====" @@ -123,3 +124,37 @@ def deploy(self,payload,sshKey,launch=False): return -1 else: print "Master node: No need to deploy!" + + def gather(self,logsDir,sshKey): + print "\n============================================" + print "Gathering logs: ",self.instID,"/",self.instName + print "=====" + logsDir+='/'+self.instID+'-'+self.instName + + try: + res=GF.run("mkdir -p "+logsDir) + res=GF.run("scp -r -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+":/var/tmp/log "+logsDir) + print "scp -r -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+":/var/tmp/log "+logsDir + except Exception as x: + print x, "\n", res + return -1 + + ''' + # EXTRACT payload + try: + res=GF.run("ssh -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+" 'tar xvf ~/bundle.tar;'") + print "ssh -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+" 'tar xvf ~/bundle.tar;'" + except Exception as x: + print x, "\n", res + return -1 + + if launch is True: + # LAUNCH Payload + try: + res=GF.run("ssh -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+" 'python ~/payload/setup.py'") + print "ssh -o StrictHostKeyChecking=no -i "+sshKey+" ubuntu@"+self.url+" 'python ~/payload/setup.py'" + self.deployed = True + except Exception as x: + print x, "\n", res + return -1 + ''' diff --git a/bundle.tar b/bundle.tar index 0b0b297..1ab6d0c 100644 Binary files a/bundle.tar and b/bundle.tar differ diff --git a/masterSpore.py b/masterSpore.py index 0f7afd0..db0d186 100755 --- a/masterSpore.py +++ b/masterSpore.py @@ -237,12 +237,13 @@ def monitor(n, timeout): sshKey='~/.ec2/pkey' rebuildBundle=True payload='./bundle.tar' + logsDir='./logs' payloadDir='./payload' print "Cluster manager v0.2"; argc=0 try: opts, args = getopt.getopt(sys.argv[1:], "dilh", ["help", "debug", "info", "list", "listspots", "listblock", - "launch=", "shutdown", "deployall", "killall", "kill=","deploy=","master="]) + "launch=", "shutdown", "deployall","gatherlogs", "killall", "kill=","deploy=","master="]) except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" @@ -386,6 +387,16 @@ def monitor(n, timeout): if n.status=='running': n.deploy(payload,sshKey,True) saveState() + elif o in ("--gatherlogs"): + lt = time.localtime(time.time()) + #should be ddmmyyyy-hhmmss AKA should not allow single digits in time + timestamp=str(lt[2])+str(lt[1])+str(lt[0])+"-"+str(lt[3])+":"+str(lt[4])+":"+str(lt[5]) + if GF.confirmQuestion("!!This will gather up all logs from agents and master!\nAre you sure you want to continue?") is False: + sys.exit() + for n in GF.nodes: + if n.status=='running': + n.gather(logsDir+"/"+timestamp,sshKey) + saveState() elif o in ("--help"): print "Help:\n" print "./masterSporte.py --help - help menue" diff --git a/payload/runconfig b/payload/runconfig index be8e0d1..e43a50f 100644 Binary files a/payload/runconfig and b/payload/runconfig differ diff --git a/payload/setup.py b/payload/setup.py index b8fe0f7..c66ec17 100644 --- a/payload/setup.py +++ b/payload/setup.py @@ -10,5 +10,7 @@ def run(cmd): try: res=run("touch ~/TEST") + res=run("mkdir -p /var/tmp/log") + res=run("ifconfig > /var/tmp/log/conifg") except Exception as x: print x, "\n", res