Task Name | Enable VMRC Console via workflow |
Description | Enable VMRC Console via workflow |
Prerequisites | - Tested on 5.3
|
Category | Workflow tasks |
Components | Enable VMRC Console via workflow |
- Log in to UCS Director as a user that has "system-admin" privileges.
- Navigate to "Policies-->Orchestration" and click on "Import".
- Click "Browse" and navigate to the location on your computer where the .wfdx file resides. Choose the .wfdx file and click "Open".
- Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
- Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
- Click "Submit".
- A new folder should appear in "Policies-->Orchestration" that contains the imported workflow.
Thank you goes out to Abhilash Pujari.
The workflow:


The workflow input of VM selection:


The custom task script:
importPackage(java.lang);
importPackage(com.cloupia.service.cIM.inframgr);
var vms = input.vmId;
var vmIds = vms.split(",");
var action = input.action;
try{
for(var i=0; i<vmIds.length; i++){
performAction(parseInt(vmIds[i]), action);
}
}catch(e){
logger.addError("Error occured"+e);
ctxt.setFailed("Task failed to retrieve vm info.");
ctxt.exit();
}
function performAction(vmId, action){
var result = false;
logger.addInfo("Getting Info. for VM : "+vmId);
var vmSummary = ctxt.getAPI().getVMwareVMInfo(vmId);
if(vmSummary != null){
if(action.equalsIgnoreCase("Enable")){
if(vmSummary.isVmrcEnabled()){
logger.addWarning("VMRC Console Access already enabled for this VM");
return;
}else{
vmSummary.setVmrcEnabled(true);
result = InfraPersistenceUtil.modifyVMWareVMSummary(vmSummary);
if(result)
logger.addInfo("VMRC Console Access Enabled successfully.");
else
logger.addWarning("failed to enable VMRC Console Access.");
}
}else{
if(! vmSummary.isVmrcEnabled()){
logger.addWarning("VMRC Console Access already disabled for this VM");
return;
}else{
vmSummary.setVmrcEnabled(false);
result = InfraPersistenceUtil.modifyVMWareVMSummary(vmSummary);
if(result)
logger.addInfo("VMRC Console Access Disabled successfully.");
else
logger.addWarning("failed to disable VMRC Console Access.");
}
}
}else{
logger.addWarning("VM not found :"+ vmSummary.getName());
}
}