cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1952
Views
0
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task NameVM Deployment with USER IP input
Description
  1. Snapshot Report with summation
Prerequisites
  1. Tested on 5.2.0.0.A
CategoryWorkflow
ComponentsvSphere 5.x
User Inputs

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

The Request

===========

1) Create a snapshot report that can add up the snapshot sizes and produce a total for the vCenter

2) Can run on a schedule

3) Input the destination e-mail address

4) Input the Cloud/vCenter destination

The Workflow

===========

Screen Shot 2015-02-21 at 6.27.53 AM.png

Execution of Workflow

=================

Screen Shot 2015-02-21 at 6.32.20 AM.png

The Run Result

=============

Screen Shot 2015-02-21 at 6.45.17 AM.png

Workflow Input

============

Screen Shot 2015-02-21 at 6.31.34 AM.png

Scheduling of the Workflow

=====================

Right click on the workflow and select schedule:

Screen Shot 2015-02-21 at 6.32.43 AM.png

Select scheduling frequency:

Screen Shot 2015-02-21 at 6.33.14 AM.png

Select scheduling TAB and check result:

Screen Shot 2015-02-21 at 6.33.28 AM.png

The second attachment has the Multi Cloud Option

It Cycles through all the vCenter Accounts

=======================================

Screen Shot 2015-02-22 at 6.39.28 AM.png

Loop #1

======

Screen Shot 2015-02-22 at 6.39.51 AM.png

Loop #2

======

Screen Shot 2015-02-22 at 6.40.16 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);

}

// Assume the To Email Addres is in the input variable 'Email Address'

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

var CloudSelector1 = [ ctxt.getInput("CloudSelector") ];

var message = new EmailMessageRequest();

message.setToAddrs(toEmail);

message.setSubject("Snapshot Size Report");

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

var buffer = new StringWriter();

var printer = new PrintWriter(buffer);

// Formatter exists in multiple packages, so it needs fully qualified name

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

//

// Report Name from Meta button

//

var reportName  = "StorageFeature.vmware.snapshot.summary.list";

//

// Context

// Can be obtained from Administration -> User Interface Settings -> Reports Customization

//

//var repContext  = util.createContext("global", null, null);

var repContext  = util.createContext("cloud", CloudSelector1, null);

var report = getReportView(repContext, reportName);

var a = 0;

var b = 0;

// Filter Active State VMs

// report = report.filterRowsByColumn("CPU Sockets", "Unlocked", false);

var sum = 0;

for (var i=0; i<report.rowCount(); i++) {

  var cnt = report.getColumnValue(i, "Snapshot Size (KB)");

  logger.addInfo("Raw Number from Report = "+cnt);

  if (cnt == null) {

    logger.addInfo("Cant add null");

  } else {

    b = Number(cnt);

    logger.addInfo("Convert String (1.4e7) to Number = "+b);

    a = parseInt(b, 10);

    logger.addInfo("Real to Integer = "+a);

    sum = sum + a;

    //sum = sum + Integer.valueOf(cnt);

    logger.addInfo("SUM ="+sum);

  }

}

var MBsum = parseInt(sum/1024 , 10);

var GBsum = parseInt(MBsum/1024, 10);

var TBsum = parseInt(GBsum/1024, 10);

var PBsum = parseInt(TBsum/1024, 10);

logger.addInfo("MB SUM ="+MBsum);

logger.addInfo("GB SUM ="+GBsum);

logger.addInfo("TB SUM ="+TBsum);

logger.addInfo("PB SUM ="+PBsum);

formatter.printTable(report);

printer.close();

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

// Specify CSS for the report

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>Snapshot Size Report</h1><br>" + buffer.toString();

body = body+"<br>Snapshot sum:<br>";

body = body+"<br>------------------------------------------------<br>";

body = body + sum.toString() + " KB ";

body = body+"<br>------------------------------------------------<br>";

body = body + MBsum.toString() + " MB ";

body = body+"<br>------------------------------------------------<br>";

body = body + GBsum.toString() + " GB ";

body = body+"<br>------------------------------------------------<br>";

body = body + PBsum.toString() + " PB ";

body = body+"<br>------------------------------------------------<br>";

message.setMessageBody(body);

logger.addInfo("Sending email");

// Now, send the report via email. First parameter is just a label used in the

// internal logs

MailManager.sendEmail("Snapshot Size Report", getMailSettings(), message);

Execution of Workflow

=================

Screen Shot 2015-02-21 at 6.22.38 AM.png

Log File Run

==========

Service Request ID: 4379

Workflow Inputs:

- Email Address

- CloudSelector

Feb 21, 2015 06:15:50 CST Request submitted

Feb 21, 2015 06:15:53 CST Executing workflow item number 1

Feb 21, 2015 06:15:53 CST Completed workflow item number 1, with status Completed

Feb 21, 2015 06:15:56 CST Executing workflow item number 2

Feb 21, 2015 06:15:56 CST Trigger context executeWorkFlowStep called

Feb 21, 2015 06:15:56 CST Executing custom action Report_Snap_shot_with_Counter (ExecuteCloupiaScript)

Feb 21, 2015 06:15:56 CST Executing custom action Report_Snap_shot_with_Counter (ExecuteCloupiaScript)

Feb 21, 2015 06:15:59 CST Executing cloupia script: ReportsSnapShotSizeReport

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =0

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =0

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =0

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =0

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =0

Feb 21, 2015 06:15:59 CST Raw Number from Report = 2.7641546700195312E7

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 27641546.700195312

Feb 21, 2015 06:15:59 CST Real to Integer = 27641546

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =27641546

Feb 21, 2015 06:15:59 CST Raw Number from Report = 1.4321122E7

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 14321122

Feb 21, 2015 06:15:59 CST Real to Integer = 14321122

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST Raw Number from Report = 0.0

Feb 21, 2015 06:15:59 CST Convert String (1.4e7) to Number = 0

Feb 21, 2015 06:15:59 CST Real to Integer = 0

Feb 21, 2015 06:15:59 CST SUM =41962668

Feb 21, 2015 06:15:59 CST MB SUM =40979

Feb 21, 2015 06:15:59 CST GB SUM =40

Feb 21, 2015 06:15:59 CST TB SUM =0

Feb 21, 2015 06:15:59 CST PB SUM =0

Feb 21, 2015 06:15:59 CST Sending email

Feb 21, 2015 06:15:59 CST Completed cloupia script ReportsSnapShotSizeReport

Feb 21, 2015 06:16:00 CST Task #1 (Report_Snap_shot_with_Counter (ExecuteCloupiaScript)) completed successfully in 3 seconds

Feb 21, 2015 06:16:00 CST Input/Output values for Task #1 (Report_Snap_shot_with_Counter (ExecuteCloupiaScript)):

Feb 21, 2015 06:16:00 CST [Local Input: Label = ReportsSnapShotSizeReport]

Feb 21, 2015 06:16:00 CST [Local Input: Script = 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, repor

Feb 21, 2015 06:16:00 CST [Local Input: Undo Script = ]

Feb 21, 2015 06:16:00 CST Completed workflow item number 2, with status Completed

Feb 21, 2015 06:16:02 CST Executing workflow item number 3

Feb 21, 2015 06:16:02 CST Completed workflow item number 3, with status Completed

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links