CMDB_CI_SERVER table location update based on discovery schedule location?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2018 06:01 AM
Hi All,
i have a requirement to update the location of the server in CMDB_CI_SERVER table w.r.to discovery schedule location.
we have OOB feature to update the location ,but for some servers location is not updating ,so we want to customize this.
1) discovery schedule has location field with one value,the same should be updated for servers in CMDB_CI_SERVER table w.r.to their IP ranges.
2) for every discovery schedule we have defined some IP ranges .the server which is present in the above tables IP range will fall in the defined range.
i have written below business rule for this .script is executing fine,but location is not populating in the CMDB_CI_SERVER table.
business rule:
function location(){
var sysID ='8d7eb7ed4f302e842967ef4f0310c789';
var serverip = new GlideRecord('cmdb_ci_server');
serverip.addQuery('sys_id',sysID);
serverip.Query();
while(serverip.next()){
var iprange = new GlideRecord('discovery_range_item');
var discsche = new GlideRecord('discovery_schedule');
if( serverip.getValue('ip_address') >= iprange.getValue('start_ip_address') && serverip.getValue('ip_address') <= iprange.getValue('end_ip_address') ){
answer = iprange.getValue('schedule');
gs.log('answer');
continue;
}
if( answer = discsche.getValue('name')){
answer2 = discsche.getValue('location');
continue;
}
if( answer2 != serverip.getValue('location')){
answer3 = answer2;
}
serverip.location= answer3;
serverip.update();
}
}
can anyone help me on this.
Thanks,
kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 04:33 AM
Hi fabiankunzke ,
thanks for your solution.
i need to execute the schedule to validate your solution as business rule. after execution location is populating as per OOB. so i am re-writing your solution as background script.
i will let you know once am done with validation.
thank you so much for your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 11:26 PM
Just my $0.02, but if you have a schedule with a defined location and you have devices that fall within the IP ranges defined in that schedule that do NOT reflect the correct location value that sounds like you should open a HI ticket and not try to come up with some workaround to correct OOB functionality.