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

This workflow / custom task will e-mail the SR log

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:

Screen Shot 2017-01-31 at 9.08.28 PM.png

Different Inputs with severities:

Screen Shot 2017-01-31 at 9.05.54 PM.png

Screen Shot 2017-01-31 at 9.06.21 PM.png

Screen Shot 2017-01-31 at 9.06.30 PM.png

Screen Shot 2017-01-31 at 9.06.49 PM.png

Resulting e-mail:

Screen Shot 2017-01-31 at 9.23.40 PM.png

Workflow Global Variables:

Screen Shot 2017-01-31 at 9.08.43 PM.png

The Custom Task:

mportPackage(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();

}

// Assume the To Email Addres is in the input variable 'Email Address'

var toEmail = [input.EMAIL];

var message = new EmailMessageRequest();

message.setToAddrs(toEmail);

message.setSubject("SR log");

message.setFromAddress("no-reply@cisco.com");

var srid =  input.SRID;

logger.addInfo ("SR id : " + srid);

var srId = parseInt(String(srid));

logger.addInfo("-------------------------Workflow Errors-----------------------------------"+srid);

var buffer = "";

//var sev3Entries = ctxt.getAPI().userAPIGetServiceRequestLogEntries(srId,3);

var sev3Entries = ctxt.getAPI().userAPIGetServiceRequestLogEntries(srId,input.SEV);

for (i=0;i<sev3Entries.length;i++){

  if(sev3Entries[i].getSeverity() == 0){

  logger.addInfo (sev3Entries[i].getMessage());

  buffer = buffer + sev3Entries[i].getMessage() + "<br>";

  }

}

logger.addInfo("-------------------------Workflow Errors-----------------------------------"+srid);

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>SR Log " + input.SRID + "</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("SR log", getMailSettings(), message);

Comments
mark-shannon
Level 1
Level 1

hi,

great task :)

works perfectly when i run as an admin but get the below when run as an 'end user':-

 

Oct 24, 2019 15:06:02 BST Task: New AD User Account and Mailbox (custom_EmailSRLog) failed with error - java.lang.RuntimeException: java.lang.Exception: No such resource exists or user does not have access privileges: , selectedContext=<None>

Oct 24, 2019 15:06:02 BST Task #3 (New AD User Account and Mailbox (custom_EmailSRLog)) failed after 0 seconds

Oct 24, 2019 15:06:02 BST Input/Output values for Task #3 (New AD User Account and Mailbox (custom_EmailSRLog)):

Oct 24, 2019 15:06:02 BST [Template Input:SRID = ${SR_ID}]

Oct 24, 2019 15:06:02 BST [Resolved Template Input: SRID = 19580]

Oct 24, 2019 15:06:02 BST [Local Input: SRID = 19580]

Oct 24, 2019 15:06:02 BST [Local Input: EMAIL = email@address.co.uk]

Oct 24, 2019 15:06:02 BST [Local Input: SEV = 2]

Oct 24, 2019 15:06:02 BST Completed workflow item number 3, with status Failed

 

Looks like privileges but do you know which one please?

 

thanks in advance

mark 

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