So, I have setup vRA 7.2 (internal vRO) and all properties are applied including adding to the appropriate domain and OU, but I CANNOT get the extensibility to work so that I can rename either the VM name or the hostname within the VM. I kind of gave up on the lattter as I could not understand how to make some of these canned solutions work... no CLUE how to get vCAC:Entity or any of the other vCAC:<whatever> to work... so I got approval to just set the VM Name and have that propagate to the nodename... While I can pass all the variables and create the appropriate naming using the standard nomenclature, I just cannot get the name to change.
This is the code I am using:
// Retrieve the machine properties
var machine = payload.get("machine");
// Check the machine properties exists
if (machine == null) { throw "Unable to retrieve Machine Properties."; }
// Retrieve the values required
// virtualMachineID = machine.get("id");
// System.log(workflow.currentWorkflow.name+" System GUID is "+virtualMachineID)
var machineProperties = machine.get("properties");
//Read the hostname generated by vRA (TEE2-busGrp-run#)
var vmName = machine.get("name");
var len = vmName.length - 4;
System.log(workflow.currentWorkflow.name+" Current hostname is "+vmName);
// Remove the prefix part, leaving the unique ID
var uniqueID = vmName.substr(len);
// Retrieve the variables
var location = machineProperties.get("LOC.Hostname.Location");
var vmType = machineProperties.get("LOC.Hostname.Type");
var busGrp = machineProperties.get("LOC.Hostname.BusGrp");
// Build new hostname
var newHostname = (location+vmType+busGrp+uniqueID);
System.log(workflow.currentWorkflow.name+" New VM Name and Windows hostname will be "+newHostname);
// Change the VM Name along with the Windows hostname
var resultCode = payload.virtualMachineAddOrUpdateProperties.put("hostname", newHostname);
System.log(workflow.currentWorkflow.name+"Workflow OSFI Rename VM complete. "+resultCode);
Logs from the Orchestrator Run:
[2017-10-27 16:35:54.424] [I] UpdateMachineName Current hostname is TEE2-Dev-048
[2017-10-27 16:35:54.427] [I] UpdateMachineName New VM Name and Windows hostname will be CVOT-Test-dev-048
[2017-10-27 16:35:54.429] [I] UpdateMachineNameWorkflow OSFI Rename VM complete. undefined
As I said, everything gets passed through as I have the subscription setup as such:
Machine provisioning
Topic ID: com.vmware.csp.iaas.blueprint.service.machine.lifecycle.provision
Name: Machine provisioning
Description: Machine lifecycle events that are triggered during the provisioning phase
Publisher: iaas-service
Blockable: Yes
Replyable: No
Conditions:
Data > Lifecycle state > Lifecycle state name Equals VMPSMasterWorkflow32.BuildingMachine
Data > Lifecycle state > State phase Equals PRE
Data > Machine > Machine type Equals Virtual Machine
I've selected the Workflow (the script above) and it executes just fine... except that it does nothing to the VM.
I'm guessing that the undefined in the logs above means payload.virtualMachineAddOrUpdateProperties didn't run, but I have no clue why...Any suggestions?
Thanks in advance,
Roger