<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=windows-1252">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-forward-container"><br>
      <br>
      Hi Aline,<br>
        <br>
        Apologies for the truncated message.<br>
      <br>
        Please find my comments inline.<br>
      <br>
      Thanks &amp; Regards,<br>
      Megha Smriti<br>
      <br>
      <div class="moz-cite-prefix">On 11/26/2015 12:16 AM, Megha Smriti
        wrote:<br>
      </div>
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <meta http-equiv="content-type" content="text/html;
            charset=windows-1252">
          <br>
          <div class="moz-forward-container"><br>
            <br>
            -------- Forwarded Message --------
            <table class="moz-email-headers-table" border="0"
              cellpadding="0" cellspacing="0">
              <tbody>
                <tr>
                  <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:


                  </th>
                  <td>Re: [PATCH] Dbginfo report generation</td>
                </tr>
                <tr>
                  <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date:

                  </th>
                  <td>Wed, 25 Nov 2015 11:27:20 +0530</td>
                </tr>
                <tr>
                  <th align="RIGHT" nowrap="nowrap" valign="BASELINE">From:

                  </th>
                  <td>Megha Smriti <a moz-do-not-send="true"
                      class="moz-txt-link-rfc2396E"
                      href="mailto:mesmriti@linux.vnet.ibm.com">&lt;mesmriti@linux.vnet.ibm.com&gt;</a></td>
                </tr>
                <tr>
                  <th align="RIGHT" nowrap="nowrap" valign="BASELINE">To:

                  </th>
                  <td>Aline Manera <a moz-do-not-send="true"
                      class="moz-txt-link-rfc2396E"
                      href="mailto:alinefm@linux.vnet.ibm.com">&lt;alinefm@linux.vnet.ibm.com&gt;</a></td>
                </tr>
              </tbody>
            </table>
            <br>
            <br>
            <meta content="text/html; charset=windows-1252"
              http-equiv="Content-Type">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western"> <br>
              Hi Aline,<br>
              <br>
                Please find my comments inline and few suggestions.<br>
              <br>
              Thanks &amp; Regards,<br>
              Megha Smriti<br>
              <br>
              On 17/11/2015 20:05, <a moz-do-not-send="true"
                class="moz-txt-link-abbreviated"
                href="mailto:mesmriti@linux.vnet.ibm.com">mesmriti@linux.vnet.ibm.com</a>
              wrote: <br>
              <blockquote type="cite" style="color: #000000;">From: root
                <a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
                  href="mailto:root@localhost.localdomain">&lt;root@localhost.localdomain&gt;</a>
                <br>
                <br>
                Signed-off-by: root <a moz-do-not-send="true"
                  class="moz-txt-link-rfc2396E"
                  href="mailto:root@localhost.localdomain">&lt;root@localhost.localdomain&gt;</a>
                <br>
                --- <br>
                  src/wok/plugins/gingerbase/i18n.py               |   4
                +- <br>
                  src/wok/plugins/gingerbase/model/debugreports.py | 212
                ++++++++++++++++++----- <br>
                  2 files changed, 167 insertions(+), 49 deletions(-) <br>
                <br>
                diff --git a/src/wok/plugins/gingerbase/i18n.py
                b/src/wok/plugins/gingerbase/i18n.py <br>
                index af75c70..6ff783b 100644 <br>
                --- a/src/wok/plugins/gingerbase/i18n.py <br>
                +++ b/src/wok/plugins/gingerbase/i18n.py <br>
                @@ -36,7 +36,9 @@ messages = { <br>
                      "GGBDR0007E": _("Debug report name must be a
                string. Only letters, digits, underscore ('_') and " <br>
                                      "hyphen ('-') are allowed."), <br>
                      "GGBDR0008E": _("The debug report with specified
                name \"%(name)s\" already exists. Please use another
                one."), <br>
                - <br>
                +    "GGBDR0009E": _("Unable to create dbginfo report
                with %(retcode)s. Details: %(err)s"), <br>
                +    "GGBDR0010E": _("Unable to compress the final debug
                report tar file with %(retcode)s. Details: %(error)s"),
                <br>
                +    "GGBDR0011E": _("Unable to generate final debug
                report %(name)s. Details: %(err)s"), <br>
                      "GGBHOST0001E": _("Unable to shutdown host machine
                as there are running virtual machines"), <br>
                      "GGBHOST0002E": _("Unable to reboot host machine
                as there are running virtual machines"), <br>
                      "GGBHOST0003E": _("There may be virtual machines
                running on the host"), <br>
                diff --git
                a/src/wok/plugins/gingerbase/model/debugreports.py
                b/src/wok/plugins/gingerbase/model/debugreports.py <br>
                index 94ab7fe..927e173 100644 <br>
                --- a/src/wok/plugins/gingerbase/model/debugreports.py <br>
                +++ b/src/wok/plugins/gingerbase/model/debugreports.py <br>
                @@ -19,13 +19,14 @@ <br>
                  # License along with this library; if not, write to
                the Free Software <br>
                  # Foundation, Inc., 51 Franklin Street, Fifth Floor,
                Boston, MA  02110-1301 USA <br>
                <br>
                -import fnmatch <br>
                  import glob <br>
                  import logging <br>
                  import os <br>
                  import shutil <br>
                  import subprocess <br>
                  import time <br>
                +import platform <br>
                +import re <br>
                <br>
                  from wok.exception import InvalidParameter,
                NotFoundError, OperationFailed <br>
                  from wok.exception import WokException <br>
                @@ -71,54 +72,109 @@ class DebugReportsModel(object): <br>
                          raise OperationFailed("GGBDR0002E") <br>
                <br>
                      @staticmethod <br>
                -    def sosreport_generate(cb, name): <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+    def
                debugreport_generate(cb, name): <br>
                          def log_error(e): <br>
                              log = logging.getLogger('Model') <br>
                              log.warning('Exception in generating debug
                file: %s', e) <br>
              </blockquote>
              <br>
              I know it is already there prior to your patch, but we
              should use wok_log to log the errors. <br>
              This special wrapper can be removed. <br>
              <br>
                Since this code was exixting prior to my patch, I am
              planned to let it be as it is though I<br>
            </div>
          </div>
        </div>
      </blockquote>
        [Megha:]  Will use wok_log to log the errors . Please find below
      the code changes.<br>
      <br>
              
      <style type="text/css">
body { margin: 0 0 0 0; padding:0 0 0 0 }
td,div { font-family:Arial;font-size:10pt;vertical-align:top }
/* Copyright IBM Corp. 2015  All Rights Reserved.                    */
body { margin: 0 0 0 0; padding:0 0 0 0; overflow:hidden; background-color:#fafafa; }
.grayBackground { background-color:#f6f6f6; }
.transcript { background-color:#d2d2d2;}
.messageBlock {padding-left:10px; padding-right:10px;padding-top:0}
.expansion{height:10px;width:100%;overflow:hidden;}
.expansionx{height:10px;overflow:hidden;}
.line{height:1px;background-color:#cccccc;overflow:hidden;}
.message { padding-left:0px; padding-right:65px;margin-left:0px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; white-space:pre-wrap;}
.messageCont { padding-left:20px; margin-left:95px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap;}
.other { font-size:11px;color:#1970b0;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.myself { font-size:11px;color:#222222;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.otherCont { font-size:8px;text-align:right; color:#1970b0;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.myselfCont { font-size:8px;text-align:right; color:#222222;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.system { font-size:11px; word-wrap:break-word;color:#d13f08;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap; }
.showTimestamp { padding-left:20px;font-size:11px; float:right; color:#999999;font-style:normal;font-weight:normal; }
.other1 { font-size:11px; color:#ba006e;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont1 { font-size:8px;text-align:right; color:#ba006e;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other2 { font-size:11px; color:#007670;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont2 { font-size:8px;text-align:right; color:#007670;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other3 { font-size:11px; color:#3b0256;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont3 { font-size:8px;text-align:right; color:#3b0256;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other4 { font-size:11px; color:#00512b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont4 { font-size:8px;text-align:right; color:#00512b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other5 { font-size:11px; color:#a91024;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont5 { font-size:8px;text-align:right; color:#a91024;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other6 { font-size:11px; color:#b8471b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont6 { font-size:8px;text-align:right; color:#b8471b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other7 { font-size:11px; color:#7f1c7d;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont7 { font-size:8px;text-align:right; color:#7f1c7d;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.highlight { background-color:#bed6f8; }
.datestamp { padding-right:0px; font-size:11px; cursor:default;padding-top:1px;padding-bottom:1px; background-color:#a7a7a7; width:100%; float:left; text-align:right; color:#333333; font-weight:bold; font-style:italic; }
#chatAlert { float:left; border-bottom:1px solid #E8D091; padding:6px; width:100%; color:#A5754C; }
#chatAlertImage { float:left; }
#chatAlertText { float:left; margin-left:6px; margin-right:10px;}
#chatAlertClose { float:right; margin-right:10px; padding-right:6px; margin-top:0px; }
#chatAlertText a { color:#A5754C; }
#chatAlertText a:hover { color:#A5754C; text-decoration:none; }

.tsDisplay { display:block }.dsDisplay { display:block }</style>
      <table>
      </table>
      <span class="left" style="font-size: 10pt; font-family: Arial;
        color: rgb(0, 0, 0);">        def log_error(e):<br>
                     wok_log.error('Exception in generating debug file:
        %s', e) </span> 
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <div class="moz-forward-container">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western"> <br>
              <blockquote type="cite" style="color: #000000;">         
                try: <br>
                -            command = ['sosreport', '--batch',
                '--name=%s' % name] <br>
                -            output, error, retcode =
                run_command(command) <br>
                - <br>
                -            if retcode != 0: <br>
                -                raise OperationFailed("GGBDR0003E",
                {'name': name, <br>
                -                                                    
                'err': retcode}) <br>
                - <br>
                -            # SOSREPORT might create file in /tmp or
                /var/tmp <br>
                -            # FIXME: The right way should be passing
                the tar.xz file directory <br>
                -            # though the parameter '--tmp-dir', but it
                is failing in Fedora 20 <br>
                -            patterns = ['/tmp/sosreport-%s-*',
                '/var/tmp/sosreport-%s-*'] <br>
                -            reports = [] <br>
                -            reportFile = None <br>
                -            for p in patterns: <br>
                -                reports = reports + [f for f in
                glob.glob(p % name)] <br>
                -            for f in reports: <br>
                -                if not fnmatch.fnmatch(f, '*.md5'): <br>
                -                    reportFile = f <br>
                -                    break <br>
                -            # Some error in sosreport happened <br>
                -            if reportFile is None: <br>
                -                wok_log.error('Debug report file not
                found. See sosreport ' <br>
                -                              'output for detail:\n%s',
                output) <br>
                -                fname = (patterns[0] %
                name).split('/')[-1] <br>
                -                raise OperationFailed('GGBDR0004E',
                {'name': fname}) <br>
                - <br>
                -            md5_report_file = reportFile + '.md5' <br>
                -            report_file_extension = '.' +
                reportFile.split('.', 1)[1] <br>
                +            # Sosreport generation <br>
                +            sosreport_file = sosreport_collection(name)
                <br>
                +            md5_report_file = sosreport_file + '.md5' <br>
                +            report_file_extension = '.' +
                sosreport_file.split('.', 1)[1] <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+           

                # If the platform is a system Z machine. <br>
                +            if platform.machine().startswith('s390'): <br>
              </blockquote>
              <br>
              The debugreport_generate() function will be called only if
              the system has the dbginfo command <br>
              So you don't need to rely in the system arch to decide on
              that. <br>
              So the 'if' statement above can be safely removed. <br>
              <br>
            </div>
          </div>
        </div>
      </blockquote>
           [Megha:]I will take care in my next patch.<br>
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <div class="moz-forward-container">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western">  <br>
              <blockquote type="cite" style="color: #000000;">+               


                path_debugreport = '<i class="moz-txt-slash"><span
                    class="moz-txt-tag">/</span>var/tmp<span
                    class="moz-txt-tag">/</span></i>' <br>
                +                dbgreport_regex = '(\S+\s+)(' +
                path_debugreport + \ <br>
                +                                 
                'DBGINFO-[\d+]{4}-[\d+]{2}' \ <br>
                +                                 
                '-[\d+]{2}-[\d+]{2}-[\d+]{2}' \ <br>
                +                                 
                '-[\d+]{2}-\w+-\d+\S+)(\s+\S+)' <br>
                +                command = ['/usr/sbin/dbginfo.sh',
                '-d', path_debugreport] <br>
                +                output, error, retcode =
                run_command(command) <br>
                +                if retcode != 0: <br>
                +                    raise OperationFailed("GGBDR0009E",
                <br>
                +                                          {'retcode':
                retcode, 'err': error}) <br>
                +                output = output.splitlines() <br>
                +                dbginfo_report = None <br>
                +                for line in output: <br>
                +                    line = line.strip() <br>
                +                    n = re.match(dbgreport_regex, line)
                <br>
                +                    if n: <br>
                +                        dbginfo_report = n.groups()[1]
                <br>
                +                        break <br>
                +                final_tar_report_name = name +
                report_file_extension <br>
                +                if dbginfo_report is not None: <br>
                +                    sosreport_tar =
                sosreport_file.split('/', 3)[3] <br>
                +                    dbginfo_tar =
                dbginfo_report.split('/', 3)[3] <br>
                +                    msg = 'Compressing the sosreport
                and debug info files into ' \ <br>
                +                          'final report file' <br>
                +                    wok_log.info(msg) <br>
                +                    # Compressing the sosreport and
                dbginfo reports into one <br>
                +                    # tar file <br>
                +                    command = ['tar', '-cvzf', '%s' %
                final_tar_report_name, <br>
                +                               '-C', path_debugreport,
                dbginfo_tar, <br>
                +                               sosreport_tar] <br>
              </blockquote>
              <br>
              You can use final_tar_report_name with the right debug
              report location to avoid need to move the file after that.
              <br>
                <br>
                
              <style type="text/css">
body { margin: 0 0 0 0; padding:0 0 0 0 }
td,div { font-family:Arial;font-size:10pt;vertical-align:top }
/* Copyright IBM Corp. 2014  All Rights Reserved.                    */
body { margin: 0 0 0 0; padding:0 0 0 0; overflow:hidden; background-color:#fafafa; }
.grayBackground { background-color:#f6f6f6; }
.transcript { background-color:#d2d2d2;}
.messageBlock {padding-left:10px; padding-right:10px;padding-top:0}
.expansion{height:10px;width:100%;overflow:hidden;}
.expansionx{height:10px;overflow:hidden;}
.line{height:1px;background-color:#cccccc;overflow:hidden;}
.message { padding-left:0px; padding-right:65px;margin-left:0px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; white-space:pre-wrap;}
.messageCont { padding-left:20px; margin-left:95px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap;}
.other { font-size:11px;color:#1970b0;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.myself { font-size:11px;color:#222222;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.otherCont { font-size:8px;text-align:right; color:#1970b0;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.myselfCont { font-size:8px;text-align:right; color:#222222;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.system { font-size:11px; word-wrap:break-word;color:#d13f08;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap; }
.showTimestamp { padding-left:20px;font-size:11px; float:right; color:#999999;font-style:normal;font-weight:normal; }
.other1 { font-size:11px; color:#ba006e;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont1 { font-size:8px;text-align:right; color:#ba006e;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other2 { font-size:11px; color:#007670;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont2 { font-size:8px;text-align:right; color:#007670;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other3 { font-size:11px; color:#3b0256;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont3 { font-size:8px;text-align:right; color:#3b0256;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other4 { font-size:11px; color:#00512b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont4 { font-size:8px;text-align:right; color:#00512b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other5 { font-size:11px; color:#a91024;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont5 { font-size:8px;text-align:right; color:#a91024;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other6 { font-size:11px; color:#b8471b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont6 { font-size:8px;text-align:right; color:#b8471b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other7 { font-size:11px; color:#7f1c7d;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont7 { font-size:8px;text-align:right; color:#7f1c7d;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.highlight { background-color:#bed6f8; }
.datestamp { padding-right:0px; font-size:11px; cursor:default;padding-top:1px;padding-bottom:1px; background-color:#a7a7a7; width:100%; float:left; text-align:right; color:#333333; font-weight:bold; font-style:italic; }
#chatAlert { float:left; border-bottom:1px solid #E8D091; padding:6px; width:100%; color:#A5754C; }
#chatAlertImage { float:left; }
#chatAlertText { float:left; margin-left:6px; margin-right:10px;}
#chatAlertClose { float:right; margin-right:10px; padding-right:6px; margin-top:0px; }
#chatAlertText a { color:#A5754C; }
#chatAlertText a:hover { color:#A5754C; text-decoration:none; }

.tsDisplay { display:block }.dsDisplay { display:none }</style>
              <table>
              </table>
              <span class="left" style="font-size: 8pt; color: rgb(0, 0,
                0);"><span style="font-size: 10pt; font-weight: normal;
                  font-style: normal;"> Instead of the direct location
                  compressing it would be good to do in var/tmp</span></span>
              and then moving it to target directory <br>
               rather trying to do any operation on the target
              directory. In <span class="left" style="font-size: 8pt;
                color: rgb(0, 0, 0);"><span style="font-size: 10pt;
                  font-weight: normal; font-style: normal;">some cases
                  if developer</span></span>
              <style type="text/css">
body { margin: 0 0 0 0; padding:0 0 0 0 }
td,div { font-family:Arial;font-size:10pt;vertical-align:top }
/* Copyright IBM Corp. 2014  All Rights Reserved.                    */
body { margin: 0 0 0 0; padding:0 0 0 0; overflow:hidden; background-color:#fafafa; }
.grayBackground { background-color:#f6f6f6; }
.transcript { background-color:#d2d2d2;}
.messageBlock {padding-left:10px; padding-right:10px;padding-top:0}
.expansion{height:10px;width:100%;overflow:hidden;}
.expansionx{height:10px;overflow:hidden;}
.line{height:1px;background-color:#cccccc;overflow:hidden;}
.message { padding-left:0px; padding-right:65px;margin-left:0px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; white-space:pre-wrap;}
.messageCont { padding-left:20px; margin-left:95px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap;}
.other { font-size:11px;color:#1970b0;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.myself { font-size:11px;color:#222222;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; white-space:nowrap; }
.otherCont { font-size:8px;text-align:right; color:#1970b0;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.myselfCont { font-size:8px;text-align:right; color:#222222;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.system { font-size:11px; word-wrap:break-word;color:#d13f08;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre;white-space:pre-wrap; }
.showTimestamp { padding-left:20px;font-size:11px; float:right; color:#999999;font-style:normal;font-weight:normal; }
.other1 { font-size:11px; color:#ba006e;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont1 { font-size:8px;text-align:right; color:#ba006e;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other2 { font-size:11px; color:#007670;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont2 { font-size:8px;text-align:right; color:#007670;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other3 { font-size:11px; color:#3b0256;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont3 { font-size:8px;text-align:right; color:#3b0256;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other4 { font-size:11px; color:#00512b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont4 { font-size:8px;text-align:right; color:#00512b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other5 { font-size:11px; color:#a91024;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont5 { font-size:8px;text-align:right; color:#a91024;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other6 { font-size:11px; color:#b8471b;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont6 { font-size:8px;text-align:right; color:#b8471b;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.other7 { font-size:11px; color:#7f1c7d;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; }
.otherCont7 { font-size:8px;text-align:right; color:#7f1c7d;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; }
.highlight { background-color:#bed6f8; }
.datestamp { padding-right:0px; font-size:11px; cursor:default;padding-top:1px;padding-bottom:1px; background-color:#a7a7a7; width:100%; float:left; text-align:right; color:#333333; font-weight:bold; font-style:italic; }
#chatAlert { float:left; border-bottom:1px solid #E8D091; padding:6px; width:100%; color:#A5754C; }
#chatAlertImage { float:left; }
#chatAlertText { float:left; margin-left:6px; margin-right:10px;}
#chatAlertClose { float:right; margin-right:10px; padding-right:6px; margin-top:0px; }
#chatAlertText a { color:#A5754C; }
#chatAlertText a:hover { color:#A5754C; text-decoration:none; }

.tsDisplay { display:block }.dsDisplay { display:none }</style>
              <table>
              </table>
              <span class="left" style="font-size: 8pt; color: rgb(0, 0,
                0);"><span style="font-size: 10pt; font-weight: normal;
                  font-style: normal;"> makes a mistake it is possible
                  that previous reports might get deleted . Please
                  correct me if any other suggestions.</span></span></div>
          </div>
        </div>
      </blockquote>
          [Megha:]Since I did not hear anything from you , I will resume
      my code changes according to the suggestions<br>
          provided by chandra, wherein we won't be doing any operations
      in the target directory but doing it via a var/tmp directory to be<br>
         on the safer side.<br>
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <div class="moz-forward-container">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western">
              <meta http-equiv="Content-Type" content="text/html;
                charset=windows-1252">
              <meta http-equiv="Content-Type" content="text/html;
                charset=windows-1252">
              <br>
              <br>
              <blockquote type="cite" style="color: #000000;">+                   



                output, error, retcode = run_command(command) <br>
                +                    if retcode != 0: <br>
                +                        raise
                OperationFailed("GGBDR0010E", <br>
                +                                             
                {'retcode': retcode, <br>
                +                                               'error':
                error}) <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+                   



                path = config.get_debugreports_path() <br>
                +                    dbg_target = os.path.join(path, <br>
                +                                              name +
                report_file_extension) <br>
              </blockquote>
              <br>
              Use the dbg_target value while running the 'tar' command
              above. So we don't need to move the file. <br>
              <br>
                [Megha:]Will be working according to chandra's
              suggestions.<br>
              <br>
              <blockquote type="cite" style="color: #000000;">+                   



                # Moving final tar file to debugreports path <br>
                +                    msg = 'Moving final debug  report
                file "%s" to "%s"' % \ <br>
                +                          (final_tar_report_name,
                dbg_target) <br>
                +                    wok_log.info(msg) <br>
                +                    shutil.move(final_tar_report_name,
                dbg_target) <br>
              </blockquote>
              <br>
              The above block can be removed. <br>
              <br>
              <blockquote type="cite" style="color: #000000;">+                   



                # Deleting the sosreport md5 file <br>
                +                   
                delete_the_sosreport_md5_file(md5_report_file) <br>
                +                    # Deleting the dbingo report file <br>
                +                    msg = 'Deleting the dbginfo file
                "%s" ' \ <br>
                +                          % dbginfo_report <br>
                +                    wok_log.info(msg) <br>
                +                    os.remove(dbginfo_report) <br>
                +                    # Deleting the sosreport file <br>
                +                    msg = 'Deleting the sosreport file
                "%s" ' % sosreport_file <br>
                +                    wok_log.info(msg) <br>
                +                    os.remove(sosreport_file) <br>
                +                    wok_log.info('The debug report file
                has been moved') <br>
                +                    cb('OK', True) <br>
                +                    return <br>
                + <br>
                +        except WokException as e: <br>
                +            log_error(e) <br>
                +            raise <br>
                + <br>
                +        except OSError as e: <br>
                +            log_error(e) <br>
                +            raise <br>
                + <br>
                +        except Exception, e: <br>
                +            # No need to call cb to update the task
                status here. <br>
                +            # The task object will catch the exception
                raised here <br>
                +            # and update the task status there <br>
                +            log_error(e) <br>
                +            raise OperationFailed("GGBDR0011E",
                {'name': name, 'err': e}) <br>
                + <br>
                +    @staticmethod <br>
                +    def sosreport_generate(cb, name): <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+       
                def log_error(e): <br>
                +            log = logging.getLogger('Model') <br>
                +            log.warning('Exception in generating debug
                file: %s', e) <br>
              </blockquote>
              <br>
              The same I commented before. We can use wok_log to log the
              errors. <br>
              <br>
                [Megha:]I will incorporate this as I commented above.<br>
              <br>
              <blockquote type="cite" style="color: #000000;">+       
                try: <br>
                +            # Sosreport collection <br>
                +            sosreport_file = sosreport_collection(name)
                <br>
                +            md5_report_file = sosreport_file + '.md5' <br>
                +            report_file_extension = '.' +
                sosreport_file.split('.', 1)[1] <br>
                              path = config.get_debugreports_path() <br>
                -            target = os.path.join(path, name +
                report_file_extension) <br>
                -            # Moving report <br>
                -            msg = 'Moving debug report file "%s" to
                "%s"' % (reportFile, <br>
                -                                                            


                target) <br>
                +            sosreport_target = os.path.join(path, <br>
                +                                            name +
                report_file_extension) <br>
                +            msg = 'Moving debug report file "%s" to
                "%s"' \ <br>
                +                  % (sosreport_file, sosreport_target)
                <br>
                              wok_log.info(msg) <br>
                -            shutil.move(reportFile, target) <br>
                -            # Deleting md5 <br>
                -            msg = 'Deleting report md5 file: "%s"' %
                (md5_report_file) <br>
                -            wok_log.info(msg) <br>
                -            with open(md5_report_file) as f: <br>
                -                md5 = f.read().strip() <br>
                -                wok_log.info('Md5 file content: "%s"',
                md5) <br>
                -            os.remove(md5_report_file) <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+           

                shutil.move(sosreport_file, sosreport_target) <br>
              </blockquote>
              <br>
              As we are using --tmp-dir option, we know exactly where
              the sosreport will be saved. So we don't need to move the
              file around. <br>
            </div>
          </div>
        </div>
      </blockquote>
      <br>
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <div class="moz-forward-container">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western">   When the sosreport
              is generated md5 file is generated along with the
              sosreport. That is why we generate the sosreport <br>
                  in a var/tmp dir and remove the md5 file and then move
              the final file to the target location to avoid doing all
              the operations <br>
                 on the target directory.<br>
            </div>
          </div>
        </div>
      </blockquote>
                [Megha:] Same as I commented above . I will be working
      according to chandra's suggestions.<br>
      <blockquote cite="mid:565601FC.4080609@linux.vnet.ibm.com"
        type="cite">
        <div class="moz-text-html" lang="x-western">
          <div class="moz-forward-container">
            <div class="moz-text-flowed" style="font-family: -moz-fixed;
              font-size: 14px;" lang="x-western"> <br>
              <blockquote type="cite" style="color: #000000;">+           

                delete_the_sosreport_md5_file(md5_report_file) <br>
                              cb('OK', True) <br>
                              return <br>
                <br>
                @@ -142,17 +198,27 @@ class DebugReportsModel(object): <br>
                          # Please add new possible debug report command
                here <br>
                          # and implement the report generating function
                <br>
                          # based on the new report command <br>
                -        report_tools = ({'cmd': 'sosreport --help', <br>
                +        report_tools = ({'cmd': '/usr/sbin/dbginfo.sh
                --help', <br>
                +                         'fn':
                DebugReportsModel.debugreport_generate}, <br>
                +                        {'cmd': 'sosreport --help', <br>
                                           'fn':
                DebugReportsModel.sosreport_generate},) <br>
                <br>
                          # check if the command can be found by shell
                one by one <br>
                          for helper_tool in report_tools: <br>
                              try: <br>
                -                retcode =
                subprocess.call(helper_tool['cmd'], shell=True, <br>
                -                                         
                stdout=subprocess.PIPE, <br>
                -                                         
                stderr=subprocess.PIPE) <br>
                -                if retcode == 0: <br>
                -                    return helper_tool['fn'] <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+               


                if 'cmd' == '/usr/sbin/dbginfo.sh --help': <br>
                +                    retcode =
                subprocess.call(helper_tool['cmd'], shell=True, <br>
                +                                             
                stdout=subprocess.PIPE, <br>
                +                                             
                stderr=subprocess.PIPE) <br>
                +                    if retcode == 0: <br>
                +                        return helper_tool['fn'] <br>
              </blockquote>
              <br>
              You don't need to a special condition to cover the dbginfo
              command. The former code already does that. <br>
              <br>
                [Megha:]  I ll make the changes.<br>
              <blockquote type="cite" style="color: #000000;">+               


                else: <br>
                + <br>
                +                    retcode =
                subprocess.call(helper_tool['cmd'], shell=True, <br>
                +                                             
                stdout=subprocess.PIPE, <br>
                +                                             
                stderr=subprocess.PIPE) <br>
                +                    if retcode == 0: <br>
                +                        return helper_tool['fn'] <br>
                              except Exception, e: <br>
                                  wok_log.info('Exception running
                command: %s', e) <br>
                <br>
                @@ -213,3 +279,53 @@ class
                DebugReportContentModel(object): <br>
                <br>
                      def lookup(self, name): <br>
                          return self._debugreport.lookup(name) <br>
                + <br>
                + <br>
                +def delete_the_sosreport_md5_file(md5_file): <br>
                +    """ <br>
                +    Deleting md5 file and displaying the contents of
                the same. <br>
                +    """ <br>
                +    msg = 'Deleting report md5 file: "%s"' % md5_file <br>
                +    wok_log.info(msg) <br>
                +    with open(md5_file) as f: <br>
                +        md5 = f.read().strip() <br>
                +        wok_log.info('Md5 file content: "%s"', md5) <br>
                +    os.remove(md5_file) <br>
                + <br>
                + <br>
                +def sosreport_collection(name): <br>
                +    """ <br>
                +    Code for the collection of sosreport n the path <br>
                +    /var/tmp as specified in the command. <br>
                +    """ <br>
                +    path_sosreport = '<i class="moz-txt-slash"><span
                    class="moz-txt-tag">/</span>var/tmp<span
                    class="moz-txt-tag">/</span></i>' <br>
                +    command = ['sosreport', '--batch', '--name=%s' %
                name, <br>
                +               '--tmp-dir=%s' % path_sosreport] <br>
                +    output, error, retcode = run_command(command) <br>
                +    if retcode != 0: <br>
                +        raise OperationFailed("GGBDR0003E", {'name':
                name, <br>
                +                                             'err':
                retcode}) <br>
                + <br>
              </blockquote>
              <br>
              <blockquote type="cite" style="color: #000000;">+    #
                SOSREPORT might create file in /tmp or /var/tmp <br>
                +    # FIXME: The right way should be passing the tar.xz
                file directory <br>
                +    # though the parameter '--tmp-dir', but it is
                failing in Fedora 20 <br>
              </blockquote>
              <br>
              You can remove this comment. <br>
                [Megha:] I will do it in the next patch<br>
              <blockquote type="cite" style="color: #000000;">+   
                sosreport_name = name.replace('_', '') <br>
              </blockquote>
              <br>
              The same I commented before. We should not change the user
              input without informing user about it. <br>
              So it is better to block underscore in the debug report
              name. Please, update API.json accordingly. <br>
              <br>
                [Megha:]  I ll make the required changes.<br>
              <blockquote type="cite" style="color: #000000;">+   
                sosreport_name_regex = '(\s+)(' + path_sosreport + \ <br>
                +                           ')(sosreport-' +\ <br>
                +                           sosreport_name +
                '-\d+.tar.xz)' <br>
                +    sosreport_file = None <br>
                +    output = output.splitlines() <br>
                +    for line in output: <br>
                +        if line: <br>
                +            matched_name =
                re.match(sosreport_name_regex, line) <br>
                +            if matched_name: <br>
                +                path = matched_name.groups()[1] <br>
                +                fname = matched_name.groups()[2] <br>
                +                sosreport_file = path + fname <br>
              </blockquote>
              <br>
              While using --tmp-dir you know exactly where the sosreport
              file will be:
              &lt;tmp-dir&gt;-sosreport-&lt;name&gt;.tar.gz <br>
              So you can need to parse the command output. <br>
                [Megha:]I will take care of this in the next patch.<br>
              <blockquote type="cite" style="color: #000000;">+               


                break <br>
                +    # Some error in sosreport happened <br>
                +    if sosreport_file is None: <br>
                +        wok_log.error('Debug report file not found. See
                sosreport ' <br>
                +                      'output for detail:\n%s', output)
                <br>
                +        raise OperationFailed('GGBDR0004E', {'name':
                name}) <br>
                +    return sosreport_file <br>
              </blockquote>
              <br>
            </div>
            <br>
          </div>
          <br>
        </div>
      </blockquote>
      <br>
      <br>
    </div>
    <br>
  </body>
</html>