+
+ def gather_logs (self):
+ # (1) get the plc's /var/log and store it locally in logs/<plcname>-var-log/*
+ # (2) get all the nodes qemu log and store it as logs/<node>-qemu.log
+ # (3) get the nodes /var/log and store is as logs/<node>-var-log/*
+ # (4) as far as possible get the slice's /var/log as logs/<slice>-<node>-var-log/*
+ # (1)
+ print "-------------------- TestPlc.gather_logs : PLC's /var/log"
+ self.gather_var_logs ()
+ # (2)
+ print "-------------------- TestPlc.gather_logs : nodes's QEMU logs"
+ for site_spec in self.plc_spec['sites']:
+ test_site = TestSite (self,site_spec)
+ for node_spec in site_spec['nodes']:
+ test_node=TestNode(self,test_site,node_spec)
+ test_node.gather_qemu_logs()
+ # (3)
+ print "-------------------- TestPlc.gather_logs : nodes's /var/log"
+ self.gather_nodes_var_logs()
+ # (4)
+ print "-------------------- TestPlc.gather_logs : sample sliver's /var/log"
+ self.gather_first_sliver_logs()
+ return True
+
+ def gather_first_sliver_logs(self):
+ try:
+ test_sliver = self.locate_first_sliver()
+ remote = test_sliver.tar_var_logs()
+ utils.system("mkdir -p logs/%s-var-log"%test_sliver.name())
+ command = remote + " | tar -C logs/%s-var-log -xf -"%test_sliver.name()
+ utils.system(command)
+ except Exception,e:
+ print 'Cannot locate first sliver - giving up',e
+ return True
+
+ def gather_var_logs (self):
+ to_plc = self.actual_command_in_guest("tar -cf - /var/log")
+ command = to_plc + "| tar -C logs/%s-var-log -xf -"%self.name()
+ utils.system("mkdir -p logs/%s-var-log"%self.name())
+ utils.system(command)
+
+ def gather_nodes_var_logs (self):
+ for site_spec in self.plc_spec['sites']:
+ test_site = TestSite (self,site_spec)
+ for node_spec in site_spec['nodes']:
+ test_node=TestNode(self,test_site,node_spec)
+ test_ssh = TestSsh (test_node.name(),key="/etc/planetlab/root_ssh_key.rsa")
+ to_plc = self.actual_command_in_guest ( test_ssh.actual_command("tar -C /var/log -cf - ."))
+ command = to_plc + "| tar -C logs/%s-var-log -xf -"%test_node.name()
+ utils.system("mkdir -p logs/%s-var-log"%test_node.name())
+ utils.system(command)
+
+