vCenter vMotion / VmMigratedEvent does not update the relation between the guest server of the vmware instance and ESX server


When a vCenter vMotion / VmMigratedEvent is received on the instance, the "Registered on::Has registered" relation between cmdb_ci_vm_instance and cmdb_ci_esx_server is updated.

However, the "Virtualizes::Virtualized by" relation between the guest server (cmdb_ci_win_server or cmdb_ci_linux_server) and the esx server is not updated.

This relation between guest server and esx server is updated when running discovery to the vCenter system.

Steps to Reproduce

1. Set up the vCenter event collector

2. Run discovery to the vCenter

3. Confirm the cmdb_ci_vm_instance records / guest servers / esx servers are created

4. Generate a vMotion event

5. Check the relations on cmdb_ci_vm_instance to esx server

6. Check the relations on its guest (that has Instantiates::Instantiated by to the vm instance) to esx server


This problem has been fixed. If you are able to upgrade, review the Fixed In section to determine the latest version with a permanent fix your instance can be upgraded to.

If an upgrade is not possible, you can use the below workaround. Note, once an out of box script is changed, it will be skipped during platform upgrade, then you can either manually revert it to OOB after the upgrade, or force it to be overwritten during the upgrade.

Open the Script Include "VCenterVmStateUpdater" and locate the code section:

[code]<pre><code>function updateRelationship(vmGen, otherGen, otherMorid, otherTable, relName) {<br/> var otherGr = new GlideRecord(otherTable);<br/> otherGr.addQuery('vcenter_uuid', vCenterInstanceUuid);<br/> otherGr.addQuery('object_id', otherMorid);<br/> otherGr.query();<br/> if (otherGr.getRowCount() != 1)<br/> return 'Expected 1 but found ' + otherGr.getRowCount() + ' records for ' + otherTable + ' for vCenter ' + vCenterInstanceUuid + ', object_id ' + otherMorid;<br/>;<br/></code></pre>[/code]

Add the section listed below right after the above script:

[code]<pre><code> //SNC workaround for CS4398559<br/> if(otherTable == 'cmdb_ci_esx_server') {<br/> var guestRel = new GlideRecord('cmdb_rel_ci');<br/> guestRel.addQuery('','Instantiates::Instantiated by');<br/> guestRel.addQuery('child',gr.sys_id);<br/> guestRel.query();<br/><br/> if (guestRel.getRowCount() == 1) {<br/>;<br/><br/> var guestESXRel = new GlideRecord('cmdb_rel_ci');<br/><br/> guestESXRel.addQuery('','Virtualized by::Virtualizes');<br/> guestESXRel.addQuery('child.sys_class_name','cmdb_ci_esx_server');<br/> guestESXRel.addQuery('parent',guestRel.parent.sys_id);<br/> guestESXRel.query();<br/><br/> if (guestRel.getRowCount() == 1) {<br/>;<br/> guestESXRel.child = otherGr.sys_id; <br/> guestESXRel.update();<br/> }<br/> }<br/> }<br/></code></pre>[/code]

After this added script block, the next lines in the existing script should be:
var relGr = new GlideRecord('cmdb_rel_ci');
relGr.addQuery('', relName);

Related Problem: PRB1371500