VMware Cloud Community
BillStreet00
Enthusiast
Enthusiast

Update VM Network during provisioning

We purchased a new IPAM solution that doesn't have a plugin for vRA but did have a sample on how to get the next available IP in the specified range.

I am running the workflow when the request hits the VMPSMasterWorkflow32.Requested - POST state as I had read somewhere that the new IP should be procured early in the build.

My workflow reads in information from the VM being built.  Since the user can specify any network that they have access to, I use the VirtualMachine.Network0.Name property as well as getApplicableNetworks to pull in a dropdown of the subnets.

I created a function to pull in the next available IP based on the VirtualMachine.Network0.Name (which works without issue). I However, when I attempt to run this module:

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity(vCACHost,virtualMachineEntity,"VirtualMachine.Network0.Address",vmIP,isFalse,isFalse,isFalse,isFalse);

I get this error:

2017-09-08 11:17:32.486] [E] (com.vmware.library.vcac/addUpdatePropertyFromVirtualMachineEntity) Error in (Dynamic Script Module name : addUpdatePropertyFromVirtualMachineEntity#7) TypeError: Cannot find function getLink in object .

[2017-09-08 11:17:32.499] [E] Workflow execution stack:

***

item: 'MM Next Free IP/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot find function getLink in object . (Dynamic Script Module name : addUpdatePropertyFromVirtualMachineEntity#7)'

workflow: 'MM Next Free IP' (b257e143-2291-4931-b5d4-8d469297f3a8)

|  'attribute': name=vCACHost type=vCAC:VCACHost value=dunes://service.dunes.ch/CustomSDKObject?id='5eb2dab1-fad8-4ae3-b949-1e7279b7cb0a'&dunesName='vCAC:VCACHost'

|  'input': name=payload type=Properties value=#[#lifecycleState#=#Properties##[#phase#=#string#POST#+#state#=#string#VMPSMasterWorkflow32.Requested#]##+#componentId#=#string#w2k12prod#+#blueprintName#=#string#ExtensibilityWF#+#componentTypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#IaaSTimeoutId#=#number#23155.0#+#endpointId#=#string#af7a34a4-cdfa-43f3-893d-3490bab38d67#+#machine#=#Properties##[#owner#=#string#streebil@AMWINS.LOCAL#+#name#=#string#iteng0425#+#id#=#string#7b067f84-735b-4486-aac7-f749518b89eb#+#type#=#number#0.0#+#properties#=#Properties##[#VirtualMachine.Cafe.Blueprint.Id#=#string#ExtensibilityWF#+#__clonefromid#=#string#a84938bd-9b3b-459b-bb20-cff033d688f9#+#__Cafe.Request.BlueprintType#=#string#1#+#__InterfaceType#=#string#vSphere#+#VirtualMachine.Network0.PrimaryDns#=#string#10.10.116.8#+#__Notes#=#string#Stock production server.#+#VirtualMachine.Memory.Size#=#string#5120#+#VirtualMachine.Network0.DnsSuffix#=#string#amwins.local#+#VirtualMachine.Cafe.Blueprint.Component.Cluster.Index#=#string#0#+#VirtualMachine.CPU.Count#=#string#2#+#__VirtualMachine.Allocation.InitialMachineState#=#string#SubmittingRequest#+#__Clone_Type#=#string#CloneWorkflow#+#VirtualMachine.Cafe.Blueprint.Component.TypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#__api.request.id#=#string#40f6e431-4a2f-4673-b49f-d2033f15f18d#+#__clonespec#=#string#vra#+#VirtualMachine.Disk0.Size#=#string#60#+#VirtualMachine.Admin.TotalDiskUsage#=#string#61440#+#VirtualMachine.Disk0.Label#=#string#Hard disk 1#+#__api.request.callback.service.id#=#string#1b0b4846-3f70-4526-b45b-51fd21912622#+#__DailyCost#=#string#{"type":"moneyTimeRate","cost":{"type":"money","currencyCode":"USD","amount":0.0},"basis":{"type":"timeSpan","unit":4,"amount":1}}#+#__trace_id#=#string#h35U3OR6#+#VirtualMachine.Cafe.Blueprint.Name#=#string#ExtensibilityWF#+#__iaas_request_binding_id#=#string#0352ddb3-4faa-4486-baa6-6bee35c71868#+#__Legacy.Workflow.ImpersonatingUser#=#string##+#__Legacy.Workflow.User#=#string#streebil@AMWINS.LOCAL#+#__VirtualMachine.ProvisioningWorkflowName#=#string#CloneWorkflow#+#VirtualMachine.Cafe.Blueprint.Component.Id#=#string#w2k12prod#+#VirtualMachine.Network0.DnsSearchSuffixes#=#string#amwins.local#+#VirtualMachine.Network0.Address#=#string#10.10.120.9#+#VirtualMachine.Network0.SubnetMask#=#string#255.255.255.0#+#VirtualMachine.Network0.SecondaryDns#=#string#10.11.116.8#+#VirtualMachine.Disk0.Storage#=#string#P10-SF-Platinum-VVOL#+#__reservationPolicyID#=#string#0a906444-1373-4d4d-ad89-af1e9ad8eb27#+#__clonefrom#=#string#2012R2_std_template_p10_vm65#+#VirtualMachine.Storage.Name#=#string#P10-SF-Platinum-VVOL#+#__Cafe.Request.VM.LeaseDays#=#string#1#+#__request_reason#=#string##+#__Cafe.Root.Request.Id#=#string#94bd5926-d78a-4b4b-9ff4-2841ff35d146#+#VirtualMachine.Network0.Gateway#=#string#10.10.120.3#+#VirtualMachine.Network0.Name#=#string#P10-10.10.119.0%2f24#+#VirtualMachine.Disk0.IsClone#=#string#true#]##]##+#requestId#=#string#40f6e431-4a2f-4673-b49f-d2033f15f18d#]#

|  'attribute': name=__asd_requestedBy type=string value=streebil@AMWINS.LOCAL

|  'attribute': name=__asd_tenantRef type=string value=vsphere.local

|  'attribute': name=__asd_targetResourceProviderTypeId type=string value=com.vmware.csp.iaas.blueprint.service

|  'attribute': name=__asd_requestInstanceId type=string value=d1c90c00-94a8-11e7-8196-b07524073a69

|  'attribute': name=__asd_requestInstanceTypeId type=string value=com.vmware.csp.iaas.blueprint.service.machine.lifecycle.provision

|  'attribute': name=__asd_catalogRequestId type=string value=4156aee9-3d04-451f-a461-717cecea6044

|  'attribute': name=__asd_requestedFor type=string value=streebil@AMWINS.LOCAL

|  'attribute': name=__asd_targetResourceId type=string value=7b067f84-735b-4486-aac7-f749518b89eb

|  'attribute': name=__asd_requestInstanceTimestamp type=string value="2017-09-08T11:17:25.000-04:00"

|  'attribute': name=__asd_targetResourceTypeId type=string value=machine

|  'attribute': name=__asd_correlationId type=string value=94bd5926-d78a-4b4b-9ff4-2841ff35d146

|  'attribute': name=__asd_requestTraceId type=string value=h35U3OR6

|  'attribute': name=__asd_targetResourceProviderId type=string value=103480de-6fab-456c-ad1b-15ff03450f69

|  'no outputs'

*** End of execution stack.

22 Replies
poorem
Enthusiast
Enthusiast

I usually run IPAM integrations during the BuildingMachine PRE state, it's still before anything is actually deployed.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

I will try that.

How are you passing the IP, subnet mask, gateway, DNS and such back to the build process?

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

We're just setting them as an output to the event broker workflow, vRA applies them back to the VM:

//Build the output object

var outputProperties = new Properties();

outputProperties.put("VirtualMachine.Network0.Address", ipAddress);

outputProperties.put("VirtualMachine.Network0.SubnetMask", subnetMask);

outputProperties.put("VirtualMachine.Network0.Gateway", defaultGateway);

virtualMachineAddOrUpdateProperties = outputProperties;

So, virtualMachineAddOrUpdateProperties is the output variable of the event broker workflow and is of type "Properties".

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

That helped immensely.  For some reason its not updating the IP address though.  I end up with a weird one like this:

pastedImage_0.png

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

That's the kind of address you get if DHCP doesn't get a response. APIPA rings a bell.

Anyway, that suggests to me that maybe something went wrong in the machine customisation. If you look at the Item in vRA, have the properties been set as expected?

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

It seems to be choking on the IP address. I'm not sure why though.  The IP address is coming in from IPAM cleanly and I can see in the workflow how its flowing through.  The WF seems to push the information to vRA, it starts to clone the new VM and then dies with this error.

The following component requests failed: w2k12prod. Request failed: Machine tested06: CustomizeVM : [CustomizeVM_Task] - A specified parameter was not correct: spec.nicSettingMap.adapter.ip.ipAddress.

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

How many NICs in your template? And how have you configured your blueprint? Sounds maybe like something is misaligned.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

Just a single NIC.  I did added an existing network but set the network profile to one I created called temp.  Temp has nothing in it.  I have a property group with the network information defined and added to the blueprint. Below is the updated properties from vRA.

var outputProperties = new Properties();

outputProperties.put("VirtualMachine.Network0.Address", vmIP);

outputProperties.put("VirtualMachine.Network0.SubnetMask", vmSubnet);

outputProperties.put("VirtualMachine.Network0.Gateway", vmGateway);

outputProperties.put("VirtualMachine.Network0.PrimaryDNS", pDNS);

outputProperties.put("VirtualMachine.Network0.SecondaryDNS", sDNS);

outputProperties.put("VirtualMachine.Network0.DnsSuffix", dnsSuffix);

outputProperties.put("VirtualMachine.Network0.Name", netName)

virtualMachineAddOrUpdateProperties = outputProperties;

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Try taking the Existing Network from the blueprint.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

I've tried that as well.

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Anything in the network settings of the component VM? We don't have any settings there:

201709251_190994-CapturFiles.png

Another question, is there any reason why you're setting Network0.Name there? I recall that you're setting it at request time.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

Nothing in the network settings at all.  I added the network name as I noticed a couple resources mentioned it.  I'm grasping at straws right now.  If I request a VM and bypass this WF it completes both with and without a network.  It's just that for some reason I am getting that error when I run this workflow.

Run the subscription event at VMPSMasterWorkflow32.BuildingMachine (PRE) and if its a VM.

Pull in the payload.

Grab my network name - var netName = vRAVmProperties.get("VirtualMachine.Network0.Name") ;

I set the primary, secondary and dns suffix.

I use the network name and run a case statement to pass the IP range to Men and Mice.

Get my IP.

Assign the gateway and subnet to variables

Drop out of the case statement

execute the property update.

The workflow is straight forward.  I am watching the logs in vRO and it completes and pulls the IP for me.  It just throws that error when updating the VM properties.

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Is your Event Subscription configured as blocking?

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

Yes. The event says that it completes successfully.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Ok. My final thought for the evening:

Create a new Customisation Specification in vCenter. Make it as simple as possible. Make sure it has default network settings (i.e. uses DHCP). Don't join it to a domain, leave it in a workgroup. Generate a new SID. Set an admin password etc.

Then update your blueprint to use that specification.

The message referencing "spec.nicSettingMap.adapter.ip" suggests that vRA might be having an issue feeding the values from the custom properties in to the Customisation Specification. I'm not certain, but it's worth a try.

Reply
0 Kudos
BillStreet00
Enthusiast
Enthusiast

No love. I get the same error even after a new customization spec.

Reply
0 Kudos
mpoorevmw
VMware Employee
VMware Employee

😞

Do you have a different template that you can try with? Also, can you confirm versions and build numbers of vRA and vSphere.

Reply
0 Kudos