Overview
In this how to, we will cover off how to create an EBS that will run on VM update allowing you to change your state of the CI in your SNOW CMDB when it is expired. We will update your Snow Configuration in vRA with an IF statement that will either leave the VM as ON or change the state to a state you desire.
Considerations
- Have your desired state for expire configured in SNOW against the cmdb_ci_vmware_instance table for the state field, else , select a default option:
- Have vRA configured and working with your SNOW CMDB
Procedure
Create an EBS Subscription
- In vRA , click on Administration (1) → Events (2) → Subscriptions (3)
- Click on New
- Select Machine Lifecycle (1) and click Next (2)
- Change the radio button to Run based on conditions
- Set the next dropdown as All of the following and add the lifecycle states as per the next image then click Next
- On the next page, Drop down Orchestartor → SovLabs → ServiceNow → CMDB → ServiceNow CMDB machineReconfigure then click Next
- Provide a name for the new EBS , no need to set as blocking
NOTE: Do not prefix your new EBS with SovLabs_ else on upgrade it may be removed - Click on Finish
- Don't forget to publish your EBS else it will never trigger
Update your SovLabs ServiceNow CMDB
- Under Deployments (1) filter compnents by SovLabs ServiceNow CMDB (2)
- Locate the CMDB item you wish to change and click Actions (1) → Update ServiceNow CMDB Configuration (2)
You will update the section named cmdb_ci_vmware_instance table with the operation of update. Amend your state
FROM:{ "table" : "cmdb_ci_vmware_instance", "operation" : "update", "template" : { "name" : "{{virtualMachineName}}", "state" : "On", "cpus" : "{{VirtualMachine.CPU.Count}}", "memory" : "{{VirtualMachine.Memory.Size}}", "disks_size" : "{{VirtualMachine.Admin.TotalDiskUsage}}", "vm_instance_uuid" : "{{VirtualMachine.Admin.UUID}}", "dns_domain" : "{{PrimaryDnsDomain}}", "fqdn" : "{{Hostname}}.{{PrimaryDnsDomain}}", "ip_address" : "{{VirtualMachine.Network0.Address}}" } }
TO:{ "table" : "cmdb_ci_vmware_instance", "operation" : "update", "template" : { "name" : "{{virtualMachineName}}", "state" : "{% if SovLabs_Lifecycle_State == 'Expired'%}Expired{% else %}On{% endif %}", "cpus" : "{{VirtualMachine.CPU.Count}}", "memory" : "{{VirtualMachine.Memory.Size}}", "disks_size" : "{{VirtualMachine.Admin.TotalDiskUsage}}", "vm_instance_uuid" : "{{VirtualMachine.Admin.UUID}}", "dns_domain" : "{{PrimaryDnsDomain}}", "fqdn" : "{{Hostname}}.{{PrimaryDnsDomain}}", "ip_address" : "{{VirtualMachine.Network0.Address}}" } }
Notice that we are updating the state of the VM. So if we expire a VM it will update the state appropraitely.
NOTE: I have added Expired as a state value in my CMDB. Thus I can set the VM State as Expired. This is not a default option- Click on Submit
- Make this same change to other configurations as required
- Now you can deploy a VM.. When it expires it should update the VM with the value you have set.. For me, it is sets the VM State to Expired
Additional information
SovLabs CMDB Module : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/modules/service-mgmt/servicenow-cmdb/
Template Engine : http://docs.sovlabs.com/latest/vmware-vra7x-plugin/framework/sovlabs-template-engine/basics/intro/
0 Comments