+ # 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()