Hi Folks,
We are able to send and receive the Email notifications for the actions we perform, but we do not see the required information in the mail. As per the vCAC 6.0 Documentation we should be able to customize the emails, but we are not sure to which files that should be modified. Can you please suggest us which files to be modified that is integrated with the email configuration.
Regards,
SK
No official documentation, examples or support that I am aware. However, the emails in vCAC 6.0 are defined using velocity templates (http://velocity.apache.org). You can find them in the VCAC VA tc-server deployment for the notification service located at: /usr/lib/vcac/server/webapps/notification-service/WEB-INF/classes/templates/email You might review them with html/core/main.vm being the starting point and figure out if you can modify them to achieve the desired result. Changes will take effect after tc-server restart (/etc/init.d/vcac-server restart) Note: This is not going to be supported and any customization will need to be redone after an eventual upgrade. It might be fine for something quick and small but not recommended for something more.
Ok, a bit more details. You don't need to restart the tc-server after modifications. Based on the properties, the changes should be refreshed in 120 seconds.
Also, You might be able to override some of the templates in a dedicated outside folder by first modifying the velocity template properties located at:
/usr/lib/vcac/server/webapps/notification-service/WEB-INF/classes/velocity/velocity-email-html.properties
You need to add the template loading from a file option so that the velocity-email-html.properties looks like that:
------------------------
#template resolution, check files system, then classpath
resource.loader = file, class
# loads templates from file system
file.resource.loader.description = Locale and Tenant Aware File Resource Loader
file.resource.loader.class = com.vmware.vcac.notification.templates.LocaleAndTenantAwareFileResourceLoader
file.resource.loader.cache = true
file.resource.loader.path = /vcac/templates/email/html
# in seconds, 2 minutes = 2 * 60
file.resource.loader.modificationCheckInterval = 120
# loads templates from classpath
class.resource.loader.description = Locale Aware Classpath Resource Loader
class.resource.loader.class = com.vmware.vcac.notification.templates.LocaleAwareClasspathResourceLoader
class.resource.loader.cache = true
class.resource.loader.path = /templates/email/html
# in seconds, 2 minutes = 2 * 60
class.resource.loader.modificationCheckInterval = 120
eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeHtmlReference
eventhandler.escape.html.match = /(link.*)|(branding.*)|(.*Content.*)|(.*[vV]alue.*)|(.*[lL]abel.*)|(.*[sS]pan.*)/
------------
Note: the property file.resource.loader.path = /vcac/templates/email/html should point to where you want to keep your customized templates (with the same folder structure and names) as the original ones.
Now, to override some templates they need to be in the same folder structure and have the same name but there is also a support for locale specific and tenant specific templates.
For example, to override the template located at /templates/email/html/core/footer.vm (which is the footer of an email) , you need to create a copy in:
/vcac/templates/email/html/defaults/core/footer.vm (pay attention to adding the /default/ folder. This is to override for all tenants and locales).
To override it only for a given locale:
/vcac/templates/email/html/defaults/de/core/footer.vm
To override it only for a given tenant (tenantA)
/vcac/templates/email/html/tenantA/core/footer.vm
To override it only for a given tenant (tenantA) and locale (de)
/vcac/templates/email/html/tenantA/de/core/footer.vm
Hi Igor,
could you elaborate on editing the templates please?
I've edited the /usr/lib/vcac/server/webapps/notification-service/WEB-INF/classes/templates/email/html/extensions/csp.places.iaas.forms.vm file and inserted some additional text first, just to see if it was working. The change was visible only after restarting the tcserver. Now what should I do, if I want for example to include the name of the vm in the email? I've tried to add an additional variable with
#set ($name = "#valueOf('VirtualMachine.Admin.Name')")
and call it later using:
#notEmpty ($name)
<tr class="layoutRow">
<td class="layoutField">
<div class="label">VM NAME</div>
<div class="value">$name</div>
</td>
</tr>
#end
but this won't display the needed info. How can I get the name value (or any other value describing a vm) from vcac?
Thanks in advance for any help!
EDIT: It seems that the restart is only required if you edit the default templates, addign new ones is discovered automatically within the defautl 120s intervals.
What are these templates using when they call #valueOf? Are those specific parameters passed to the template or are they a data structures of some sort that have other accessible parameters?
Per support, the only email templates that can be modified are those listed in the Systems Administrators guide. All others cannot be modified at this time.
I was able to get cost working someone correctly as well as include my own custom properties in the email template. However, there seem to be a lot of inconsistencies in what properties you have access to. As Czernobog noted above, VirtualMachine.Admin.Name does not work. If fact I can't seem to get that property to work anywhere in 6.0.1 but thats a different story. It appears that the template has access to the same properties that Orchestrator does but not all. I was trying to use VirtualMachine.Network0.Address to create some relationship between the provisioned machine and a post approval but no value was returned by that property. igorstoyanov, do you have a list of properties that are accessible by the templates? It is incredibly crippling that the whole notification method was changed on a minor rev and no documentation is provided.
I've summarized my findings in a blog post. http://willonit.blogspot.com/2014/07/on-vcac-velocity-templates.html
I now have Name and Cost showing properly in my notifications.
I've updated the blog post. It seems that anything property that is set after the request is made is not available to be used in the email templates. Example, anything included in a network profile, any properties from a reservation or compute resource, name, or anything set by orchestrator stub workflow.
I hope these templates are fixed soon.