Skip to content

Commit

Permalink
added log recovery with --gatherlogs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Lee committed Aug 10, 2011
1 parent 333a632 commit f38cd54
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
35 changes: 35 additions & 0 deletions CLnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "====="
Expand Down Expand Up @@ -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
'''
Binary file modified bundle.tar
Binary file not shown.
13 changes: 12 additions & 1 deletion masterSpore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Binary file modified payload/runconfig
Binary file not shown.
2 changes: 2 additions & 0 deletions payload/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f38cd54

Please sign in to comment.