# everything in the onelab.eu domain
domain = 'pl.sophia.inria.fr'
- testmaster = 'testmaster'
build_boxes = [ "mirror", "liquid", "reed", "velvet", ]
plc_boxes = [ "testplc" ]
- qemu_boxes = \
- [ "qemu64-%d"%i for i in range (1,4) ] + \
- [ "qemu32-%d"%i for i in range (1,6) ]
- test_boxes = plc_boxes + qemu_boxes
+ testmaster = 'testmaster'
testmaster_boxes = [ testmaster ]
+ # cache the list of qemu boxes in ~/.qemu-boxes
+ # this can be refreshed by running -c
+ qemu_boxes=[]
+
+ def cache_file (self): return os.path.expanduser("~/.qemu-boxes")
+
+ def load_cache (self):
+ cache=self.cache_file()
+ if os.path.isfile(cache):
+ self.qemu_boxes=file(cache).read().split()
+ self.test_boxes = self.plc_boxes + self.qemu_boxes
+
+ # run LocalTestResources on testmaster
+ def refresh_cache (self):
+ retrieved= \
+ self.backquote_ssh(self.fqdn(self.testmaster),['LocalTestResources.py'],trash_err=True)
+ remove="."+BuildBoxes.domain
+ retrieved = [ x.replace(remove,"").strip() for x in retrieved.split()]
+ self.qemu_boxes = retrieved
+ cache=self.cache_file()
+ file(cache,'w').write(' '.join(self.qemu_boxes)+'\n')
+ print "New contents of %s:"%cache
+ print file(cache).read(),
def __init__ (self):
# dummy defaults
self.boxes = []
self.do_tracker_qemus = False
self.do_tracker_plcs = False
+ self.load_cache()
def fqdn (self, box):
return "%s.%s"%(box,self.domain)
command=['ps','-o','pid,command'] + [ pid for pid in pids.split("\n") if pid]
self.run_ssh(box,command,"Active build processes on %s (%s)"%(box,uptime),True)
+ # this one is more accurate as it locates processes in the vservers as well
+ # but it's so sloooowww
+ def handle_build_box_deep (self,box):
+ if not self.options.probe:
+ self.reboot(box)
+ else:
+ command=['uptime']
+ uptime=self.backquote_ssh(box,command,True).strip()
+
+ command=['vps','-e']
+ if self.options.dry_run:
+ self.run_ssh(box,command,None)
+ else:
+ # simulate grep vbuild
+ vps_lines=[ line for line in self.backquote_ssh(box,command,True).split("\n")
+ if line.find('vbuild') >= 0]
+ pids=[ line.split()[0] for line in vps_lines ]
+ if not pids:
+ self.header ('No build process on %s (%s)'%(box,uptime))
+ else:
+ command=['vps','-o','pid,command'] + pids
+ self.run_ssh(box,command,"Active build processes on %s (%s)"%(box,uptime),True)
+
+
vplc_matcher = re.compile(".*(vplc[0-9]+$)")
def vplcname (self, vservername):
match = self.vplc_matcher.match(vservername)
return buildname
def handle_testmaster_box (self, box):
+ if not self.options.probe:
+ pass
+ else:
command=['pgrep','run_log']
if self.options.dry_run:
self.run_ssh(box,command,None)
elif box in self.testmaster_boxes:
if type=='testmaster': self.handle_testmaster_box(self.fqdn(box))
elif type=="build":
- self.handle_build_box(self.fqdn(box))
+ if self.options.deep:
+ self.handle_build_box_deep(self.fqdn(box))
+ else:
+ self.handle_build_box(self.fqdn(box))
def handle_disk (self,box):
box=self.fqdn(box)
help="Acts on build and test boxes")
parser.add_option ("-b","--build",action="store_true",dest="build_only",default=False,
help="Acts on build boxes only")
+ parser.add_option ("-e","--deep",action="store_true", dest="deep", default=False,
+ help="on build boxes, shows vbuild processes in vservers as well; signif. slower")
parser.add_option ("-q","--qemu",action="store_true",dest="qemu_only",default=False,
help="Only acts on the qemu boxes")
parser.add_option ("-t","--trackers",action="store_true",dest="trackers_only",default=False,
help="Display the testmaster status")
parser.add_option ("-d","--disk",action="store_true",dest="show_disk",default=False,
help="Only inspects disk status")
+ parser.add_option ("-c","--refresh-cache",action="store_true",dest="refresh_cache", default=False,
+ help="Refresh cached list of qemu boxes at testmaster - implies -q")
(self.options,args) = parser.parse_args()
+ # -c implies -q
+ if self.options.refresh_cache:
+ self.options.qemu_only=True
+ self.refresh_cache()
+
# use given hostnames if provided
if args:
self.boxes=args
self.do_tracker_plcs = False
self.do_tracker_qemus = False
elif self.options.all_boxes:
- self.boxes=self.test_boxes + self.build_boxes
+ self.boxes=self.test_boxes + self.build_boxes + self.testmaster_boxes
self.do_tracker_plcs = True
self.do_tracker_qemus = True
elif self.options.build_only:
for box in self.boxes: self.handle_disk(box)
return
- # ALL OTHERS
- for box in self.boxes: self.handle_box (box,"build")
- # TESTMASTER
- for box in self.boxes: self.handle_box (box,"testmaster")
# PLCS
if self.do_tracker_plcs:self.handle_tracker_plcs ()
for box in self.boxes: self.handle_box (box,"plc")
# QEMU
if self.do_tracker_qemus:self.handle_tracker_qemus ()
for box in self.boxes: self.handle_box (box,"qemu")
+ # ALL OTHERS
+ for box in self.boxes: self.handle_box (box,"build")
+ # TESTMASTER
+ for box in self.boxes: self.handle_box (box,"testmaster")
if __name__ == "__main__":
BuildBoxes().main()