Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Unrelating CI's from other CI's

SOLVED
Go to solution
Highlighted
NMOLL
Regular Collector

Unrelating CI's from other CI's

Hey guys, I really need your help.

We have a bunch of hardware CI's (computers, servers, laptops etc.) with related software CI's (operating system, office packs etc.).

These are imported and related automatically, but sometimes software is also uninstalled and is therefore no longer related to the hardware CI.

For this, I need to find a way to automatically unrelate our software CI's from our hardware CI's

My thought is, is it possible to unrelate all CI's before I run my daily import?


I don’t think its possible using data exchange, but maybe one of you have some JAVA code that can do this (I'm no java programmer myself)? or maybe another solution to my problem.


Thanks a lot.
9 REPLIES
Jonathon Druce
Honored Contributor
Solution

Re: Unrelating CI's from other CI's

Niels,

The way I do this is as follows;

I create a new CI relation called "Redundant" or "No longer related"

I then import the CI's and their relations from the data source.

I next extract all the relations from my data source but give them a relationship descriptor of "Redundant"

I then extract the same relations from the Service Desk Data base and give them the same relationship descriptor.

Finally I do a delta import with the SD data being the data and the external data being the reco file. What happens is that if a relationship is in the external data and in service desk nothing happens (no difference). If it is in Service Desk but not in the source then the descriptor will get changed to "Redundant" as it is seen as a new record (present in SD but not in external data). The trick is to make the unique key on the import mapping both the cifrom and cito.

Hope this makes sense.
NMOLL
Regular Collector

Re: Unrelating CI's from other CI's

Hi Jonathon,

I think I understand.

Doing it this way, I will not unrelate anything, just change the relation type from "Related to" to "No longer related"?
please correct me if im wrong.

I think it would be better to unrelate things, because otherwise we will have ALOT of relations with "No longer related". Almost all our software is created as CI's and people tend to install/update/uninstall all the time.

I appreciate your suggestion.

Jonathon Druce
Honored Contributor

Re: Unrelating CI's from other CI's

You are right. The advantage I have seen with changing the relationship descriptor and with some of the later service packs where you can audit CI relations is that you can strat to get some historical picture of what is happening.

If you want to delete these relationships you will need to use something like sd_event which can delete an item. I have done one install where I did a DTS job (it was on SQL - I think there is an oracle equivilent) that extracted all relationships of a certain type ( I was anle to even filter on the CI types) to a text file that was a series of SD_Event.exe calls. The downside of this is that the extract took about 30 seconds to run but the batch file that it created took about 6 hours to run. Also if you delete and then recreate the relations you have to add on the data exchange time so you can end up taking a lot of time to do this.
NMOLL
Regular Collector

Re: Unrelating CI's from other CI's

Thanks Jonathon,

I still think we will run into problems because we have almost all our software as CI's and it will change alot.

I will try it out.

Thank you very much for your help.

If anyone else has an idea, please let me know

Re: Unrelating CI's from other CI's

it is quite easy to unrelate CIs with the Java web-api but it still takes some time, especially when you have CIs with many related CIs (like one parent CI with 5,000 clients related to it).
The actual code to unrelate the CIs is about 10 lines of Java. You just have to think about how you like to use it (e.g. as a client app, command line tool or on a Web server)
NMOLL
Regular Collector

Re: Unrelating CI's from other CI's

Hi Mark,

I would like to run the script just before I start doing my imports. if it can run from a scheduled task on the server it would be great.

I'm not a great java programmer myself, can you help me out?

Re: Unrelating CI's from other CI's

NMOLL
Regular Collector

Re: Unrelating CI's from other CI's

Hi Mark,

Thank you very much.

I should have said we are using 5.1 SP2 right now, and the code is for 4.5

I will take a look at the code and see what I can figure out.


If you have anything else that might help me solve this, pleease let me know.

Thanks
NMOLL
Regular Collector

Re: Unrelating CI's from other CI's

Hi guys,

I really can't get this code to work in 5.10. anyone else have a suggestion?

I can't belive its that hard to unrelate a CI from another CI.
//Add this to "OnDomLoad" event