Parse QCommand errorCode

Last post 02-12-2020, 3:55 AM by stefan.vollrath. 4 replies.
Sort Posts: Previous Next
  • Parse QCommand errorCode
    Posted: 02-06-2020, 2:15 AM

    Hi All

    I'm working on automating integrating new Clients and instances and use Qcommand Execute to send the xml Requests to Commserve.

    Now I found out that the exitCode of this Activity comes back with success / 0 even if the REquest did nothing or did fail with an Error or Warning. 

    That fact would only be stated in the xml Response <errorCode> Element.

    <App_UpdateInstancePropertiesResponse>

       <response>

          <entity>

             <instanceName>ZFSTI0</instanceName>

          </entity>

          <errorString>Failed to create SQL Instance [ZFSTI0]. SQL services may be offline or User authentication failed.</errorString>

          <errorCode>1</errorCode>

          <warningCode>0</warningCode>

       </response>

    </App_UpdateInstancePropertiesResponse>

    Any recommendations on how to parse and check that Info the easy way? Could put a XPathQuery-Activity after each Execute-Block and check the output of that in a Transition or Desicion-Block, but that would double the Workflow size unnecessarily. 

    Thinking of using OnComplete Script to extract and check the error/warningCode and maybe overrule the exitCode of the Activity, but not sure if that is the best way to go.

     

    Thanks in advance

    Stefan

  • Re: Parse QCommand errorCode
    Posted: 02-06-2020, 6:07 AM

    Whilst there may indeed be a better way, from memory I have done just as you have proposed.

  • Re: Parse QCommand errorCode
    Posted: 02-06-2020, 9:44 AM

    It all really depends on what your wanting to do in case the response contains an error.

    if you just wanting the workflow activity to go pending or cause the workflow to completely fail out then an onComplete script like such would do that

    XML xml = utils.parseXml(activity.outputXml);
    if (!xml.getText("//errorCode").equals("0")) {
    throw new Exception(xml.getText("//errorString"));
    }

    If you wanting to handle the error with transitioning to some other activities but do not want the bloat which comes with XPath+Decision activities, then you can use a script like above inside a transitional condition script

    xml.getText("//errorCode").equals("0") ==> Success Transition
    !xml.getText("//errorCode").equals("0") ==> Failure Transition

    I am also checking with another engineer about being able to configure the App_UpdateInstancePropertiesResponse response message to fail the qoperation.exe command which would eliminate having to do any coding in the workflow to cause this activity to fail when this response is recieved containing a non-zero error code.

    Regards

  • Re: Parse QCommand errorCode
    Posted: 02-06-2020, 11:23 AM

    Basic intention is to know if a Activity didn't complete successfully and have something to act upon.

    As is in the sample. UpdateInstanceProperties is "completed successfully" but did nothing whatsoever. Actually worried that many other xml Activities silently fail as well and all our Automation leaves inconsistent setup. At this point this would mean checking and validating 30+ Workflows.

    Shame those Shortcuts like activity.outputXml and utils.parseXml are not on BOL, similar to csdb.execute() and co, could be so much easier if one knew what is possible :-)

    Wrote something lenthy and ugly in meantime. no exeption handling, no clue how that works here. Think its ovious that I'm a Java-Noob :-)

    XPathFactory xpathFactory = XPathFactory.newInstance();
    XPath xpath = xpathFactory.newXPath();

    int errorCode = xpath.evaluate("//response/errorCode", document, XPathConstants.NUMBER).intValue();
    int warningCode = xpath.evaluate("//response/warningCode", document, XPathConstants.NUMBER).intValue();
    String errorString = xpath.evaluate("//response/errorString", document, XPathConstants.STRING);

    if(errorCode > 0 || warningCode > 0)
    {
    workflow.setVariable("errorCode", errorCode);
    workflow.setVariable("warningCode", warningCode);
    workflow.setVariable("errorString", errorString);
    activity.exitCode=999;
    }
    else
    {
    activity.exitCode=0;
    }

    Still stuck with figuring out how to best manage Error/Warning Codes and Strings for a final OnWorkflowComplete Checkup, f.E. how to append ErrorrStrings into a List-Type variable or if to better fail the Workflow on the first Error anyways and just send that Info out via Mail.

  • Re: Parse QCommand errorCode
    Posted: 02-12-2020, 3:55 AM

    Tried your suggestion and makes my life way easier. Thanks a lot so far!

    Found throwing the Exception that way bit harsh though and found the Workflow Actionworkflow.setFailed(xml.getText("//errorString"));

    Less hard but still kills the Workflow without setting a normal Completion Status and sending that as API Response. Is there maybe a Script-Control that works similar to the WorkflowEnd Activity, or in general some kind of documentation what methods are in Class commvault.cte.workflow and what parameters they use?

The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
Close
Copyright © 2020 Commvault | All Rights Reserved. | Legal | Privacy Policy