Instructions for CISCO models including: CloupiaScript Interpreter, CloupiaScript, Interpreter
Cisco UCS Director Custom Task Getting Started Guide, Release 6.8 - CloupiaScript Interpreter [Cisco UCS Director] - Cisco
CloupiaScript Interpreter · About the CloupiaScript Interpreter, on page 1 · Starting the CloupiaScript Interpreter, on page 1 · Starting the CloupiaScript Interpreter with a Context, on page 2 · Example: Using the CloupiaScript Interpreter, on page 2 About the CloupiaScript Interpreter The CloupiaScript interpreter is a JavaScript interpreter populated with built-in libraries and APIs. You can use the CloupiaScript interpreter to test CloupiaScript code without having to create and run a workflow task. Built-in Functions of the CloupiaScript Interpreter · PrintObj()--Takes an object as an argument and prints out all the properties and methods in the object. The printed result provides the names and values for variables in the object and the names of all the object's functions. You can then call toString() on any of the method names to examine the method signature. · Upload()--Takes a filename as an argument and uploads the file's contents to the CloupiaScript interpreter. Starting the CloupiaScript Interpreter To open the CloupiaScript interpreter, do the following: Step 1 Step 2 Step 3 Step 4 Step 5 Choose Orchestration. Click Custom Workflow Tasks. Click Launch Interpreter. The Cloupia Script Interpreter screen appears. Enter a line of JavaScript code in the text input field at the bottom of the Cloupia Script Interpreter field. Press Enter. The code is executed and the result is displayed. If there is a syntax error in the code, the error is displayed. CloupiaScript Interpreter 1 Starting the CloupiaScript Interpreter with a Context CloupiaScript Interpreter Starting the CloupiaScript Interpreter with a Context You can evaluate JavaScript in the context of a particular a custom task. To do so, you select a custom task, launch the CloupiaScript Interpreter, and supply the context variables that are defined for executing that custom task. When you launch the interpreter, it prompts you for values of the custom task input fields and populates the input object of the task. All the variables that are available when you actually execute the custom task are made available. To open the CloupiaScript interpreter with a context available, do the following: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Choose Orchestration. Click Custom Workflow Tasks. Click the row with the custom task for which you need to test the JavaScript. Click Launch Interpreter with Context. The Launch Interpreter screen appears with input fields to collect input values for the custom task. The input fields are those defined for the custom task you have selected. Enter input values in the screen. Click Submit. Click Submit. The Cloupia Script Interpreter screen appears. Enter a line of JavaScript code in the text input field at the bottom of the Cloupia Script Interpreter field. Press Enter. The code is executed and the result is displayed. If there is any syntax error in the code, the error is displayed. Example: Using the CloupiaScript Interpreter The printObj( ) function prints all the properties and methods it contains. Call functiontoString() to find more details about a function. The following example shows how to examine the ReportContext class and get details about ReportContext.setCloudName(). session started > importPackage(com.cloupia.model.cIM); > var ctx = new ReportContext(); > printObj(ctx); properties = cloudName:null class:class com.cloupia.model.cIM.ReportContext filterId:null id:null targetCuicId:null type:0 ids:[Ljava.lang.String;@4de27bc5 methods = setIds jdoReplaceField CloupiaScript Interpreter 2 CloupiaScript Interpreter jdoReplaceFields toString getCloudName wait getClass jdoReplaceFlags hashCode jdoNewInstance jdoReplaceStateManager jdoIsDetached notify jdoGetVersion jdoProvideField jdoCopyFields jdoGetObjectId jdoGetPersistenceManager jdoCopyKeyFieldsToObjectId jdoGetTransactionalObjectId getType getFilterId setType jdoIsPersistent equals setCloudName jdoNewObjectIdInstance jdoIsDeleted getTargetCuicId setId setFilterId jdoProvideFields jdoMakeDirty jdoIsNew requiresCloudName getIds notifyAll jdoIsTransactional getId jdoReplaceDetachedState jdoIsDirty setTargetCuicId jdoCopyKeyFieldsFromObjectId > var func = ctx.setCloudName; > func void setCloudName(java.lang.String) > func.toString(); function setCloudName() {/* void setCloudName(java.lang.String) */} Example: Using the CloupiaScript Interpreter CloupiaScript Interpreter 3 Example: Using the CloupiaScript Interpreter CloupiaScript Interpreter CloupiaScript Interpreter 4DITA Open Toolkit XEP 4.30.961; modified using iText 2.1.7 by 1T3XT