X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fmanage-infrastructure.py;h=81d3d210c3b33d63ea3e554233899f8796e412b7;hb=23591c42ebe1c6c2d19e2b90db94cf742e139a28;hp=685c964b6349806e707cae6f2331ad2403653f3e;hpb=509217a4fd801e3165f4e2a7a561f99960e51bdf;p=infrastructure.git diff --git a/scripts/manage-infrastructure.py b/scripts/manage-infrastructure.py index 685c964..81d3d21 100755 --- a/scripts/manage-infrastructure.py +++ b/scripts/manage-infrastructure.py @@ -190,39 +190,42 @@ class BuildBoxes: def margin_outline (self, string): return self.margin(self.outline(string)) def handle_plc_box (self,box): + # even for rebooting we need to scan vserver-stat to stop the vservers properly + vserver_names=[] + command=['vserver-stat'] + if self.options.dry_run: + self.run_ssh(box,command,"Active vservers on %s"%box) + # try to find fullname (vserver_stat truncates to a ridiculously short name) + self.header ("vserver map on %s"%box) + # fetch the contexts for all vservers on that box + map_command=['grep','.','/etc/vservers/*/context','/dev/null',] + context_map=self.backquote_ssh (box,map_command) + # at this point we have a set of lines like + # /etc/vservers/2010.01.20--k27-f12-32-vplc03/context:40144 + ctx_dict={} + for map_line in context_map.split("\n"): + if not map_line: continue + [path,xid] = map_line.split(':') + ctx_dict[xid]=os.path.basename(os.path.dirname(path)) + # at this point ctx_id maps context id to vservername + + vserver_stat = self.backquote_ssh (box,command) + for vserver_line in vserver_stat.split("\n"): + if not vserver_line: continue + context=vserver_line.split()[0] + if context=="CTX": + print self.margin(""),vserver_line + continue + longname=ctx_dict[context] + vserver_names.append(longname) + print self.margin_outline(self.vplcname(longname)),"%(vserver_line)s [=%(longname)s]"%locals() if not self.options.probe: + # remove mark for all running servers to avoid resurrection + if vserver_names: + bash="; ".join( [ "rm -f /etc/vservers/%s/apps/init/mark"%vs for vs in vserver_names ] ) + stop_command=['bash','-c',"'" + bash + "'"] + self.run_ssh(box,stop_command,"Removing mark on running vservers on %s"%box) self.reboot(box) - else: - command=['vserver-stat'] - if self.options.dry_run: - self.run_ssh(box,command,"Active vservers on %s"%box) - else: - # try to find fullname (vserver_stat truncates to a ridiculously short name) - try: - self.header ("vserver map on %s"%box) - # fetch the contexts for all vservers on that box - map_command=['grep','.','/etc/vservers/*/context','/dev/null',] - context_map=self.backquote_ssh (box,map_command) - # at this point we have a set of lines like - # /etc/vservers/2010.01.20--k27-f12-32-vplc03/context:40144 - ctx_dict={} - for map_line in context_map.split("\n"): - if not map_line: continue - [path,xid] = map_line.split(':') - ctx_dict[xid]=os.path.basename(os.path.dirname(path)) - # at this point ctx_id maps context id to vservername - - vserver_stat = self.backquote_ssh (box,command) - for vserver_line in vserver_stat.split("\n"): - if not vserver_line: continue - context=vserver_line.split()[0] - if context=="CTX": - print self.margin(""),vserver_line - continue - longname=ctx_dict[context] - print self.margin_outline(self.vplcname(longname)),"%(vserver_line)s [=%(longname)s]"%locals() - except: - self.run_ssh(box,command,"Fine-grained method failed - fallback to plain vserver-stat") vnode_matcher = re.compile(".*(vnode[0-9]+)") def vnodename (self, ps_line): @@ -357,6 +360,7 @@ Default is to act on test boxes only""" elif self.options.plc_only: self.boxes=self.plc_boxes self.do_tracker_plcs = True + self.do_tracker_plcs = False self.do_tracker_qemus = False elif self.options.testmaster_only: self.boxes=self.testmaster_boxes