Remove CI Relationships

jeremyeperdue
Giga Expert

My goal is to be able to "retire or decommission" a CI. Using the Server Class, I will use a Windows Server as an example.

In our environment, we can retire a server running Windows, then bring it back online as a Linux machine. For reporting purposes and requirements by our CMDB team, we will need to keep the old CI record and the new CI discovered record. The current server will be active with all details and the previous server is set to inactive and numerous fields are cleared.

I have the code for removing all fields and linking the old CI to the new CI, but I am looking for assistance with the removing relationships part. What is the best way to purge the relationships on a CI?

Example: The retired Windows server was running an instance of MSSQL. This machine is clearly no longer running the database. So while we want to keep the records about the software that was installed, disk drives, serial numbers etc... , I want to remove the relationship(s) that would only be accurate if the machine is still "active". What is the best way to handle this?

16 REPLIES 16

swa3
Kilo Explorer

Hi Mark,


one more question. The script is working fine with Onbefore BR.


can you please tell me if I should be using Should i be using Onbefore or Onafter BR.



Thanks,


S


What about deleting other info in the Related Tabs? For example, I don't see a need to keep Installed Software, (running) Processes, and IP addresses.



With IP addresses still there and it is reused, there is a risk of an incorrect merge match with Network (IP/MAC) if the serial number data is missing.


Hai Mark Stanger,



I wrote above code for removing ci relationships, But it is not working.


Can you explain your code, And elobarate with screenshots of answers.




Thank you.


Mark - looks like a great solution, haven't tried it yet because I have a question. Where did you place this BR or what tables are you using it to trigger off of?  I don't think you can put it at the core tables so you would have to put it on every CI/service table? 

We only used this in one place in our turnkey...the 'Service Offering' table has a 'Parent' field that references the 'Business Service' table.