cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2577
Views
2
Helpful
4
Comments
Damien Gouju
Cisco Employee
Cisco Employee

Purpose of the document

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.

Prerequisites

You have to enable developer mode in UCS Director as an admin, to access to report metadata:

screenshot_1538.png

Download the Cloupia Script bundle, to get access to JavaDoc (and multiple custom tasks samples):

screenshot_1537.png

Methodology

First, we will gather the elements that are needed:

  • Go to the report that interest you in UCS Director. In this example, you need to access to the VMs running on a specific node (see this task). Go to Virtual -> Compute, select a cloud (here "vc-labcloud"), go to Host nodes tab, select a host (here named "192.168.7.77") and click on View Details and go to VMs tab:

screenshot_1540.png

  • The developper menu feature enabled the Report Metadata, click on it and scroll to reportName:

screenshot_1541.png

The reportName is the generic identifier of this report. Now, we need to identify in which contexts this report exists.

  • Go to Admin -> User Interface Settings and select Report Customization tab. Add the ID column (it is hidden by default) using the blue wheel, and search for the reportName (ID) you noted:

screenshot_1539.png

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:

screenshot_1543.png

  1. The contextName is the context we got from the Report Customization page. In this example: contextName = "hostnode"
  2. If contextName is cloud or hostnode, this should be set to the cloud name. In this example, the cloud name is vc-labcloud: cloud = "vc-labcloud" Otherwise, it should be set to null
  3. The value is the object name. In this example, the host name we want the VMs running on is 192.168.7.77 : value = "192.168.7.77"


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:

screenshot_1544.png


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!

Comments
chris31
Community Member

A must have in your bookmark!

Thank you Damien ;-)

harishap.24
Level 1
Level 1

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.

Orf Gelbrich
Cisco Employee
Cisco Employee

I would need to your CCO id to do that

odahlqvist
Level 4
Level 4

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

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