Name
global.FixSwitchAndRouterModelForPatterns
Description
should add missing relations for IRE for Switches
Script
var FixSwitchAndRouterModelForPatterns = Class.create();
FixSwitchAndRouterModelForPatterns.prototype = Object.extendsObject(FixPatternsModelBasic, {
addMissingRelationsForSwitchesAndRouters : function() {
this.stepsCompleted = this.getStepsCompleted();
this.startLogRecord(this.scriptNames.NETWORK);
//Do quick Prerequisite check to make sure we can run this migration
this.quickPrerequisiteCheck();
this.recordArray = [];
this.addNetworkClassifiersToArray();
for (var i = 0; i < this.recordArray.length; i++) {
if (this.recordArray[i].status.equals(this.checkResult.FAIL))
this.classifierCheck = false;
}
var passLog = this.getPassLog("Classifier", this.classifierCheck);
this.infoMsg(passLog);
if (this.PASS_ALL) {
var startTime = new Date();
this.infoMsg('Switch/Router migration start');
//Update records for Routers and Switches
var networkArr = ['cmdb_ci_ip_switch', 'cmdb_ci_ip_router'];
this.addMissingRelationsForNetworkType(networkArr);
//Migrate Switch and Router Classifications to Patterns
for (var j = 0; j < this.recordArray.length; j++)
this.enablePatternObj(this.recordArray[j]);
this.setPropertyForOSProbes('glide.discovery.ip_based.active', 'false');
this.updateDNSIPAddresses();
var endTime = new Date();
var totalTime = endTime.getTime() - startTime.getTime();
var formattedTime = this.msToTime(totalTime);
this.infoMsg('Switch/Router Migration took: ' + formattedTime);
} else
this.infoMsg('Switch/Router migration prerequisite check FAILED - Please run ProbeToPatternPrerequisiteScript to check for issues.');
this.endLogs();
},
addMissingRelationsForNetworkType : function(networkArr) {
switch(this.stepsCompleted) {
case 0:
this.infoMsg('Switch/Router: Adding Network Adapter Relationships');
this.addNetworkAdapter(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 1:
this.infoMsg('Switch/Router: Adding IP Address Relationships');
this.addIpAddress(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 2:
this.infoMsg('Switch/Router: Adding Exit Interface Relationships');
this.addExitInterfaceRule(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 3:
this.infoMsg('Switch/Router: Adding Next Hop Relationships');
this.addNextHopRule(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 4:
this.infoMsg('Switch/Router: Adding Router Interface Relationships');
this.addRouterInterface(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 5:
this.infoMsg('Switch/Router: Adding Switch Partitions Relationships');
this.addSwitchPartitions(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 6:
this.infoMsg('Switch/Router: Adding Switch Port Relationships');
this.addSwitchPort(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 7:
this.infoMsg('Switch/Router: Adding Switch Forwarding Rule Relationships');
this.addSwitchForwardingRule(networkArr);
this.saveLeftOversRelationsToCMDBRelCI();
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 8:
this.infoMsg('Switch/Router: Updating Exit Interface Route Names');
this.updateRouteInterfaceName(networkArr, 'dest_ip_network');
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
case 9:
this.infoMsg('Switch/Router: Fixing Dest IP Network Values');
this.fixDestIpNetwork(networkArr);
this.stepsCompleted++;
this.updateStepsCompleted(this.stepsCompleted);
break;
case 10:
this.infoMsg('Switch/Router: All previous steps have been completed. Moving to enable patterns');
break;
default:
this.infoMsg('Switch/Router migration step count check FAILED - Please check probe_to_pattern_log for issues.');
}
},
type: 'FixSwitchAndRouterModelForPatterns'
});
Sys ID
5e18d8a49fa313004deb91aec32e7031