Monday, July 30, 2007

CallManager Syncronization

Occasionally you will need to check for synchronization between CallManager servers in a cluster.

In order to remove the server from the database there is a script listed in Cisco documentation but its incorrect. Here's the correct remove batch script.

@echo off
@if "%3x" == "x" goto Usage
echo Install stored procedure in database %2
echo USE %2                                                                        
echo GO                                                                            
echo DROP PROCEDURE dblRemoveServerFromDB                                          
echo GO                                                                            
echo CREATE PROCEDURE [dblRemoveServerFromDB]                                      
echo (@servername NVARCHAR(50)) AS                                                 
echo BEGIN TRANSACTION                                                             
echo DECLARE @nodeid NVARCHAR(50), @deviceid NVARCHAR(50), @pnsid NVARCHAR(50)     
echo --                                                                            
echo PRINT 'Get the Node ID'                                                       
echo SELECT @nodeid=pkid from ProcessNode where name=@servername                   
echo --                                                                            
echo PRINT 'Delete associated Device and MediaMixer'                               
echo WHILE (SELECT COUNT(*) FROM Device WHERE fkProcessNode=@nodeid) ^> 0          
echo BEGIN                                                                         
echo SELECT @deviceid=pkid from Device where fkProcessNode=@nodeid                 
echo PRINT 'Delete MediaMixer'                                                     
echo DELETE FROM MediaMixer WHERE fkDevice=@deviceid                               
echo PRINT 'Delete MOHServer'                                                      
echo DELETE FROM MOHServer WHERE fkDevice=@deviceid                                
echo PRINT 'Delete Device'                                                         
echo DELETE FROM Device WHERE pkid=@deviceid                                       
echo END                                                                           
echo --                                                                            
echo PRINT 'Delete associated CallManager records'                                 
echo DELETE FROM CallManagerGroupMember FROM CallManagerGroupMember AS M           
echo JOIN CallManager AS C ON C.pkid=M.fkCallManager WHERE C.fkProcessNode=@nodeid 
echo DELETE FROM CallManager WHERE fkProcessNode=@nodeid                           
echo --                                                                            
echo PRINT 'Delete associated ProcessConfig records'                               
echo DELETE FROM ProcessConfig WHERE fkProcessNode=@nodeid                         
echo --                                                                            
echo PRINT 'Delete associated AlarmConfig records'                                 
echo DELETE FROM AlarmConfig FROM AlarmConfig AS A JOIN ProcessNodeService         
echo AS S ON A.fkProcessNodeService=S.pkid WHERE S.fkProcessNode=@nodeid           
echo PRINT 'Delete associated ProcessNodeService records'                          
echo DELETE FROM ProcessNodeService WHERE fkProcessNode=@nodeid                    
echo --                                                                            
echo PRINT 'Delete associated ComponentVersion records'                            
echo DELETE FROM ComponentVersion WHERE fkProcessNode=@nodeid                      
echo --                                                                            
echo PRINT 'Delete the node'                                                       
echo DELETE FROM ProcessNode WHERE pkid=@nodeid                                    
echo --                                                                            
echo COMMIT TRANSACTION                                                            
echo GO                                                                            
echo -- Execute procedure on server %1
echo exec dblRemoveServerFromDB '%3'                                               
osql -S %1 -d %2 -E -e -i temp.sql
del temp.sql
echo USE %2                                                                      
echo GO                                                                            
echo sp_dropsubscription @publication = '%2', @subscriber = '%3', @article='all'   
echo GO                                                                            
osql -S %1 -d %2 -E -e -i temp1.sql
del temp1.sql
goto endd
@echo Usage:
RemoveServerFromDB "server" "database" "name_of_server_to_delete_from_ProcessNode.Name"
@echo Example: RemoveServerFromDB . CCM0300

No comments: