cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
562
Views
0
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee

 

 

Task Name

APIC Reports E-Mailed (Generic)

Description

APIC Reports E-Mailed (Generic)

Prerequisites

Validated on UCSD 6.6

Category

Workflow Task

Components

 

User Inputs

  1. Number of disks

Output

Result of operation

 

 

Installation

  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 .WFDX 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.

This is a workflow for APIC report to be e-mailed. 

It generates the context on the fly. 

Input is only report name and param1 

 

Here is a site (https://ascii.cl/url-decoding.htm)  to decode the parm0, parm1, parm2 URL in the developer mode screen metadata:

Screen Shot 2018-07-28 at 4.43.41 AM.png

 

The workflow:

 

Screen Shot 2018-07-27 at 2.08.20 PM.png

 

Task one grabs the report context from here: 

 

contextcontext

 

The context ends up in this variable: 

 

Screen Shot 2018-07-27 at 1.03.22 PM.png

 

Workflow run: 

 

Screen Shot 2018-07-27 at 2.01.23 PM.png

Workflow outputs: 

 

Screen Shot 2018-07-27 at 2.03.19 PM.pngScreen Shot 2018-07-27 at 2.04.35 PM.pngScreen Shot 2018-07-27 at 2.06.04 PM.png

 

Screen Shot 2018-07-27 at 2.06.53 PM.png

 

Workflow Inputs tested with: 

 

Screen Shot 2018-07-28 at 4.32.15 AM.pngScreen Shot 2018-07-28 at 4.32.22 AM.pngScreen Shot 2018-07-28 at 4.32.30 AM.pngScreen Shot 2018-07-28 at 4.34.47 AM.png

 

Workflow e-mail results: 

 

Screen Shot 2018-07-28 at 4.37.28 AM.pngScreen Shot 2018-07-28 at 4.37.36 AM.pngScreen Shot 2018-07-28 at 4.37.51 AM.pngScreen Shot 2018-07-28 at 4.37.57 AM.pngCode snippet: 

 

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);
importPackage(com.cloupia.lib.util);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(org.apache.commons.httpclient);
importPackage(org.apache.commons.httpclient.cookie);
importPackage(org.apache.commons.httpclient.methods);
importPackage(org.apache.commons.httpclient.auth);
importPackage(com.cloupia.model.cEvent.notify);
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)
{
logger.addInfo("Error occured::: with getConfigTableReport ");

}
if (report == null)
{
logger.addInfo("report is null with report name "+reportName);
return ctxt.getAPI().getTabularReport(reportName, reportContext);
} else
{
var source = report.getSourceReport();
logger.addInfo("getSourceReport name is:::"+source);
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);
}

function getTabularReport(contextName , contextValue , reportId ){
try {
var tabularReport = ctxt.getAPI().userAPIGetTabularReport(contextName, contextValue,reportId);
logger.addInfo("tabularReport: " + tabularReport);
return tabularReport;
} catch(e){
logger.addError("Error : "+e.message);
}
}

 

var accountANDtenant = "accountName=='Test-Apic' && tenantName=='TamilCusTest' && name=='TamilCusTest_AP'";//picked up from the id(s) field of the report metadata

var reportName="apic.tenant.appln.profile.epg.report.config"; // picked up from the report name field of report meta data

var reportContextType=ReportContext.getDynamicContextLevel("apic.tenant.appln.profile.report"); //picked up this value from user interface settings by passing APIReportId of EPG-T52

logger.addInfo("accountANDtenant is ::::::::::: " + accountANDtenant);

logger.addInfo("Report Context Type is ::::::::::: " + reportContextType);

var repContext = util.createContextByType(reportContextType, null, accountANDtenant);

var report = getReportView(repContext, reportName);

logger.addInfo("Report Context Type is ::::::::::: " + reportContextType);

var numRowsFound = report.rowCount();

logger.addInfo("Number of Rows found: " + numRowsFound);

 

 

 

 

More information: 

 

var accountANDtenant = "accountName=='Test-Apic' && tenantName=='TamilCusTest' && name=='TamilCusTest_AP'";//picked up from the id(s) field of the report metadata

 

var reportName="apic.tenant.appln.profile.epg.report.config"; // picked up from the report name field of report meta data

 

var reportContextType=ReportContext.getDynamicContextLevel("apic.tenant.appln.profile.report"); //picked up this value from user interface settings by passing APIReportId of EPG-T52

 

 

 

 

 

 

 

 

 

 

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