VMware Cloud Community
SteskaljGE
Enthusiast
Enthusiast
Jump to solution

Update IP address of a vm through vRO

I am trying to update the IP address of a VM through vRO. When I attempt to use the function updateVCACEntity I get a Java null pointer error.

Here is the action I am using to update the IP address:

System.log(workflow.currentWorkflow.name+": Updating VirtualMachine IP Address to '" + IPAddress + "'.");

//Get the properties of the vCAC VM Entity object (different than vCAC custom properties)
var vmEntityProps = virtualMachineEntity.getProperties();

for each( var Prop in vmEntityProps)
{
System.log(Prop);
}


//Change the VirtualMachine.Network0.Address property by deleting it and re-adding it
vmEntityProps.remove('VirtualMachine.Network0.Address');
vmEntityProps.put('VirtualMachine.Network0.Address', IPAddress);

//Update the Entity object to save the change
var hostId = virtualMachineEntity.hostId;
var modelName = virtualMachineEntity.modelName;
var entitySetName = virtualMachineEntity.entitySetName;
var entityIdString = virtualMachineEntity.keyString;
var actionResult = System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,vmEntityProps,null,null);

System.log(workflow.currentWorkflow.name+": Update of VirtualMachine.Network0.Address finished.");

return actionResult;

Reply
0 Kudos
1 Solution

Accepted Solutions
eoinbyrne
Expert
Expert
Jump to solution

OK, makes more sense now.

I think the problem is in the use of this action

var actionResult = System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,vmEntityProps,null,null);

You're passing nulls there for the last two parameters and I can remember having trouble with that action in the past when using nulls for Links and Headers. If all you want to do is change the network IP property you can use this action which is in the same package

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity()

pastedImage_0.png

However, I think it is actually better to use the EventBroker to update properties as it's even simpler

pastedImage_1.png

Add an output to your EBS workflow as shown, then in your workflow/action code just write the new IP property to that variable and when your workflow exits the EBS will update your entity for you. This is a lot simpler and also gets around the issues of

- locking

- existence of the entity

- etc

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

Reply
0 Kudos
3 Replies
eoinbyrne
Expert
Expert
Jump to solution

You don't specify here so I need to ask - is this workflow running as an EventBroker Subscription during vRA provisioning?

Also, it would be helpful to include the log messages for the workflow

Reply
0 Kudos
SteskaljGE
Enthusiast
Enthusiast
Jump to solution

I've attached a package of the actions and the vRO workflow.

I am using an event subscription:

event_subscription.png

Here are the conditions:

conditions.png

Here are the properties I have enabled for the tenant:

properties.png

Here is the full error I get in vRO:

[2019-09-17 15:13:37.056] [I] Set_IP: Updating VirtualMachine IP Address to '10.141.144.32'.

[2019-09-17 15:13:37.058] [I] 0

[2019-09-17 15:13:37.061] [I] false

[2019-09-17 15:13:37.063] [I] false

[2019-09-17 15:13:37.066] [I] 80

[2019-09-17 15:13:37.068] [I] On

[2019-09-17 15:13:37.070] [I] false

[2019-09-17 15:13:37.071] [I] Tue Sep 17 2019 14:26:50 GMT-0000 (UTC)

[2019-09-17 15:13:37.074] [I] Tue Sep 17 2019 14:23:26 GMT-0000 (UTC)

[2019-09-17 15:13:37.077] [I] 675459a4-c3c0-4085-b43b-653d390e1def

[2019-09-17 15:13:37.079] [I] true

[2019-09-17 15:13:37.081] [I] 0

[2019-09-17 15:13:37.084] [I] 16796e8b-c2bf-4247-b5af-df94a2318722

[2019-09-17 15:13:37.086] [I] 0

[2019-09-17 15:13:37.088] [I] false

[2019-09-17 15:13:37.090] [I] ALP-Tst-Windows Server 2016

[2019-09-17 15:13:37.093] [I] 0

[2019-09-17 15:13:37.095] [I] windows9Server64Guest

[2019-09-17 15:13:37.097] [I] vm-427804

[2019-09-17 15:13:37.100] [I] 1

[2019-09-17 15:13:37.102] [I] false

[2019-09-17 15:13:37.104] [I] vsanDatastore

[2019-09-17 15:13:37.106] [I] false

[2019-09-17 15:13:37.108] [I] Microsoft Windows Server 2016 (64-bit)

[2019-09-17 15:13:37.111] [I] ALPCTS000001299

[2019-09-17 15:13:37.113] [I] false

[2019-09-17 15:13:37.115] [I] true

[2019-09-17 15:13:37.117] [I] 32

[2019-09-17 15:13:37.120] [I] On

[2019-09-17 15:13:37.123] [I] VM

[2019-09-17 15:13:37.125] [I] Provisioned by VMware vRA

[2019-09-17 15:13:37.128] [I] Tue Sep 17 2019 16:05:03 GMT-0000 (UTC)

[2019-09-17 15:13:37.130] [I] false

[2019-09-17 15:13:37.132] [I] 503b1027-e504-454d-4759-269ca42e9205

[2019-09-17 15:13:37.134] [I] 9647cc80-795a-4f72-a842-b45dddb80a66

[2019-09-17 15:13:37.137] [I] ALPCTS000001299.logon.ds.ge.com

[2019-09-17 15:13:37.139] [I] 2

[2019-09-17 15:13:37.141] [I] Cloned

[2019-09-17 15:13:37.145] [I] 80

[2019-09-17 15:13:37.146] [I] d7596cb2-d1f7-4d4d-97fd-00f6d1d72b71

[2019-09-17 15:13:37.147] [I] 8192

[2019-09-17 15:13:37.198] [E] Workflow execution stack:

***

item: 'Set_IP/item4', state: 'failed', business state: 'null', exception: 'java.lang.NullPointerException'

workflow: 'Set_IP' (f0609191-72ef-434b-80d4-5f7be1db496f)

|  'attribute': name=virtualMachineId type=string value=9647cc80-795a-4f72-a842-b45dddb80a66

|  'attribute': name=IPAddress type=string value=10.141.144.32

|  'attribute': name=vCACVMEntity type=vCAC:Entity value=dunes://service.dunes.ch/CustomSDKObject?id='%2528guid%25279647cc80-795a-4f72-a842-b45dddb80a66%2527%2529%25401b4c06a9-aaf0-484a-83d1-d1dbb23c6a97%2540ManagementModelEntities.svc%2540VirtualMachines'&dunesName='vCAC:Entity'

|  'attribute': name=errorCode type=string value=java.lang.NullPointerException

|  'input': name=payload type=Properties value=#[#workflow.execution.id#=#string#549dce8d-8bf7-4f1a-ab20-9873797fec1e#+#workflow.execution.endDate#=#Date#20190917102437-0400#+#lifecycleState#=#Properties##[#phase#=#string#PRE#+#state#=#string#VMPSMasterWorkflow32.BuildingMachine#]##+#componentId#=#string#VM#+#blueprintName#=#string#ALP-Tst-Windows Server 2016#+#componentTypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#IaaSTimeoutId#=#number#1373990.0#+#requestId#=#string#c3bc23ae-f4cd-4562-b050-899b51876031#+#endpointId#=#string#2d1355aa-b9dd-405f-b6ca-82f7dcc0b328#+#machine#=#Properties##[#owner#=#string#212670239@logon.ds.ge.com#+#name#=#string#ALPCTS000001299#+#id#=#string#9647cc80-795a-4f72-a842-b45dddb80a66#+#type#=#number#0.0#+#properties#=#Properties##[#VirtualMachine.Cafe.Blueprint.Id#=#string#ALPTstWindowsServer2016#+#__InterfaceType#=#string#vSphere#+#VirtualMachine.Network0.PrimaryDns#=#string#10.220.220.220#+#VirtualMachine.Network0.DnsSuffix#=#string#logon.ds.ge.com#+#__VirtualMachine.Allocation.InitialMachineState#=#string#SubmittingRequest#+#VirtualMachine.Cafe.Blueprint.Component.TypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#__api.request.id#=#string#c3bc23ae-f4cd-4562-b050-899b51876031#+#VirtualMachine.Disk0.Size#=#string#80#+#__api.request.callback.service.id#=#string#8397f792-7f46-4dfa-bfc8-332bb7f8855c#+#VirtualMachine.Cafe.Blueprint.Name#=#string#ALP-Tst-Windows Server 2016#+#Cafe.Shim.VirtualMachine.TotalStorageSize#=#string#80#+#gesso#=#string#212670239#+#__Legacy.Workflow.ImpersonatingUser#=#string##+#__Legacy.Workflow.User#=#string#212670239@logon.ds.ge.com#+#__VirtualMachine.ProvisioningWorkflowName#=#string#CloneWorkflow#+#VirtualMachine.Admin.ThinProvision#=#string#Yes#+#VirtualMachine.Network0.SubnetMask#=#string#255.255.240.0#+#VirtualMachine.Network0.SecondaryDns#=#string#10.220.220.221#+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine#=#string#*#+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned#=#string#*#+#__request_reason#=#string##+#__Cafe.Root.Request.Id#=#string#71df83e1-a5bc-4918-8c4e-3d1d34ad735d#+#__ovfAuthNeeded#=#string#False#+#_number_of_instances#=#string#1#+#VirtualMachine.Disk0.IsClone#=#string#true#+#__Cafe.Request.VM.HostnamePrefix#=#string#ALPCTS#+#__clonefromid#=#string#afb9ac75-1eb5-422e-8f70-eecacad54ca6#+#vRA.Deployment.Tags#=#string#Dev#+#__Cafe.Request.BlueprintType#=#string#1#+#VirtualMachine.Memory.Size#=#string#8192#+#VMware.VirtualCenter.Folder#=#string#vRA#+#VirtualMachine.Cafe.Blueprint.Component.Cluster.Index#=#string#0#+#VirtualMachine.CPU.Count#=#string#2#+#__Clone_Type#=#string#CloneWorkflow#+#callExternalWorkflowActivityPostWaitingToBuild#=#string#False#+#geexportcontrol#=#string#No#+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Buildingmachine#=#string#*#+#__clonespec#=#string#WIN#+#ge.location#=#string#alpcts#+#VirtualMachine.Admin.TotalDiskUsage#=#string#81920#+#VirtualMachine.Disk0.Label#=#string#Hard disk 1#+#__trace_id#=#string#oOhtyoam#+#__iaas_request_binding_id#=#string#0e5ac95b-8339-4973-8ea7-17f899242463#+#VirtualMachine.Cafe.Blueprint.Component.Id#=#string#VM#+#VirtualMachine.Network0.Address#=#string#10.141.144.28#+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.VMPSMasterWorkflow32#=#string#*#+#VirtualMachine.Disk0.Storage#=#string#vsanDatastore#+#Vrm.ProxyAgent.Uri#=#string#https://alpctsvramgr01.logon.ds.ge.com/VMPS2Proxy#+#__reservationPolicyID#=#string#9ddccfb3-42c2-4de...

|  'no outputs'

*** End of execution stack.

Reply
0 Kudos
eoinbyrne
Expert
Expert
Jump to solution

OK, makes more sense now.

I think the problem is in the use of this action

var actionResult = System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,vmEntityProps,null,null);

You're passing nulls there for the last two parameters and I can remember having trouble with that action in the past when using nulls for Links and Headers. If all you want to do is change the network IP property you can use this action which is in the same package

System.getModule("com.vmware.library.vcac").addUpdatePropertyFromVirtualMachineEntity()

pastedImage_0.png

However, I think it is actually better to use the EventBroker to update properties as it's even simpler

pastedImage_1.png

Add an output to your EBS workflow as shown, then in your workflow/action code just write the new IP property to that variable and when your workflow exits the EBS will update your entity for you. This is a lot simpler and also gets around the issues of

- locking

- existence of the entity

- etc

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

Reply
0 Kudos