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
|
- Number of disks
|
Output
|
Result of operation
|
Installation
- Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
- Unzip the file on your computer. Should end up with a .WFDX file.
- Log in to UCS Director as a user that has "system-admin" privileges.
- Navigate to "Policies-->Orchestration" and click on "Import".
- Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
- Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
- Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
- Click "Submit".
- 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:
The workflow:
Task one grabs the report context from here:
context
The context ends up in this variable:
Workflow run:
Workflow outputs:
Workflow Inputs tested with:
Workflow e-mail results:
Code 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