X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fmanage-infrastructure.py;h=685c964b6349806e707cae6f2331ad2403653f3e;hb=509217a4fd801e3165f4e2a7a561f99960e51bdf;hp=3312d929c3260605b7c1344bdc53ff2c2c1fa5fb;hpb=17308fd16c8e790ecd822a69f70f0a8a68f62ac0;p=infrastructure.git diff --git a/scripts/manage-infrastructure.py b/scripts/manage-infrastructure.py index 3312d92..685c964 100755 --- a/scripts/manage-infrastructure.py +++ b/scripts/manage-infrastructure.py @@ -9,21 +9,40 @@ class BuildBoxes: # everything in the onelab.eu domain domain = 'pl.sophia.inria.fr' - testmaster = 'testmaster' build_boxes = [ "mirror", "liquid", "reed", "velvet", ] plc_boxes = [ "testplc" ] - # qemu32-5 is officially dead - qemu_boxes = \ - [ "qemu64-%d"%i for i in range (1,4) ] + \ - [ "qemu32-%d"%i for i in range (1,5) ] - 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) @@ -307,9 +326,16 @@ Default is to act on test boxes only""" 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