I have my custom emails setup using the event broker thanks to gary coburn at extending clouds. While these work and look beautiful. I need to add machine costs into one of the emails that I have set up to send out, to initiate charge back.
Using his code for "Event Broker Get Custom Properties Example" I can see the data I need to reference is there "__DailyCost : {"type":"moneyTimeRate","cost":{"type":"money","currencyCode":"USD","amount":138.3684},"basis":{"type":"timeSpan","unit":4,"amount":1}}"
However I am at a loss on how to add that to my Workflow. I have successfully added Custom Properties such as "Cost Center" and can get that data into my email.
A VMware contact of mine sent me a workflow he designed that should work, it runs without error however it does not return the correct machine Cost information. No matter what vRB shows for the machine costs it always returns 0.0;
[2016-12-05 14:11:05.634] [I] dailyCost: DynamicWrapper (Instance) : [vCACCAFEDecimalLiteral]-[class com.vmware.vcac.platform.content.literals.DecimalLiteral] -- VALUE : 0.0
[2016-12-05 14:11:05.636] [I] Yearly Cost: 0
Here is the workflow I was given. I had to create a configuration element which is referenced in the workflow “Send Customization Activation Email”, I also had to setup the vCACCAFEHosts attribute as an array of vCACCAFE:vCACHost objects.
His notes on the workflow state;
"One more thing to note on the configuration element – the vCACCAFEHosts attribute is an array of vCACCAFE:vCACHost objects. These are the vRealize Automation servers configured with the vRA plugin in vRO:
There is usually one per tenant. My workflow needs a list of all these objects which you would like to search for resources that got provisioned as a result of the request. The reason for this is because the MachineDailyCost information is stored in the provider side of things. In order to match the resource to the provider ID, I had to code it to query all catalog resources, match the provider ID, and then grab the daily cost info. This means that all possible tenants where the resource could be provisioned into need to be added to this array in the configuration element so the code will iterate over all of them. If you only have one, that’s fine, but I wanted to make sure the bases were covered in case you have more than one tenant.
Yearly cost is calculated as daily cost * 365, thus on leap years, a day will be missing."
So does anyone have any suggestions? P.S. I am aware of Customizing email templates in vRA 7.x (2147429) | VMware KB and can get the machine cost data into a email using the templates. However, this solution present issues of it's own that I prefer not to have to work around if I can get my preferred method working. I welcome all input and appreciate the help.