cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
870
Views
1
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task NameThis example shows how to filter UCSD screens by a regex
Description
  1. Get PSA report and find PSA agent name
Prerequisites
  1. Tested on 6.0
CategoryWorkflow
ComponentsvSphere 5.x
User Inputs
  1. redex PSA agent name  .*106.*
OutputID

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.

Here are a few examples on how to search for a PSA agent name:

Screen Shot 2016-10-30 at 7.41.50 AM.png

Screen Shot 2016-10-30 at 7.42.20 AM.png

Screen Shot 2016-10-30 at 7.43.05 AM.png

Screen Shot 2016-10-30 at 7.43.24 AM.png

The workflow:

Screen Shot 2016-10-30 at 7.43.33 AM.png

The key in the search in the code:

Screen Shot 2016-10-30 at 7.44.21 AM.png

The UCSD PSA screen that is searched:

Screen Shot 2016-10-30 at 7.50.37 AM.png

The Code:

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

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

}

var name = input.Name;

logger.addInfo("Looking for Power Shell Agent Partial Name : " + name);

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 reportName  = "PowershellAgentController.powershellagent.table_config";

var repContext = util.createContext("global_admin", null, null);

var report = getReportView(repContext, reportName);

logger.addInfo("Looking/Filtering for Power Shell Agent Name..............: " + name);

// false exact match

// ture = regex

//report = report.filterRowsByColumn("Name", name, false);

report = report.filterRowsByColumn("Name", name , true);

var numRowsFound = report.rowCount();

if (numRowsFound == 1 )

{

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

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

logger.addInfo("Power Shell Agent Name...............: " + id);

  formatter.printTable(report);

  printer.close();

  output.ReturnStatus = id;

// ctxt.setFailed("Number of Rows found......greater then zero PSA exists:" + name);

}

else

{

  logger.addInfo("Zero or Less...............: ");

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

  formatter.printTable(report);

  printer.close();

  output.ReturnStatus = -1;

  ctxt.setFailed("Number of Rows found......greater then zero more then one PSA exists:" + name);

}

//output.ReturnStatus = -1;

//ctxt.exit();

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