07-22-2015 05:30 PM - edited 03-01-2019 06:36 AM
Task Name | Install / Upgrade Vmware Tools |
Description | |
Prerequisites |
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs |
Instructions for Regular Workflow Use:
Thanks goes out to Phani Penmethsa
The request to create this via custom task:
The workflow and custom task:
The location:
User Input:
The Code for the Custom Task:
importPackage(java.net);
importPackage(javax.xml.rpc);
importPackage(com.vmware.vim);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(com.cloupia.lib.cIaaS.vmware);
importPackage(com.vmware.vim25);
importPackage(com.vmware.vim25.mo);
importPackage(java.lang);
var vmid=input.vmware;
var api=ctxt.getAPI();
var gvm=api.getVMBasicInfo(vmid);
logger.addInfo("GVM" + gvm);
var accountName = gvm.getAccountName();
var vmname=gvm.getInstanceId();
logger.addInfo("ACCOUNT NAME" +accountName);
logger.addInfo("VMWARE NAME" +vmname);
try {
logger.addInfo("Inside try ");
var account = InfraPersistenceUtil.getAccount(accountName);
logger.addInfo("ACCOUNT" + account);
var si = new VCenterConnectionManager(account).getServiceInstance();
logger.addInfo("SERVICEINSTANCE" + si);
var rootFolder = si.getRootFolder();
var vm=new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", vmname);
logger.addInfo("VIRTUAL MACHINE" + vm);
var harwarelist=vm.getConfig().getHardware().getDevice();
var toolrunninnstatus=vm.getGuest().getToolsRunningStatus();
logger.addInfo("TOOL STATUS" + toolrunninnstatus);
var cdRom = null;
for(var i=0;i<harwarelist.length;i++){
logger.addInfo("HARDWARE:" + harwarelist[i]);
if(harwarelist[i] instanceof VirtualCdrom){
cdRom = harwarelist[i];
}
}
if(cdRom == null)
throw new Exception("CD/DVD not found");
if(toolrunninnstatus == "guestToolsRunning"){
logger.addInfo("Inside if ");
vm.upgradeTools_Task("");
}
else{
logger.addInfo("Inside else ");
vm.mountToolsInstaller();
}
} catch (e) {
logger.addError(e);
ctxt.setFailed("CD/DVD drive not found");
ctxt.exit();
}
The run of the workflow:
Service Request ID: 5899
Workflow Inputs:
- VM ID
Nov 24, 2015 12:31:26 UTC Request submitted
Nov 24, 2015 12:31:31 UTC Executing workflow item number 1
Nov 24, 2015 12:31:31 UTC Completed workflow item number 0, with status Completed
Nov 24, 2015 12:31:35 UTC Executing workflow item number 2
Nov 24, 2015 12:31:35 UTC Trigger context executeWorkFlowStep called
Nov 24, 2015 12:31:35 UTC Executing custom action Upgrade or Install VMware tools (custom_Install Or Upgrade VM Tool custom task)
Nov 24, 2015 12:31:35 UTC Executing custom action Upgrade or Install VMware tools (custom_Install Or Upgrade VM Tool custom task)
Nov 24, 2015 12:31:35 UTC Executing custom script for Install Or Upgrade VM Tool custom task
Nov 24, 2015 12:31:39 UTC GVMcom.cloupia.model.cIM.GenericVM@4c302d7f
Nov 24, 2015 12:31:39 UTC ACCOUNT NAMEDallas
Nov 24, 2015 12:31:39 UTC VMWARE NAMEPRD-Win1-01
Nov 24, 2015 12:31:39 UTC Inside try
Nov 24, 2015 12:31:39 UTC ACCOUNTAccount: Name:Dallas, vServer:172.17.32.110, vuser:administrator Vurl :/sdkAccess Port 443, hServer:null, huser:null, rhevmHost: null, rhevmDomain: null, rhevmUserName: null, Location:null
Nov 24, 2015 12:31:39 UTC SERVICEINSTANCEServiceInstance:ServiceInstance @ https://172.17.32.110/sdk
Nov 24, 2015 12:31:39 UTC VIRTUAL MACHINEVirtualMachine:vm-1469 @ https://172.17.32.110/sdk
Nov 24, 2015 12:31:39 UTC TOOL STATUSguestToolsRunning
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualIDEController@5cc529d5
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualIDEController@741dce93
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualPS2Controller@1754fce9
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualPCIController@7493027e
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualSIOController@29014c9b
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualKeyboard@10a7d2e8
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualPointingDevice@14ff7d33
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualMachineVideoCard@1e8c534b
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualMachineVMCIDevice@316cd1d2
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualLsiLogicSASController@7c475547
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualDisk@50cec4fa
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualDisk@62df90dc
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualDisk@613eec82
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualDisk@583fca63
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualCdrom@24481db3
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualVmxnet3@59909d6e
Nov 24, 2015 12:31:39 UTC HARDWARE:com.vmware.vim25.VirtualFloppy@6fc243e5
Nov 24, 2015 12:31:39 UTC Inside if
Nov 24, 2015 12:31:39 UTC Task #1 (Upgrade or Install VMware tools (custom_Install Or Upgrade VM Tool custom task)) completed successfully in 4 seconds
Nov 24, 2015 12:31:39 UTC Input/Output values for Task #1 (Upgrade or Install VMware tools (custom_Install Or Upgrade VM Tool custom task)):
Nov 24, 2015 12:31:39 UTC [Mapped Input: Vmid = 1809]
Nov 24, 2015 12:31:39 UTC Completed workflow item number 1, with status Completed
Nov 24, 2015 12:31:43 UTC Executing workflow item number 3
Nov 24, 2015 12:31:43 UTC Completed workflow item number 2, with status Completed
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: