No containment or hosting rules defined for dependent class cmdb_ci_logical_datacenter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 11:47 AM
Hi all!
I've been working on integrating my saas json data into ServiceNow's CMDB, specifically targeting the cmdb_ci_database table. My goal is to map my databasae data from my application to ServiceNow, ensuring that each database instance is accurately reflected within the CMDB. However, I keep encountering an error related to the Identification and Reconciliation (I&R) engine and scripting customizations, and I'm seeking advice or solutions from anyone who may have tackled similar issues.
Overview of the Process:
Data Source and Target:
The data originates from my saas app, representing various database instances (like Microsoft SQL and Oracle databases), and the target within ServiceNode is the cmdb_ci_database table.
To facilitate the mapping, I've created an onBefore script that manipulates the incoming data, preparing it for identification and reconciliation within ServiceNow. It looks like this (the additional childData & relations nodes are added to conform to SN's recommended payload sample):
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
ignore = true; // Prevents import set from creating record after IRE is run
try {
var data = JSON.parse(source.u_data);
var dbName = data.database_name;
var cloudDbName = data.database_name;
var logicalDatacenterId = "100"; // update
var region = "us-east"; // update
var dbTypeId = data.database_type;
var childData = [
{
"className": "cmdb_ci_cloud_database",
"lookup": [],
"values": {
"type": dbTypeId,
"object_id": cloudDbName
}
},
{
"className": "cmdb_ci_logical_datacenter",
"lookup": [],
"values": {
"object_id": logicalDatacenterId
}
}
];
var relations = [
{
"type": "Contains::Contained by",
"parent": 1, // Referring second item (cmdb_ci_cloud_database) as parent
"child": 0 // Referring first item (cmdb_ci_database) as child
},
{
"type": "Hosted on::Hosts",
"parent": 1, // Referring second item (cmdb_ci_cloud_database) as parent
"child": 2 // Referring third item (cmdb_ci_logical_datacenter) as child
}
];
var util = new D42SyncUtil();
util.processIRE(source, map, log, relations, childData);
} catch (e) {
log.error(e.toString());
}
})(source, map, log, target);
The issue is that SN requires its Database CI model to be contained in a Cloud Database model and that in turn to be Hosted On a Logical Datacenter.
The IRE engine keeps saying in the logs: No containment or hosting rules defined for dependent class cmdb_ci_logical_datacenter.
The issue is that I cannot define any hosting/containment rule for cmdb_ci_logical_datacenter as it shouldn't have any according to SN's Dependent Relationships mapping diagram.
Additionally, I've tried the Identification Simulation's own example payload, and it fails with the above error as well.
{
"items": [{
"className": "cmdb_ci_database",
"lookup": [],
"values": {
"name": "master",
"type": "Microsoft SQL Server"
}
},
{
"className": "cmdb_ci_cloud_database",
"lookup": [],
"values": {
"object_id": "master"
}
},
{
"className": "cmdb_ci_logical_datacenter",
"lookup": [],
"values": {
"object_id": "100"
}
}
],
"relations": [{
"type": "Contains::Contained by",
"parent": 1,
"child": 0
},
{
"type": "Hosted on::Hosts",
"parent": 1,
"child": 2
}
]
}
Any advice would be greatly appreciated.
Thanks in advance!