docs: def getConsole(rh):
      """
      Get the virtual machine's console output.
  
      Input:
         Request Handle with the following properties:
            function    - 'CMDVM'
            subfunction - 'CMD'
            userid      - userid of the virtual machine
  
      Output:
         Request Handle updated with the results.
         Return code - 0: ok, non-zero: error
      """
  
      rh.printSysLog("Enter getVM.getConsole")
  
      # Transfer the console to this virtual machine.
      parms = ["-T", rh.userid]
      results = invokeSMCLI(rh, "Image_Console_Get", parms)
  
      if results['overallRC'] != 0:
          if (results['overallRC'] == 8 and results['rc'] == 8 and
              results['rs'] == 8):
              # Give a more specific message.  Userid is either
              # not logged on or not spooling their console.
              msg = msgs.msg['0409'][1] % (modId, rh.userid)
          else:
              msg = results['response']
          rh.updateResults(results)    # Use results from invokeSMCLI
          rh.printLn("ES", msg)
          rh.printSysLog("Exit getVM.parseCmdLine, rc: " +
                         str(rh.results['overallRC']))
          return rh.results['overallRC']
  
      # Check whether the reader is online
      with open('/sys/bus/ccw/drivers/vmur/0.0.000c/online', 'r') as myfile:
          out = myfile.read().replace('\n', '')
          myfile.close()
  
      # Nope, offline, error out and exit
      if int(out) != 1:
          msg = msgs.msg['0411'][1]
          rh.printLn("ES", msg)
          rh.updateResults(msgs.msg['0411'][0])
          rh.printSysLog("Exit getVM.parseCmdLine, rc: " +
                         str(rh.results['overallRC']))
          return rh.results['overallRC']
  
      # We should set class to *, otherwise we will get errors like:
      # vmur: Reader device class does not match spool file class
      cmd = ["sudo", "/sbin/vmcp", "spool reader class *"]
      strCmd = ' '.join(cmd)
      rh.printSysLog("Invoking: " + strCmd)
      try:
          subprocess.check_output(
              cmd,
              close_fds=True,
              stderr=subprocess.STDOUT)
      except subprocess.CalledProcessError as e:
          # If we couldn't change the class, that's not fatal
          # But we want to warn about possibly incomplete
          # results
          msg = msgs.msg['0407'][1] % (modId, strCmd, e.output)
          rh.printLn("WS", msg)
      except Exception as e:
          # All other exceptions.
          # If we couldn't change the class, that's not fatal
          # But we want to warn about possibly incomplete
          # results
          rh.printLn("ES", msgs.msg['0422'][1] % (modId, strCmd,
              type(e).__name__, str(e)))
          rh.printLn("ES", msgs.msg['0423'][1] % modId, strCmd,
              type(e).__name__, str(e))
  
      # List the spool files in the reader
      cmd = ["sudo", "/usr/sbin/vmur", "list"]
      strCmd = ' '.join(cmd)
      rh.printSysLog("Invoking: " + strCmd)
      try:
          files = subprocess.check_output(
              cmd,
              close_fds=True,
              stderr=subprocess.STDOUT)
      except subprocess.CalledProcessError as e:
          # Uh oh, vmur list command failed for some reason
          msg = msgs.msg['0408'][1] % (modId, rh.userid,
                                       strCmd, e.output)
          rh.printLn("ES", msg)
          rh.updateResults(msgs.msg['0408'][0])
          rh.printSysLog("Exit getVM.parseCmdLine, rc: " +
                         str(rh.results['overallRC']))
          return rh.results['overallRC']
      except Exception as e:
          # All other exceptions.
          rh.printLn("ES", msgs.msg['0421'][1] % (modId, strCmd,
              type(e).__name__, str(e)))
          rh.updateResults(msgs.msg['0421'][0])
          rh.printSysLog("Exit getVM.parseCmdLine, rc: " +
                         str(rh.results['overallRC']))
          return rh.results['overallRC']
  
      # Now for each line that contains our user and is a
      # class T console file, add the spool id to our list
      spoolFiles = files.split('\n')
      outstr = ""
      for myfile in spoolFiles:
          if (myfile != "" and
                  myfile.split()[0] == rh.userid and
                  myfile.split()[2] == "T" and
                  myfile.split()[3] == "CON"):
  
              fileId = myfile.split()[1]
              outstr += fileId + " "
  
      # No files in our list
      if outstr == "":
          msg = msgs.msg['0410'][1] % (modId, rh.userid)
          rh.printLn("ES", msg)
          rh.updateResults(msgs.msg['0410'][0])
          rh.printSysLog("Exit getVM.parseCmdLine, rc: " +
                         str(rh.results['overallRC']))
          return rh.results['overallRC']
  
      # Output the list
      rh.printLn("N", "List of spool files containing "
                 "console logs from %s: %s" % (rh.userid, outstr))
  
      rh.results['overallRC'] = 0
      rh.printSysLog("Exit getVM.getConsole, rc: " +
                     str(rh.results['overallRC']))
      return rh.results['overallRC']