Fixed the hpm upgstatus command to print the results of the command
without having to specify -v to enable verbose operation.

It's not clear that this command is even useful to the user at all.
Perhaps it should be removed entirely.

Signed-off-by: Dan Gora <d...@adax.com>
---
 ipmitool/lib/ipmi_hpmfwupg.c |  103 +++++++++++++++++++----------------------
 1 files changed, 48 insertions(+), 55 deletions(-)

diff --git a/ipmitool/lib/ipmi_hpmfwupg.c b/ipmitool/lib/ipmi_hpmfwupg.c
index 9a2711f..0ccde76 100644
--- a/ipmitool/lib/ipmi_hpmfwupg.c
+++ b/ipmitool/lib/ipmi_hpmfwupg.c
@@ -1067,9 +1067,7 @@ static int HpmfwupgFinishFirmwareUpload(struct ipmi_intf 
*intf,
 static int HpmfwupgActivateFirmware(struct ipmi_intf *intf,
                                     struct HpmfwupgActivateFirmwareCtx* pCtx,
                                     struct HpmfwupgUpgradeCtx* pFwupgCtx);
-static int HpmfwupgGetUpgradeStatus(struct ipmi_intf *intf,
-                                    struct HpmfwupgGetUpgradeStatusCtx* 
pCtxstruct,
-                                    struct HpmfwupgUpgradeCtx* pFwupgCtx);
+static int HpmfwupgGetUpgradeStatus(struct ipmi_intf *intf, struct 
HpmfwupgGetUpgradeStatusCtx* pCtxstruct, struct HpmfwupgUpgradeCtx* pFwupgCtx, 
int silent);
 static int HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf,
                                           struct 
HpmfwupgManualFirmwareRollbackCtx* pCtx,
                                           struct HpmfwupgUpgradeCtx* 
pFwupgCtx);
@@ -3149,68 +3147,63 @@ int HpmfwupgActivateFirmware(struct ipmi_intf *intf, 
struct HpmfwupgActivateFirm
    return rc;
 }
 
-int HpmfwupgGetUpgradeStatus(struct ipmi_intf *intf, struct 
HpmfwupgGetUpgradeStatusCtx* pCtx,
-                             struct HpmfwupgUpgradeCtx* pFwupgCtx)
+int HpmfwupgGetUpgradeStatus(struct ipmi_intf *intf, 
+                            struct HpmfwupgGetUpgradeStatusCtx *pCtx,
+                             struct HpmfwupgUpgradeCtx *pFwupgCtx,
+                            int silent)
 {
-   int    rc = HPMFWUPG_SUCCESS;
-   struct ipmi_rs * rsp;
-   struct ipmi_rq   req;
+       int    rc = HPMFWUPG_SUCCESS;
+       struct ipmi_rs * rsp;
+       struct ipmi_rq   req;
 
-   pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
+       pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;
 
-   memset(&req, 0, sizeof(req));
-   req.msg.netfn    = IPMI_NETFN_PICMG;
+       memset(&req, 0, sizeof(req));
+       req.msg.netfn    = IPMI_NETFN_PICMG;
        req.msg.cmd      = HPMFWUPG_GET_UPGRADE_STATUS;
        req.msg.data     = (unsigned char*)&pCtx->req;
        req.msg.data_len = sizeof(struct HpmfwupgGetUpgradeStatusReq);
 
-   rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
-
-   if ( rsp )
-   {
-      if ( rsp->ccode == 0x00 )
-      {
-         memcpy(&pCtx->resp, rsp->data, sizeof(struct 
HpmfwupgGetUpgradeStatusResp));
-         if ( verbose > 1 )
-         {
-            lprintf(LOG_NOTICE,"Upgrade status:");
-            lprintf(LOG_NOTICE," Command in progress:          %x", 
pCtx->resp.cmdInProcess);
-            lprintf(LOG_NOTICE," Last command completion code: %x", 
pCtx->resp.lastCmdCompCode);
-         }
-      }
-      /*
-       * PATCH --> This validation is to handle retryables errors codes on 
IPMB bus.
-       *           This will be fixed in the next release of open ipmi and this
-       *           check will have to be removed. (Buggy version = 39)
-       */
-      else if ( HPMFWUPG_IS_RETRYABLE(rsp->ccode) )
-      {
-         lprintf(LOG_DEBUG,"HPM: [PATCH]Retryable error detected");
+       rsp = HpmfwupgSendCmd(intf, req, pFwupgCtx);
+       if (!rsp){
+               lprintf(LOG_NOTICE,
+               "Error getting upgrade status. Failed to get response.");
+               return HPMFWUPG_ERROR;
+       }
 
-         pCtx->resp.lastCmdCompCode = HPMFWUPG_COMMAND_IN_PROGRESS;
-      }
-      else
-      {
-         if ( verbose )
-         {
+       if ( rsp->ccode == 0x00 ) {
+               memcpy(&pCtx->resp, rsp->data, 
+                       sizeof(struct HpmfwupgGetUpgradeStatusResp));
+               if (!silent)
+                       {
+                       lprintf(LOG_NOTICE,"Upgrade status:");
+                       lprintf(LOG_NOTICE," Command in progress:          %x", 
+                               pCtx->resp.cmdInProcess);
+                       lprintf(LOG_NOTICE," Last command completion code: %x", 
+                               pCtx->resp.lastCmdCompCode);
+                       }
+       } else if ( HPMFWUPG_IS_RETRYABLE(rsp->ccode) ) {
+               /*
+                * PATCH --> This validation is to handle retryable errors 
+                *           codes on the IPMB bus.
+                *           This will be fixed in the next release of 
+                *           open ipmi and this check can be removed. 
+                *           (Buggy version = 39)
+                */
+               if (!silent)
+                       {
+                       lprintf(LOG_DEBUG,"HPM: Retryable error detected");
+                       }
+               pCtx->resp.lastCmdCompCode = HPMFWUPG_COMMAND_IN_PROGRESS;
+       } else {
                lprintf(LOG_NOTICE,"Error getting upgrade status");
                lprintf(LOG_NOTICE,"compcode=0x%x: %s",  
                        rsp->ccode,
                        val2str(rsp->ccode, completion_code_vals));
-               rc = HPMFWUPG_ERROR;
-         }
-      }
-   }
-   else
-   {
-      if ( verbose )
-      {
-         lprintf(LOG_NOTICE,"Error getting upgrade status");
-         rc = HPMFWUPG_ERROR;
-      }
-   }
+               return HPMFWUPG_ERROR;
+       }
 
-   return rc;
+       return HPMFWUPG_SUCCESS;
 }
 
 int HpmfwupgManualFirmwareRollback(struct ipmi_intf *intf, struct 
HpmfwupgManualFirmwareRollbackCtx* pCtx,
@@ -3693,7 +3686,7 @@ int HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf, 
struct HpmfwupgUpgradeCt
       /* Poll upgrade status until completion or timeout*/
       timeoutSec1 = time(NULL);
       timeoutSec2 = time(NULL);
-      rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx);
+      rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx, 1);
    }
 
    while(
@@ -3706,7 +3699,7 @@ int HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf, 
struct HpmfwupgUpgradeCt
       /* Must wait at least 1000 ms between status requests */
       usleep(1000000);
       timeoutSec2 = time(NULL);
-      rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx);
+      rc = HpmfwupgGetUpgradeStatus(intf, &upgStatusCmd, pFwupgCtx, 1);
       //printf("Get Status: %x - %x = %x _ %x [%x]\n", timeoutSec2, 
timeoutSec1,(timeoutSec2 - timeoutSec1),upgradeTimeout, rc);
    }
 
@@ -3921,7 +3914,7 @@ int ipmi_hpmfwupg_main(struct ipmi_intf * intf, int argc, 
char ** argv)
    {
       struct HpmfwupgGetUpgradeStatusCtx cmdCtx;
       verbose++;
-      rc = HpmfwupgGetUpgradeStatus(intf, &cmdCtx, NULL);
+      rc = HpmfwupgGetUpgradeStatus(intf, &cmdCtx, NULL, 0);
    }
    else if ( (argc == 1) && (strcmp(argv[0], "rollback") == 0) )
    {
-- 
1.7.7


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to