07-27-2016 09:06 AM - edited 03-01-2019 06:42 AM
UCS Director collects a lot of information on the infrastructure. Manipulating these information in workflows and custom tasks is very useful in various use cases: extracting informations, cross-reference data... This document explain how to quickly access and manipulate these elements called reports in custom tasks.
You have to enable developer mode in UCS Director as an admin, to access to report metadata:
Download the Cloupia Script bundle, to get access to JavaDoc (and multiple custom tasks samples):
First, we will gather the elements that are needed:
The reportName is the generic identifier of this report. Now, we need to identify in which contexts this report exists.
The Context column give you the context(s) of this report. In this example, context is "hostnode". Now, we have all the information, we can start to code!
Attached to this document is a Script Module that you can import in the Orchestration module (like Workflows / tasks). Then, you can load this code in your custom tasks, it will provide the functions that create the TableView object that will contain these data and that you will manipulate. This module can be easily loaded at the beginning of your script:
loadLibrary("ReportManipulation/ReportCloupiaScripts")
This module provides a function getReportView which requires 2 arguments: getReportView(reportContext, reportName);
Second one is easy, it is the name of the report, so in this example:
var reportName = "PER_HOSTNODE_VM_LIST_CONFIG_REPORT";
First one is an object created using the createContext method. Here is the documentation from the JavaDoc:
So, you can now create the context:
var reportContext = util.createContext("hostnode", "vc-labcloud", "192.168.7.77");
And now you can get the report data using these two informations:
var report = getReportView(reportContext, reportName);
This function returns a TableView object, and all the methods to manipulate it (filter,...) are documented in the JavaDoc:
This workflow allows you to discover the columnLabels of the report, or you can just loop on it:
for (i=0;i<report.columnCount();i++)
{
logger.addInfo("Column "+i+" : " + report.getColumnLabel(i))
}
And you can do whatever you want , keeping only powered-on vm with the name prefixed by "dc-web", and then store the VM-ID of the first VM of the table:
report = report.filterRowsByColumn("Power Status", "ON", false);
report = report.filterRowsByColumn("Instance Name", "dc-web.*", true);
vmid = report.getColumnValue(0,"VM-ID");
Now you can easily manipulate reports!
A must have in your bookmark!
Thank you Damien ;-)
Hey I am a new to this, and i would like explore on the cloupia scripts. Could you publish the cloupia scripts SDK bundle 6.5.
I would need to your CCO id to do that
Hi Orf
Will this work also in version 6.7 and if not what do I need to do?, I want to add som columns to L2 APIC reports for CDP neighbors and try to find how to change the build in report and add a column for "description" filed
/Ola
APIC_NEIGHBORS_REPORT
Report Definition
APIC_NEIGHBORS_REPORT
L2 Neigbors
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: