UCSD - Report on UCSD Users and create User LOV

Version 1
    Task Name

    Create LOV of UCSD Users.

    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.

     

     

    The Workflow:

     

    Step one get user report (user1=user1,user2=user2;...)

    Step two is re-use a create LOV task with step one input.

    Screen Shot 2017-01-11 at 5.10.12 PM.png

     

    Workflow execution:

    Screen Shot 2017-01-11 at 5.10.37 PM.png

     

    Screen Shot 2017-01-11 at 5.10.44 PM.png

     

    The resulting LOV:

     

    Screen Shot 2017-01-11 at 5.09.42 PM.png

    LOV test:

    Screen Shot 2017-01-11 at 5.09.53 PM.png

     

    The report code:

     

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

     

     

    // 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  = "AccountsFeature.user.table_config";

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

    var report = getReportView(repContext, reportName);

     

     

     

     

    // Filter Active State VMs

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

    var numRowsFound = report.rowCount();

    logger.addInfo("numRowsFound : " + numRowsFound)

    var aa="";

               for (var i=0; i<numRowsFound; i++)

                {

                var a1 = report.getColumnValue(i, "Login Name");

                logger.addInfo("Login Name: " + a1);

      aa = aa + a1 + "=" + a1 + ",";

                }

     

     

    logger.addInfo("aa : " + aa)

    ctxt.updateInput("out", aa);

     

     

     

     

    formatter.printTable(report);

     

    printer.close();

     

     

    The LOV custom task code:

     

    importPackage(java.lang);

    importPackage(java.util);

    importPackage(com.cloupia.service.cIM.inframgr);

    importPackage(com.cloupia.model.cIM);

    importPackage(com.cloupia.service.cIM.inframgr.reservation);

    importPackage(com.cloupia.service.cIM.inframgr.forms.wizard);

     

     

    var csvlist = input.CSV_List;

    var lovvariablename = input.LOV_Variable_Name;

     

     

    function createLOV(){

    var dataProvider = getDataProvider();

    registerLOV(dataProvider);

    registerGlobalInputs(dataProvider)

    }

     

     

    function getDataProvider(){

    var lovRegistry = LOVProviderRegistry.getInstance();

    var lovProvider = new com.cloupia.service.cIM.inframgr.forms.wizard.LOVProviderIf({

    getLOVs : function(session) {

    //provide your own lovContent

    //var lovContent = "Country1=1,Country2=2,Country3=3,Country4=4,Country5=5";

     

     

    var lovContent = csvlist;

     

     

    return getFormLovPair(lovContent);

    //End of implementation for Lovprovider

    }

    });

    return lovProvider;

    }

     

     

    function registerLOV(dataProvider){

    var lovRegistry = LOVProviderRegistry.getInstance();

    lovRegistry.registerProvider(lovvariablename, dataProvider);

    }

     

     

    function getWorkflowInputType(){

    return lovvariablename;//provide here WorkflowInputType inside the Quotes

    }

     

     

    function getWorkflowInputLabel(){

    return lovvariablename;//provide here WorkflowInputLabel inside the Quotes

    }

     

     

    function registerGlobalInputs(lovProvider){

    var registry = CustomFeatureRegistry.getInstance();

    registry.registerWorkflowInputFieldType(getWorkflowInputType(), getWorkflowInputLabel(), FormFieldDefinition.FIELD_TYPE_EMBEDDED_LOV, lovvariablename);

    }

    function getFormLovPair(lovContent) {

     

      var lovPairArr = lovContent.split(",");

      var lovPair;

      var lovLabel;

      var lovValue;

      var formlov;

      var formlovarr = [];

      for(var count = 0;count<lovPairArr.length;count++){

      lovPair = lovPairArr[count];

      lovLabel = lovPair.split("=")[0];

      lovValue = lovPair.split("=")[1];

      formlov = new FormLOVPair(lovLabel,lovValue);

      formlovarr[count] = formlov;

      }

      return formlovarr;

    }

    createLOV()