+ def hostname_fedora (self,virt=None):
+ result = "%s {"%self.hostname
+ if virt: result += "%s-"%virt
+ result += "%s"%self.fedora()
+ # too painful to propagate this cleanly
+ global verbose
+ if verbose:
+ result += "-%s" % self.uname()
+ result += "}"
+ return result
+
+ separator = "===composite==="
+
+ # probe the ssh link
+ # take this chance to gather useful stuff
+ def probe (self):
+ # try it only once
+ if self._probed is not None: return self._probed
+ composite_command = [ ]
+ composite_command += [ "hostname" ]
+ composite_command += [ ";" , "echo", Box.separator , ";" ]
+ composite_command += [ "uptime" ]
+ composite_command += [ ";" , "echo", Box.separator , ";" ]
+ composite_command += [ "uname", "-r"]
+ composite_command += [ ";" , "echo", Box.separator , ";" ]
+ composite_command += [ "cat" , "/etc/fedora-release" ]
+
+ # due to colons and all, this is going wrong on the local box (typically testmaster)
+ # I am reluctant to change TestSsh as it might break all over the place, so
+ if self.test_ssh().is_local():
+ probe_argv = [ "bash", "-c", " ".join (composite_command) ]
+ else:
+ probe_argv=self.test_ssh().actual_argv(composite_command)
+ composite=self.backquote ( probe_argv, trash_err=True )
+ self._hostname = self._uptime = self._uname = self._fedora = "** Unknown **"
+ if not composite:
+ print "root@%s unreachable"%self.hostname
+ self._probed=''
+ else:
+ try:
+ pieces = composite.split(Box.separator)
+ pieces = [ x.strip() for x in pieces ]
+ [self._hostname, self._uptime, self._uname, self._fedora] = pieces
+ # customize
+ self._uptime = ', '.join([ x.strip() for x in self._uptime.split(',')[2:]])
+ self._fedora = self._fedora.replace("Fedora release ","f").split(" ")[0]
+ except:
+ import traceback
+ print 'BEG issue with pieces',pieces
+ traceback.print_exc()
+ print 'END issue with pieces',pieces
+ self._probed=self._hostname
+ return self._probed
+
+ # use argv=['bash','-c',"the command line"]