cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1067
Views
1
Helpful
2
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task Name

Report example on how to get the APIC application Tenant Profile Name.

Description

Prerequisites

Tested on UCSD 6.0.0.0

CategoryWorkflow
ComponentsvSphere 5.x
User Inputs


Instructions for Regular Workflow Use:

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

Workflow:

The custom task as well as the Cloupia script are included.

Screen Shot 2017-01-19 at 9.57.36 AM.png

Input:

Screen Shot 2017-01-18 at 8.36.51 AM.png

The Log:

Service Request ID: 361

Workflow Inputs:

- outa1

- outa2

- APIC_Tenant

- Email Address

Jan 19, 2017 15:55:00 UTC Request submitted

Jan 19, 2017 15:55:05 UTC Executing workflow item number 1

Jan 19, 2017 15:55:05 UTC Completed workflow item number 1, with status Completed

Jan 19, 2017 15:55:11 UTC Executing workflow item number 2

Jan 19, 2017 15:55:11 UTC Trigger context executeWorkFlowStep called

Jan 19, 2017 15:55:12 UTC Executing custom action ReportAPICTenantProfiles (custom_APICTenantApplicationProfile)

Jan 19, 2017 15:55:12 UTC Executing custom action ReportAPICTenantProfiles (custom_APICTenantApplicationProfile)

Jan 19, 2017 15:55:12 UTC Executing custom script for APICTenantApplicationProfile

Jan 19, 2017 15:55:12 UTC Input : OracleAPIC@infra

Jan 19, 2017 15:55:12 UTC Input 0 : OracleAPIC

Jan 19, 2017 15:55:12 UTC Input 1 : infra

Jan 19, 2017 15:55:12 UTC numRowsFound : 1

Jan 19, 2017 15:55:12 UTC DN: uni/tn-infra/ap-access

Jan 19, 2017 15:55:12 UTC Application Profile Name: access

Jan 19, 2017 15:55:12 UTC Tenant: infra

Jan 19, 2017 15:55:12 UTC Description:

Jan 19, 2017 15:55:12 UTC QOS Class: unspecified

Jan 19, 2017 15:55:12 UTC DN 0: uni

Jan 19, 2017 15:55:12 UTC DN 1: tn-infra

Jan 19, 2017 15:55:12 UTC Dn 2: ap-access

Jan 19, 2017 15:55:12 UTC Processing output: a0

Jan 19, 2017 15:55:12 UTC Processing output: a1

Jan 19, 2017 15:55:12 UTC Processing output: a2

Jan 19, 2017 15:55:12 UTC Processing output: a3

Jan 19, 2017 15:55:12 UTC Processing output: a4

Jan 19, 2017 15:55:12 UTC Processing output: dn0

Jan 19, 2017 15:55:12 UTC Processing output: dn1

Jan 19, 2017 15:55:13 UTC Processing output: dn2

Jan 19, 2017 15:55:13 UTC Task #2 (ReportAPICTenantProfiles (custom_APICTenantApplicationProfile)) completed successfully in 1 seconds

Jan 19, 2017 15:55:13 UTC Input/Output values for Task #2 (ReportAPICTenantProfiles (custom_APICTenantApplicationProfile)):

Jan 19, 2017 15:55:13 UTC [Mapped Input: APICTenant = OracleAPIC@infra]

Jan 19, 2017 15:55:13 UTC [Output: a0 = uni/tn-infra/ap-access]

Jan 19, 2017 15:55:13 UTC [Output: a1 = access]

Jan 19, 2017 15:55:13 UTC [Output: a2 = infra]

Jan 19, 2017 15:55:13 UTC [Output: a3 = ]

Jan 19, 2017 15:55:13 UTC [Output: a4 = unspecified]

Jan 19, 2017 15:55:13 UTC [Output: dn0 = uni]

Jan 19, 2017 15:55:13 UTC [Output: dn1 = tn-infra]

Jan 19, 2017 15:55:13 UTC [Output: dn2 = ap-access]

Jan 19, 2017 15:55:13 UTC Completed workflow item number 2, with status Completed

Jan 19, 2017 15:55:14 UTC Executing workflow item number 3

Jan 19, 2017 15:55:14 UTC Trigger context executeWorkFlowStep called

Jan 19, 2017 15:55:14 UTC Executing custom action ReportAPICTenantProfiles (ExecuteCloupiaScript)

Jan 19, 2017 15:55:14 UTC Executing custom action ReportAPICTenantProfiles (ExecuteCloupiaScript)

Jan 19, 2017 15:55:15 UTC Executing cloupia script: ReportsAPICTenantProfiles

Jan 19, 2017 15:55:15 UTC AT : OracleAPIC@infra

Jan 19, 2017 15:55:15 UTC 0 : OracleAPIC

Jan 19, 2017 15:55:15 UTC 1 : infra

Jan 19, 2017 15:55:15 UTC numRowsFound : 1

Jan 19, 2017 15:55:15 UTC report: com.cloupia.lib.util.managedreports.TableView@14bd62fc

Jan 19, 2017 15:55:15 UTC DN: uni/tn-infra/ap-access

Jan 19, 2017 15:55:15 UTC Profile02: access

Jan 19, 2017 15:55:15 UTC Tenant: infra

Jan 19, 2017 15:55:15 UTC Description:

Jan 19, 2017 15:55:15 UTC QOS Class: unspecified

Jan 19, 2017 15:55:15 UTC DN 0: uni

Jan 19, 2017 15:55:15 UTC DN 1: tn-infra

Jan 19, 2017 15:55:15 UTC Dn 2: ap-access

Jan 19, 2017 15:55:15 UTC Sending email

Jan 19, 2017 15:55:15 UTC Completed cloupia script ReportsAPICTenantProfiles

Jan 19, 2017 15:55:15 UTC Task #3 (ReportAPICTenantProfiles (ExecuteCloupiaScript)) completed successfully in 0 seconds

Jan 19, 2017 15:55:15 UTC Input/Output values for Task #3 (ReportAPICTenantProfiles (ExecuteCloupiaScript)):

Jan 19, 2017 15:55:15 UTC [Local Input: Label = ReportsAPICTenantProfiles]

Jan 19, 2017 15:55:15 UTC [Local Input: Script = 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.service.cIM.inframgr.profiles); importPackage(com.cloupia.service.cIM.inframgr); 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) { } 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); } // Assume the To Email Addres is in the input variable 'Email Address' var toEmail = [ ctxt.getInput('Email Address') ]; var message = new EmailMessageRequest(); message.setToAddrs(toEmail); message.setSubject('APIC Tenant Profile Report'); message.setFromAddress('no-reply@cisco.com'); var buffer = new StringWriter(); var printer = new PrintWriter(buffer); // Formatter exists in multiple packages, so it needs fully qualified name var formatter = new com.cloupia.lib.util.managedreports.Formatter(new File('.'), printer); var AT = ctxt.getInput('APIC_Tenant'); logger.addInfo('AT : ' + AT); var x = AT.split('@'); logger.addInfo('0 : ' + x[0]); logger.addInfo('1 : ' + x[1]); var reportName='apic.tenant.appln.profile.report.config'; var repContext = util.createContextByType( '90160','','accountName=='' + x[0] +'' && name=='' + x[1] +'''); var report = getReportView(repContext, reportName); var i=0; var numRowsFound = report.rowCount(); logger.addInfo('numRowsFound : ' + numRowsFound); logger.addInfo('report: ' + report); var a0 = report.getColumnValue(0, 'DN'); logger.addInfo('DN: ' + a0); //var a1 = report.getColumnValue(0, 'Application Profile Name'); var a1 = report.getColumnValue(0, 'Name'); logger.addInfo('Profile02: ' + a1); var a2 = report.getColumnValue(0, 'Tenant '); logger.addInfo('Tenant: ' + a2); var a3 = report.getColumnValue(0, 'Description'); logger.addInfo('Description: ' + a3); var a4 = report.getColumnValue(0, 'QoS Class'); logger.addInfo('QOS Class: ' + a4); var sp = a0.split('/'); logger.addInfo('DN 0: ' + sp[0]); logger.addInfo('DN 1: ' + sp[1]); logger.addInfo('Dn 2: ' + sp[2]); ctxt.updateInput('outa1', sp[2]); formatter.printTable(report); printer.close(); var body = '<head><style type='text/css'>'; // Specify CSS for the report body = body + 'table { font-family: Verdana, Geneva, sans-serif; font-size: 12px; border: thin solid #039; border-spacing: 0; background: #ffffff; } '; body = body + ' th { background-color: #6699FF; color: white; font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-weight: bold; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; } '; body = body + ' td { font-family: Verdana, Geneva, sans-serif; font-size: 10px; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; background: #ffffff; }'; body = body + '</style></head>'; body = body+ '<body><h1>VDC 1 Report</h1><br>' + buffer.toString(); message.setMessageBody(body); logger.addInfo('Sending email'); // Now, send the report via email. First parameter is just a label used in the // internal logs MailManager.sendEmail('VDC approver report', getMailSettings(), message); ]

Jan 19, 2017 15:55:15 UTC [Local Input: Undo Script = ]

Jan 19, 2017 15:55:15 UTC Completed workflow item number 3, with status Completed

Jan 19, 2017 15:55:17 UTC Executing workflow item number 4

Jan 19, 2017 15:55:17 UTC Trigger context executeWorkFlowStep called

Jan 19, 2017 15:55:17 UTC Executing custom action ReportAPICTenantProfiles (Send Email)

Jan 19, 2017 15:55:17 UTC Executing custom action ReportAPICTenantProfiles (Send Email)

Jan 19, 2017 15:55:18 UTC Sending email to ogelbric@cisco.com, with Subject APIC Tenant Profle

Jan 19, 2017 15:55:18 UTC Task #4 (ReportAPICTenantProfiles (Send Email)) completed successfully in 0 seconds

Jan 19, 2017 15:55:18 UTC Input/Output values for Task #4 (ReportAPICTenantProfiles (Send Email)):

Jan 19, 2017 15:55:18 UTC [Local Input: E-mail Addresses = ogelbric@cisco.com]

Jan 19, 2017 15:55:18 UTC [Local Input: Subject = APIC Tenant Profle]

Jan 19, 2017 15:55:18 UTC [Template Input:Body = ${outa1}]

Jan 19, 2017 15:55:18 UTC [Resolved Template Input: Body = ap-access]

Jan 19, 2017 15:55:18 UTC [Local Input: Body = ap-access]

Jan 19, 2017 15:55:18 UTC [Output: EMAIL_ADDRESSES = ogelbric@cisco.com]

Jan 19, 2017 15:55:18 UTC Completed workflow item number 4, with status Completed

Jan 19, 2017 15:55:23 UTC Executing workflow item number 5

Jan 19, 2017 15:55:23 UTC Completed workflow item number 5, with status Completed

The Custom Task:

Screen Shot 2017-01-19 at 9.59.04 AM.png

Screen Shot 2017-01-19 at 9.59.10 AM.png

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.service.cIM.inframgr.profiles);

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 buffer = new StringWriter();

var printer = new PrintWriter(buffer);

var formatter = new com.cloupia.lib.util.managedreports.Formatter(new File("."), printer);

var AT = input.APICTenant;

logger.addInfo("Input : " + AT);

var x = AT.split('@');

logger.addInfo("Input 0 : " + x[0]);

logger.addInfo("Input 1 : " + x[1]);

var reportName="apic.tenant.appln.profile.report.config";

var repContext = util.createContextByType( "90160","","accountName=='" + x[0] +"' && name=='" + x[1] +"'");

var report = getReportView(repContext, reportName);

var numRowsFound = report.rowCount();

logger.addInfo("numRowsFound : " + numRowsFound);

var aa0 = report.getColumnValue(0, "DN");

logger.addInfo("DN: " + aa0);

//var a1 = report.getColumnValue(0, "Application Profile Name"); Apparently heading is actuall just Name

var aa1 = report.getColumnValue(0, "Name");

logger.addInfo("Application Profile Name: " + aa1);

var aa2 = report.getColumnValue(0, "Tenant ");

logger.addInfo("Tenant: " + aa2);

var aa3 = report.getColumnValue(0, "Description");

logger.addInfo("Description: " + aa3);

var aa4 = report.getColumnValue(0, "QoS Class");

logger.addInfo("QOS Class: " + aa4);

var sp = aa0.split('/');

logger.addInfo("DN 0: " + sp[0]);

logger.addInfo("DN 1: " + sp[1]);

logger.addInfo("Dn 2: " + sp[2]);

output.a0 = aa0;

output.a1 = aa1;

output.a2 = aa2;

output.a3 = aa3;

output.a4 = aa4;

output.dn0 = sp[0];

output.dn1 = sp[1];

output.dn2 = sp[2];

formatter.printTable(report);

printer.close();

Comments
phirobin
Community Member

great - thanks Orf - the Heading Application Profile Name = Name is the bit that threw me - though it's not the first time that has happened with the report name headers not matching the variables

Orf Gelbrich
Cisco Employee
Cisco Employee

Trying to keep I generic for the next report that needs this…

Orf Gelbrich

Check out UCS Director Workflow INDEX<https://communities.cisco.com/docs/DOC-56419> on Cisco Communities Site (Twitter @UCSDGURU)

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