06-04-2014 11:07 AM - edited 03-01-2019 06:29 AM
Developed by Russ Whitear
Task Name | This custom workflow task can determine which ESX host nodes belong to each ESX cluster. |
Description |
|
Prerequisites |
|
Category | File |
Components | vSphere 5.x |
User Inputs |
Instructions for Custom Workflow Use:
Instructions for Regular Workflow Use:
Script Example:
// Report Skeleton.
importPackage(java.lang);
importPackage(java.util);
importPackage(com.cloupia.lib.util.managedreports);
importPackage(com.cloupia.model.cIM);
importPackage(com.cloupia.service.cIM.inframgr);
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 cloudName = input.cloudName;
var repContext = util.createContext("cloud", cloudName, null);
var report = getReportView(repContext, "PER_CLOUD_CLUSTER_LIST");
var numRowsFound = report.rowCount();
logger.addInfo("Number of Rows found: " + numRowsFound);
// Retrieve ESX Cluster Names. We will use these to then retrieve the ESX hostnames
// for each cluster.
var ClusterNameArray = [];
for (var i=0; i<report.rowCount(); i++)
{
ClusterNameArray[i] = report.getColumnValue(i, "Cluster Name");
logger.addInfo("Column [" + i + "]: " + ClusterNameArray[i]);
}
for(i=0; i<ClusterNameArray.length; i++)
{
var repContext = util.createContext("cloud", cloudName, ClusterNameArray[i]);
var report = getReportView(repContext, "PER_CLUSTER_HOSTNODE_INVENTORY_LIST")
var numRowsFound = report.rowCount();
logger.addInfo("Number of Rows found for cluster " + ClusterNameArray[i] + ": " + numRowsFound);
for (var j=0; j<report.rowCount(); j++)
logger.addInfo("Node [" + j + "]: " + report.getColumnValue(j, "Host Node") );
}
Is there supposed to be a zip file attached?
Looks like you need to paste the java script into a custom task. Russ wrote this.
Ok, cool. Thanks Orf.
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: