UCSD get UCSM Firmware Report

Version 2
    Task NameUCSM Firmware Report
    DescriptionUCSM Firmware Report
    Prerequisites
    1. Tested on 5.2.0.2
    CategoryWorkflow tasks
    ComponentsUCSM Firmware Report
    1. Log in to UCS Director as a user that has "system-admin" privileges.
    2. Navigate to "Policies-->Orchestration" and click on "Import".
    3. Click "Browse" and navigate to the location on your computer where the .wfdx file resides. Choose the .wfdx file and click "Open".
    4. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
    5. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
    6. Click "Submit".
    7. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow.

     

     

    Workflow execution select the UCSM account/POD:

     

    Screen Shot 2015-04-18 at 7.26.04 AM.png

     

    Workflow execution enter the destination e-mail address:


    Screen Shot 2015-04-18 at 7.26.15 AM.png


    Watch the workflow execute:


    Screen Shot 2015-04-18 at 7.26.40 AM.png


    The log file:


    Screen Shot 2015-04-18 at 7.26.52 AM.png


    The resulting e-mail with the Firmware Report:


    Screen Shot 2015-04-18 at 7.27.01 AM.png


    The workflow can now be scheduled as well:


    Screen Shot 2015-04-18 at 7.29.11 AM.png


    The fields to fill out for the schedule:


    Screen Shot 2015-04-18 at 7.30.05 AM.png


    The Workflow:


    Screen Shot 2015-04-18 at 7.35.21 AM.png


    The code:


    importPackage(java.util);

    importPackage(java.lang);

    importPackage(java.io);

    importPackage(com.cloupia.model.cEvent.notify);

    importPackage(com.cloupia.model.cIM);

    importPackage(com.cloupia.lib.util.mail);

    importPackage(com.cloupia.fw.objstore);

    importPackage(com.cloupia.lib.util.managedreports);

     

     

     

     

    function getMailSettings()

    {

          return ObjStoreHelper.getStore((new MailSettings()).getClass()).getSingleton();

    }

     

     

     

     

     

     

    function getReport(reportContext, reportName)

    {

         var report = null;

          try

          {

                 report = ctxt.getAPI().getConfigTableReport(reportContext, reportName);

          } catch(e)

          {

          }

     

          if (report == null)

          {

                 return ctxt.getAPI().getTabularReport(reportName, reportContext);

          } else

         {

               var source = report.getSourceReport();

               return ctxt.getAPI().getTabularReport(source, reportContext);

         }

    }

     

    function getReportView(reportContext, reportName)

    {

          var report = getReport(reportContext, reportName);

     

         if (report == null)

         {

               logger.addError("No such report exists for the specified context "+reportName);

     

               return null;

         }

     

         return new TableView(report);

    }

     

     

     

     

    var ucsmAccountName = ctxt.getInput("UCS_Account_Name");

    var reportName = "INFRA_COMPUTING_INSTALLED_FIRMWARE_REPORT";

     

     

     

     

    var repContext = util.createContext("ucsm", null, ucsmAccountName);

    var report = getReportView(repContext, reportName);

     

     

     

    var toEmail = [ ctxt.getInput("Email Address") ];

    var message = new EmailMessageRequest();

    message.setToAddrs(toEmail);

    message.setSubject("UCSM Firmware Report : "+ ucsmAccountName);

    message.setFromAddress("no-reply@cisco.com");

    var buffer = new StringWriter();

    var printer = new PrintWriter(buffer);

    var formatter = new com.cloupia.lib.util.managedreports.Formatter(new File("."), printer);

    formatter.printTable(report);

    printer.close();

     

    var body = "<head><style type='text/css'>";

    body = body + "table { font-family: Verdana, Geneva, sans-serif; font-size: 12px; border: thin solid #039; border-spacing: 0; background: #ffffff; } ";

    body = body + " th { background-color: #6699FF; color: white; font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-weight: bold; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; } ";

    body = body + " td { font-family: Verdana, Geneva, sans-serif; font-size: 10px; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; background: #ffffff; }";

    body = body + "</style></head>";

    body = body+ "<body><h1>Firmware Report</h1><br>" + buffer.toString();

           

    message.setMessageBody(body);

    logger.addInfo("Sending email");

    MailManager.sendEmail("Frimware Report", getMailSettings(), message);