- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:30 AM
Hello team,
As an ITOM developer, I want to reroute the VM CI's based on naming convention, under mid server script includes the following "VMWAREvCenterVMsProbe" creates virtual machines which then goes into cmdb_ci_vmware_instance upon discovery of vCenter's. If possible any virtual machine that begin with "USX" or "USZ we would like to have routed to the cmdb_ci_virtual_desktop table upon discovery, all others would remain in the same table. All CI's that starts with USX or USZ would be automatically moved to cmdb_ci_virtual_desktop upon discovery.
Should I enable plugin for above requirement?
Would you please correct the steps and scripts below, if it is wrong. I am grateful to your response.
var vmName = current.name.toString();
if (vmName.startsWith("USX") || vmName.startsWith("USZ")) {
// Create a new record in cmdb_ci_virtual_desktop table and copy over relevant information
var newDesktop = new GlideRecord('cmdb_ci_virtual_desktop');
newDesktop.initialize();
newDesktop.name = current.name;
newDesktop.description = current.description;
newDesktop.os = current.os;
newDesktop.ip_address = current.ip_address;
newDesktop.mac_address = current.mac_address;
// ... copy over other relevant fields
newDesktop.insert();
}
to modify the "process" function in the "VMWarevCenterVMsProbe" script include to include the logic I described earlier:
process: function(vm) {
// Call the parent process function to do the standard processing
this.parent.process(vm);
// Check if the VM name starts with "USX" or "USZ"
var vmName = vm.name.toString();
if (vmName.startsWith("USX") || vmName.startsWith("USZ")) {
// Create a new record in cmdb_ci_virtual_desktop table and copy over relevant information
var newDesktop = new GlideRecord('cmdb_ci_virtual_desktop');
newDesktop.initialize();
newDesktop.name = vm.name;
newDesktop.description = vm.description;
newDesktop.os = vm.os;
newDesktop.ip_address = vm.ip_address;
newDesktop.mac_address = vm.mac_address;
// ... copy over other relevant fields
newDesktop.insert();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 05:39 AM
Hi,
Looks good to me but please test it out in a non-prod environment to be sure.
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 07:47 AM
Hi,
Classification in CMDB is done per "type of device". Each classification has it's own table. Meaning CIs in cmdb_ci_vmware_instance are not the same type of CIs as CIs in cmdb_ci_virtual_desktop. You should not base your classification on the name of the device but something that can properly identify the correct class.
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 09:17 AM
Hi Niklas,
Thank you so much for the swift response and taking the time to acknowledge upon my request.
I agree your point, but the actual problem is that virtual machines CIs are goes into cmdb_ci_vmware_instance (which is a wrong table "cmdb_ci_vmware_instance") instead of "cmdb_ci_virtual_desktop" upon discovery of VCenter's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 12:58 PM
Hello again,
In what way is the VMware Virtual Machine Instance [cmdb_ci_vmware_instance] the wrong table for Virtual Machine instances?
Here is the reference documentation for VMware discovery and all the classes that is populated.
https://docs.servicenow.com/bundle/utah-it-operations-management/page/product/discovery/reference/r_...
The cmdb_ci_virtual_desktop table is for "User's desktop environment (such as icons, wallpaper, windows, folders, toolbars, and widgets) is stored remotely on a server."
https://docs.servicenow.com/bundle/utah-servicenow-platform/page/product/configuration-management/re...
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 01:59 AM
Hi Niklas,
the correct table is for virtual machine CIs is "cmdb_ci_vmware_instance", the issue is that in the dev environment our virtual desktops which start with USZ & USX also go into that same table, they need to go into the "cmdb_ci_virtual_desktop" table. This has to be fixed.
Would you please provide a solution?
Regards
Karthikeyan Palaniyappan