SovLabs Support

Submit a Ticket My Tickets
Welcome
Login

Notifications: Add detail / make detail dynamic in your email

Overview

Sometimes we would like / need more information to come through on the notifications instead of the default information SovLabs provides.  This KB will provide some insight into how you can amend the notification body to include additional information based on your requirements.  


We will also cover how notifications can utilize the SovLabs Template Engine to dynamically update your notifications.


Considerations


Scenarios

Scenario 1

You have been asked to add the vCPU count to a notification.


Scenario 2

You have been asked to update / create a notification that will suit singular and multi NIC vm's but your manager wants the second NIC to only show up in the notification if a second NIC exists on the VM, else, it should not be mentioned in the notification.


Procedure

I will assume you have already selected your "Add Notification Configuration - SovLabs module" opened from your catalog and have provided the configuration information required.  I will only be providing steps on how to update the body of the notification email.


Common Steps 

These are the same steps to be used to start your notification changes.

  1. In your notification, copy out the text from the "Body" area
  2. Using a text editor (Such as Notepad++) paste the text into a new document
  3. The section we will modify will reside in the <tr> tags </tr>

  4. You will see in the section the Machine, Blueprint, IP Address and Network name already exists.  We will add a line in here to provide the extra information you need.
  5. Copy one of these lines and paste it below the line you copied. In this example I have copied the Network Name line


    1. The code you are copying is in the example below

      1. The first value you change is Network name.  This will be the left field and is static. This is name given for the value or information you are presenting
      2. The second value is templated to gather information from your VM.
      3. <tr><th style="text-align: left;">Network name:</th><td>{{ VirtualMachine.Network0.Name }}</td></tr>


Scenario 1

In this example I will be adding the vCPU count for the VM being deployed

  1. Follow the common steps outline under "Common Steps"
    1. In the newly created line, replace "Network name:" with the name of the field you want to display in your notification. In this example, we will add the number of vCPU assigned to the VM

      1. Example of changing the Network name to vCPU Count code is below

        <tr><th style="text-align: left;">vCPU Count:</th><td>{{ VirtualMachine.Network0.Name }}</td></tr>


    2. Now you will need to replace the {{ VirtualMachine.Network0.Name }} value with the payload property for vCPU (This information is from vRO, you can check a previous run of a machine to gather payload information). In this instance it is iaasProperties.VMCPUs

      1. Example of changing the  VirtualMachine.Network0.Name to iaasProperties.VMCPUs. This would be the final state of the code to gather the vCPU of your machine

        <tr><th style="text-align: left;">vCPU Count:</th><td>{{ iaasProperties.VMCPUs }}</td></tr>


    3. Copy all of the text you have in your text editor and replace all the text in the "Body" field of your notification, you should now see the extra line for vCPU Count you added

    4. Finish configuring your notification and configure it for use on the nominated blueprint
    5. When the notification is triggered, you should see the vCPU count in your notification



Scenario 2

In this use case, I will be using the template engine IF statement to display a second network cards IP address based on a boolean (true/false) value from your blueprint. This example is based off "adding multiple NICs dynamically to your blueprint".


  1. Follow the common steps outline under "Common Steps"
    1. In the newly created line, replace "Network name:" with the name of the field you want to display in your notification. In this example, we will add NIC1 IPAddress

    2. Now you will need to replace the {{ VirtualMachine.Network0.Name }} value with the payload property for NIC1 (This information is from vRO, you can check a previous run of a machine to gather payload information). In this instance it is VirtualMachine.Network1.Address.

    3. If you left your Body text as above, it would add the line to every notification even if there was no NIC1.  
    4. We want to utilize our template engine to build an IF statement that checks against the true/false statement we have on our blueprint.  In this example, I have a property called AddNIC1.
      1. See IF/Else template engine syntax http://docs.sovlabs.com/latest/vRA/7.5/framework/sovlabs-template-engine/tags/if-else/
    5. To start with, we will build the first part of the if statement, this will be saying "if my property is saying it is true"
      1. {% if AddNIC1 == 'true' %}



    6. Since we are asking for a true statement, we want it to write out the IP address for the additional network card.  So lets add the <tr> line behind the if statement.  This will now be saying "If my property is true, then lets write this line into the notification"
      1. {% if AddNIC1 == 'true' %}<tr><th style="text-align: left;">IP Address (NIC1):</th><td>{{ VirtualMachine.Network1.Address }}</td></tr>


    7. Now, since we don't want to write anything in the notification if our property is false, we can close this if statement, so lets add an end if. 
      1. {% if AddNIC1 == 'true' %}<tr><th style="text-align: left;">IP Address (NIC1):</th><td>{{ VirtualMachine.Network1.Address }}</td></tr>{% endif %}


    8. Now you have an if statement that will check your property for a true or false, if it is validating as true, it will write out the IP address information of your additional network card, but, if it validates to false, no extra information will be added to your blueprint.
    9. Copy all of the text you have in your text editor and replace all the text in the "Body" field of your notification, you should now see the extra line for for your newly created if statement

    10. Finish configuring your notification and configure it for use on the nominated blueprint
    11. When the notification is triggered, and you have setup your dynamic NIC blueprint, you should see the Extra NICS IP Address

    12. If no additional NIC is add, the notification will not display any additional information



Additional information


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.