Name
global.NetAppRelationshipsAndSnapshotUpdate
Description
NetApp pattern migration script to create necessary relationships missing in the probe/sensors + snapshot
Script
var NetAppRelationshipsAndSnapshotUpdate = Class.create();
NetAppRelationshipsAndSnapshotUpdate.prototype = {
initialize: function() {
},
updateNetAppRelationshipsAndSnapshot: function (naCondition) {
var naTable = new GlideRecord('cmdb_ci_storage_server');
naTable.addQuery('cim_object_path', 'STARTSWITH', 'ONTAP');
naTable.addQuery('short_description', naCondition, '7-Mode');
naTable.query();
while (naTable.next()){
gs.log("***** Start NetApp pattern migration script to create necessary relationships and pattern snapshot ******");
var ownsRelSysId = new DiscoveryFunctions().findCIRelationshipTypeByDesc('cmdb_rel_type', 'Owns', 'Owned by');
var containsRelSysId = new DiscoveryFunctions().findCIRelationshipTypeByDesc('cmdb_rel_type', 'Contains', 'Contained by');
var controllerForRelSysId = new DiscoveryFunctions().findCIRelationshipTypeByDesc('cmdb_rel_type', 'Controller for', 'Controlled by');
var hostedOnRelSysId = new DiscoveryFunctions().findCIRelationshipTypeByDesc('cmdb_rel_type', 'Hosted on', 'Hosts');
var providesRelSysId = new DiscoveryFunctions().findCIRelationshipTypeByDesc('cmdb_rel_type', 'Provides', 'Provided by');
if (!ownsRelSysId || !containsRelSysId || !controllerForRelSysId || !hostedOnRelSysId || !providesRelSysId) {
gs.log("No NetApp relations updates: the necessary relation types are not defined");
return;
}
//RELATIONSHIPS CREATION START
// Create Owns::Owned relationship for NetApp Storage Server references: fibre channel port, ip address
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_fc_port', 'computer', ownsRelSysId, 'false');
DiscoveryStorageUtilities.convertStorageServerReferenceIPToRel(naTable, ownsRelSysId);
// Create Contains::Contained by relationship for NetApp Storage Server references: storage pool, storage volume, storage disk
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_storage_pool', 'hosted_by', containsRelSysId, 'false');
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_storage_volume', 'computer', containsRelSysId, 'false');
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_disk', 'computer', containsRelSysId, 'false');
// Create Controller for::Controlled by relationship for NetApp Storage Server references: storage controller
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_storage_controller', 'computer', controllerForRelSysId, 'true');
// Create Hosted on::Hosts relationship for NetApp Storage Server references: fibre channel export, iscsi export
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_iscsi_export', 'hosted_by', hostedOnRelSysId, 'true');
DiscoveryStorageUtilities.convertStorageServerReferenceToRel(naTable, 'cmdb_ci_fc_export', 'hosted_by', hostedOnRelSysId, 'true');
//RELATIONSHIPS CREATION END
//PATTERN SNAPSHOT CREATION START
DiscoveryStorageUtilities.createSnapshotForDiscoveredNetAppStorage(naTable);
//PATTERN SNAPSHOT CREATION END
gs.log("***** End NetApp pattern migration script to create necessary relationships and pattern snapshot ******");
}
}, type: 'NetAppRelationshipsAndSnapshotUpdate'
};
Sys ID
a514a0259f0503002b9b92ec757fcf2a