Setting "Location" of a CI via the Location in Discovery Schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2010 02:57 PM
I am trying to make use of the "Location" field in a Discovery Schedule to set the "Location" of any discovered CI. It seems to work for some but not others.
Is there documentation somewhere on this feature? I haven't tripped over any yet.
cheers,
robin850
- Labels:
-
Discovery
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2018 05:57 AM
Hi all,
am new to service now.please accept my apologies if there is anything wrong in the code.
i have the similar requirement,based on my understanding i have written the below code. but it is not giving the expected output. can any one please help me on this.
below are the requirement details and written code.
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();
}
}
Thanks,
kumar