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


Task Name


Toggle the VMware tools automatic upgrade on a VM at power on
Description

Prerequisites
  1. UCSD 6.5.0.2
CategoryWorkflow
Components
User Inputs

VM name

vCenter Cluster name/vCenter DC Name

vCenter name

Boolean (true / false)

Output

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 .WFDX file resides. Choose the .WFDX 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.

Note:

This task can work in conjunction with this posting:

UCSD - Patch ESXi Servers by vCenter Cluster (Firmware Upgrade coming in UCSD 6.6)

The Workflow:

Screen Shot 2018-01-30 at 6.29.23 AM.png

User Input to toggle the flag on:

Screen Shot 2018-01-30 at 6.30.23 AM.png

Result:

Screen Shot 2018-01-29 at 7.14.07 AM.png

User Input to toggle the flag off:

Screen Shot 2018-01-30 at 6.33.56 AM.png

Result:

Screen Shot 2018-01-30 at 6.34.33 AM.png

Workflow execution:

Screen Shot 2018-01-30 at 6.32.42 AM.png

The code of the custom task for the VMware tools toggle:

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

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

importPackage(com.cloupia.model.cIM);

importPackage(com.cloupia.lib.cIaaS.vmware);

importPackage(com.vmware.vim25.mo);

importPackage(com.vmware.vim25);

importPackage(java.lang);

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

importPackage(com.cloupia.feature.vmwareController.wftasks.configs);


var clusterName=input.VCenterCluster;

var account=InfraPersistenceUtil.getAccount(input.VCenterAccount);

var datacenterName = input.VCenterDC;

var serviceInstance = new VCenterConnectionManager(account).getServiceInstance();

var dataCenterEntity = null;

var vmName = input.VMName;

if (datacenterName !== null && !datacenterName.isEmpty()) {

    //If datacenter name is present, get the entity from root folder.

    logger.addInfo("Datacenter name is " + datacenterName);

    var folder = serviceInstance.getRootFolder();

dataCenterEntity = new InventoryNavigator(folder).searchManagedEntity("Datacenter", datacenterName);

}


var clusterEntity = null;  

var folder = null;

if (dataCenterEntity !== null) {

        logger.addInfo("Datacenter entity is " + dataCenterEntity);

if (clusterName !== null && !clusterName.isEmpty()) {

         logger.addInfo("Cluster name is " + clusterName);

//Once we have datacenter and cluster, filter at cluster level

clusterEntity = new InventoryNavigator(dataCenterEntity).searchManagedEntity("ClusterComputeResource", clusterName);

}

} else {

    logger.addInfo("Cluster is only present " + clusterName);

if (clusterName !== null && !clusterName.isEmpty()) {

     folder = serviceInstance.getRootFolder();

         clusterEntity = new InventoryNavigator(folder).searchManagedEntity("ClusterComputeResource", clusterName);

}

}

var vmME = null;


if (clusterEntity !== null) {

    logger.addInfo("Cluster entity is: " + clusterEntity);

    logger.addInfo("VM name is " + vmName);

    vmME = new InventoryNavigator(clusterEntity).searchManagedEntity("VirtualMachine", vmName);

    logger.addInfo("VM Entity is " + vmME);

    if (vmME !== null) {

//     logger.addInfo("Tools running status " + vmME.getGuest().getToolsRunningStatus());

// logger.addInfo("Tools status " + vmME.getGuest().getToolsStatus());

// logger.addInfo("Tools version " + vmME.getGuest().getToolsVersion());

//     logger.addInfo("Tools version status " + vmME.getGuest().getToolsVersionStatus());

// logger.addInfo("Tools version status2 " + vmME.getGuest().getToolsVersionStatus2());

// logger.addInfo("Tool policy " + vmME.getConfig().getTools().getToolsUpgradePolicy());

var powerState = vmME.getRuntime().getPowerState().toString();

if (powerState.equals("poweredOff")) {

     var toolsInfo = vmME.getConfig().getTools();

//    toolsInfo.setAfterPowerOn(true);

        if (input.UpgradeYesNo === false){

            toolsInfo.setAfterPowerOn(false);

            toolsInfo.setToolsUpgradePolicy(UpgradePolicy.manual.toString());

        }

        if (input.UpgradeYesNo === true){

            toolsInfo.setAfterPowerOn(true);

            toolsInfo.setToolsUpgradePolicy(UpgradePolicy.upgradeAtPowerCycle.toString());

        }

//    toolsInfo.setAfterPowerOn(false);

   

    //For manual setting

//toolsInfo.setToolsUpgradePolicy(UpgradePolicy.manual.toString());

//For upgrade at power recycle settings

//toolsInfo.setToolsUpgradePolicy(UpgradePolicy.upgradeAtPowerCycle.toString());

//vmME.getConfig().setTools(toolsInfo);

var spec = new VirtualMachineConfigSpec();

spec.setTools(toolsInfo);

logger.addInfo("Tool policy2 " + vmME.getConfig().getTools().getToolsUpgradePolicy());

var aTask = vmME.reconfigVM_Task(spec);

var aStatus = aTask.waitForTask();

        if (!Task.SUCCESS.equals(aStatus)) {

var ti = task.getTaskInfo();

if (ti !== null) {

if (ti.getError() !== null) {

aStatus = aStatus + ": " + ti.getError().getLocalizedMessage();

}

}

logger.addInfo(status);

} else {

      logger.addInfo("Successfully reconfigured the vm with name "+ vmName);

}

}

    }

   

}

serviceInstance.getServerConnection().logout();



VOD:


Video Link : 16858

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