Well my hope is that you have already read through the Enabling the Event Broker that was posted in January. Then were thirsty for more and more around the Event broker. If you recall, in that post we covered the basics of consuming the payload from vRA 7 and utilize it just like we did the “Workflow Template” that used to exist in the 6.* days of vRA.
In the days since Enabling the Event Broker was posted I’ve built out some really powerful use cases as you can see by reviewing other more advanced Event Broker postings like Due to high demand, here’s the combined AAA deployment!, and New disk on a new SCSI adapter at request time. The issue is that it came to my attention by comments and customer meetings that I shouldn’t just be building out great use cases but enabling vRO template based examples.
So here we are with part 2 and in this post we will focus on Adding or Updating properties as the example. I will assume that you have followed the Enabling the Event Broker which will have your property groups already built out to pass all of the needed properties from vRA to vRO.
As I frequently do, if you want to follow along via video feel free to view this
***Note – You will notice there has been a bit of a change to my folder structure due to some standardization internally. Basically the team and I have decided that between us “Experts” (I use that term loosely) we will all build our content in a standardized layout so when you use stuff from Daily Hypervisor or VMtoCloud that you will have the same layout and limited reproduction of content.
While you can still use the examples from the original post you will likely get more out of the package I’ve posted here or here!
Then import into vRO and follow along step by step.
First let’s look at what’s included in the package you’ve downloaded.
Expand out the VMware -> SDE-SET -> Common -> vRealize Automation folder. In there you’ll find the folder we are going to base this post on. Expand Property Examples and the workflows you need for examples are all in this folder.
If we review the Add or Update properties for vRA example you’ll see the standard scriptable task which pulls in the payload (properties) and logs those. There are also 3 lines added to the end of that and an output of virtualMachineAddOrUpdateProperties with a type of properties. The benefit of this is that you can pass any number of value pairs back to vRA during the Event Broker execution.
virtualMachineAddOrUpdateProperties = new Properties ();
virtualMachineAddOrUpdateProperties.put(‘VirtualMachine.Network0.Name’, ‘dvPortGroup’);
virtualMachineAddOrUpdateProperties.put(‘custom.example’, ‘just a simple example’);
Reviewing these 3 lines you can see we are defining the property, updating an existing property, and creating a new property. These should help you as a starting point.
Now that we have looked at those to understand what’s going on let’s jump into vRA and work through the subscription. Go to Administration -> Events -> Subscriptions and +New
Select Machine provisioning
Run based on conditions
All of the following
Expand Data-Lifecycle state-Lifecycle state name
Equals and I’m choosing BuildingMachine as the example but this could be used at any of the events
Expand Data-Lifecycle state-State phase
Equals and I chose POST for the example
Choose your workflow “Add or Update properties for vRA”
IMPORTANT Select Blocking this is the only way vRA will accept the output from vRO to add or update properties
Publish the subscription you just created
Now time for some verification work. Based on Enabling the Event Broker you should have a trigger on all events subscription if not repeat the steps above and make sure this is published.
This is the walk through to verify you have something collecting the payload at every event
Run on all events
Get properties (don’t worry it’s just logging so we can verify the add or update worked)
Doesn’t need to block, but make sure it’s PUBLISHED
Now all you need to do is put the request for your catalog item in and let’s look at the workflows as they execute.
First we look at the event on request and notice there are no custom.example
And our VirtualMachine.Network0.Name is set to VM Network
When our Add or Update is kicked off we can see it successfully ran
Now let’s look at the logs collected after the Add or Update was run
Notice we now have a custom.example (Which was created)
And our VirtualMachine.Network0.Name is set to dvPortGroup
I chose these very specifically to illustrate something that you likely have or could use in your environment but mostly I wanted to provide you with a sampling of what you can accomplish and how much easier it is than the good ole days of v.6
Having completed this and previously completed the Enabling the Event Broker you should now be able to collect and update any of the custom properties in vRA 7 using the Event Broker!
As always please let me know any feedback, thoughts, concerns, or kudos.
23 comments
1 ping
Skip to comment form
Hey Gary, has anyone mentioned any issues around downloading the sdeset package? When importing it, I get an “invalid block type” error in vRO. Thanks!
Tested on 7.01, what version are you running?
Should be 7.0.1 as it’s the one nested in our vRA 7.0.1
Do me a favor and try this one. I think it may be an issue with sample exchange.
https://www.dropbox.com/s/rngu9tzl93gogjm/com.vmware.sdeset.vra.workflowTemplates.package?dl=0
Can you try this package? I believe we may have an issue with developer center. https://www.dropbox.com/s/rngu9tzl93gogjm/com.vmware.sdeset.vra.workflowTemplates.package?dl=0
That one worked as expected, thanks!
Hello, I trying to used this method to rename the VM Name at the Pre BuildMachine Phase whit a custom name generated by a name generator from a web App REst API Call.
Using this the methode list bellow:
virtualMachineAddOrUpdateProperties = new Properties ();
virtualMachineAddOrUpdateProperties.put(“Name”, VMNewName);
is the new name generated by the web app Rest API Call workflow result.
This not seams to be working because I cannot see the VM Name change wen deploy and part of the Item list.
Do you have any idea what I missing ?
Based on my testing you can only do this at Requested Post. That should work for you as long as you have the subscription set to block
Wow that work as you said. Now I was strungleling for week trying to figured this out.
Very appreciate you help on this.
Regards,
I’m very glad these have helped you over come any learning challenges you may have been having. Stay tuned for even more content my friend!
Gary, have you seen it where the payload isn’t even passed to the workflow?
Typically that is due to the custom property not being assigned to the blueprint. Make sure the appropriate property is assigned for your state change.
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.BuildingMachine
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Disposing
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineActivated
Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.UnprovisionMachine
We have both the custom property and the *.Requested in place. What’s odd is we can choose between two different workflows to run in the event; one receives a payload and the other does not.
More than willing to jump on a webex with you if you’d like to demonstrate the behavior. That said is this 7.0.1 fresh install or upgrade? Are both blocking tasks? Can you disable the one that’s successfully running now and see if the one not working will pull the payload?
Gary,
Is there a particular state requirements for updating any of the “__” hidden properties? I am trying to add some data to the __Notes field and it does not seem to be working at MachineProvisioned PRE or POST. I am able to update and create standard custom properties though. Any suggestions?
Skraack, Not sure what you’re running into. I just tested in my environment and at Requested and phase of PRE I just set the __Notes as expected.
Here’s the vRO code I used
virtualMachineAddOrUpdateProperties = new Properties ();
virtualMachineAddOrUpdateProperties.put(‘__Notes’, ‘Test’);
Make sure your subscription is blocking
Trying to do it in a later state when I have more data. Requested is too early in the process.
Now I see what is happening. I am trying to update the VM Description field and I assumed that the __Notes was it, but it looks like Description is a copy of __Notes. I guess I will have to update the vCAC entity to get the description to update in VRA. Thought there might be a shortcut there, but I guess not.
If you’re attempting to update the description of the actual deployment then that may be a bit of a challenge. I’m not sure that the vCAC entity will even do it. Since the Event Broker doesn’t allow for any interaction at the deployment level I have only seen that updated via an API call. Take a look at http://dailyhypervisor.com/vrealize-automation-custom-hostnaming-extension/ for the example to jump off of.
virtualMachineAddOrUpdateProperties.put(‘VirtualMachine.Network0.ProfileName’
can this be sent back to VRA? cant grab the profile
Yes you can force settings back to vRA simply by making the event blocking and having the vRO workflow set a properties output. Take a look at this much older video as the example. http://screencast-o-matic.com/watch/coX2nOhDqD
Hi Gary,
I am unable to retrieve _number_of_instances payload property value, if I set deployment limit to 1 or set it to any maximum number it will fail to retrieve instance value. If I remove value from deployment limit as blank, then I am able to get properties value for _number_of_instances. Could you please let me know how can I retrieve value if I set deployment limit.
Thanks & Regards,
Suresh
Author
Suresh, Sadly I believe this is a bug that you will want to open a ticket with VMware.
[…] Check out part 2 […]