+ def hostname_fedora (self, virt=None):
+ # this truly is an opening bracket
+ result = "{}".format(self.hostname) + " {"
+ if virt:
+ result += "{}-".format(virt)
+ result += "{} {}".format(self.fedora(), self.memory())
+ # too painful to propagate this cleanly
+ global verbose
+ if verbose:
+ result += "-{}".format(self.uname())
+ # and the matching closing bracket
+ 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" ]
+ composite_command += [ ";" , "echo", Box.separator , ";" ]
+ composite_command += [ "grep", "MemTotal", "/proc/meminfo" ]
+
+ # 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 = self._memory = "** Unknown **"
+ if not composite:
+ print("root@{} unreachable".format(self.hostname))
+ self._probed = ''
+ else:
+ try:
+ pieces = composite.split(Box.separator)
+ pieces = [ x.strip() for x in pieces ]
+ # get raw data
+ [hostname, uptime, uname, fedora, memory] = pieces
+ # customize
+ self._hostname = hostname
+ self._uptime = ', '.join([ x.strip() for x in uptime.split(',')[2:]]).replace("load average", "load")
+ self._uname = uname
+ self._fedora = fedora.replace("Fedora release ","f").split(" ")[0]
+ # translate into Mb
+ self._memory = int(memory.split()[1])/(1024)
+ except Exception as e:
+ import traceback
+ print('BEG issue with pieces')
+ traceback.print_exc()
+ self._probed = self._hostname
+ return self._probed
+
+ # use argv=['bash','-c',"the command line"]