CA Service Management

Scripted pdm_publish for AA environment 

Mar 22, 2017 02:14 PM

Hi Community,

 

To help reduce errors when modifying the schema for Service Desk Manager, I've scripted the pdm_publish steps in PowerShell.  We deploy changes in our production environment on Saturday mornings, and I've noticed that I'm more error prone in the morning before I've had coffee!  This script will help ensure the steps are followed correctly every time.

 

Let me know if you have any questions!

 

 

Requirements

1. Must be an administrator on the background/standby servers

2. PowerShell Remote Commands must be available

 

Notes

1. The pdm_publish command may show an error with something along the lines of input failed, this is because it's expecting the user to input Y or N, which it will then conditionally start the background server.  The script will still continue without error.  However, if you want to stop this alert you can comment out line 151 in pdm_publish.pl.  This line fires the function asking for user input to fail over the background server.

After commenting out the line it should look like this.

#performAutoFailOver(); #Perform Standby Server services startup and fail-over (pdm_server_control -a) - This is only for AA mode.

 

Follow these steps to use this script.

1. Copy the contents of to Notepad++ or the text editor of your choice

2. Update the $sdm_bg_srvr and $sdm_sb_srvr variables to the FQDN of your background and standby server

3. Update the $nx_path variable to the install location of Service Desk for your environment

4. Name the script and make sure it end in .ps1

5. Open PowerShell and navigate to the directory you saved the file.

6. To execute the script, run the following command ".\<filename>"

 

##########################################################################
#
# Automated pdm_publish for Advanced Availability
#
# by Grant Bruneau
# Version 2: 2017-03-22
#   Updated nx_path to a variable and added error checking on pdm_publish
#
##########################################################################
$sdm_bg_srvr = "background_fqdn"
$sdm_sb_srvr = "standby_fqdn"
$nx_path = "D$\Program Files (x86)\CA\Service Desk Manager"

if(!(Test-Connection -Cn $sdm_bg_srvr -BufferSize 16 -Count 1 -ea 0 -quiet)){
     Write-Host "Unable to contact $sdm_bg_srvr" -ForegroundColor Red
}
elseif(!(Test-Connection -Cn $sdm_sb_srvr -BufferSize 16 -Count 1 -ea 0 -quiet)){
     Write-Host "Unable to contact $sdm_sb_srvr" -ForegroundColor Red
}
else{
     #Continue if wsp.altercol and wsp.altertbl exist
     if((Test-Path "\\$sdm_bg_srvr\$nx_path\site\mods\wsp.altercol") -AND (Test-Path "\\$sdm_bg_srvr\$nx_path\site\mods\wsp.altertbl")){
          Write-Host "Alter Column and Table files found, process continuing`n" -Fore Green;
          #Promote the original standby server to the background server
          Write-Host "Promoting $sdm_sb_srvr to the background server`n" -Fore Green;
          icm -cn $sdm_sb_srvr -scriptblock {pdm_server_control -b}
          Start-Sleep -s 5
          #Kill leftover catalog_sync and interval logging processes
          Write-Host "Killing leftover Java processes on $sdm_bg_srvr`n" -Fore Green;
          icm -cn $sdm_bg_srvr -scriptblock {get-process -name java | stop-process -force}
          #Suppress version control on original background server
          Write-Host "Suppressing Version Control on $sdm_bg_srvr`n" -Fore Green;
          icm -cn $sdm_bg_srvr -scriptblock {pdm_server_control -v}
          Start-Sleep -s 5
          #Continue if suppress_version_control.txt exists
          if(Test-Path "\\$sdm_bg_srvr\$nx_path\pdmconf\suppress_version_control.txt"){
               #Execute pdm_publish on the original background server
               Write-Host "Executing pdm_publish on $sdm_bg_srvr`n" -Fore Green;
               icm -cn $sdm_bg_srvr -scriptblock {pdm_publish} | Tee-Object -Variable publishOutput
               #Continue if pdm_publish was successful
                  if($publishOutput -like "*Normal end of pdm_publish*"){
                       Write-Host "pdm_publish successful, process continuing`n" -Fore Green;
                       Start-Sleep -s 5
                       #Stop processes on standby server
                       Write-Host "Stopping processes on $sdm_sb_srvr`n" -Fore Green;
                       icm -cn $sdm_sb_srvr -scriptblock {get-process -name sslump_nxd | stop-process -force}
                       icm -cn $sdm_sb_srvr -scriptblock {get-process -name java | stop-process -force}
                       Start-Sleep -s 15
                       #Start services on original background server
                       Write-Host "Starting services on $sdm_bg_srvr`n" -Fore Green;
                       (get-service -cn $sdm_bg_srvr -name pdm_daemon_manager).Start()
                       Write-Host "Waiting 2 minutes for services to start`n" -Fore Green;
                       Start-Sleep -s 120
                       #Promote the original background server to the background server
                       Write-Host "Promoting $sdm_bg_srvr to the background server`n" -Fore Green;
                       icm -cn $sdm_bg_srvr -scriptblock {pdm_server_control -b}
                       Start-Sleep -s 5
                       #Start services on original standby server
                       Write-Host "Starting services on $sdm_sb_srvr`n" -Fore Green;
                       (get-service -cn $sdm_sb_srvr -name pdm_daemon_manager).Start();
                       #Copy wsp files to standy server to help prevent accidental data deletion
                       Write-Host "Copying modified wsp files to $sdm_sb_srvr`n" -Fore Green;
                       Copy-Item "\\$sdm_bg_srvr\$nx_path\site\mods\wsp_*" "\\$sdm_sb_srvr\$nx_path\site\mods\" -force
                       Write-Host "Schema modification successful`n" -Fore Green;
                       Write-Host "Services on Application Servers will still need to be restarted in order to pick up changes" -Fore Green;
                  }
                  else{
                       #Error condition, pdm_publish failed
                       Write-Host "pdm_publish encountered an error, please review the logs and try again" -Fore Red
                  }
          }
          else{
               #Error condition, suppress_version_control.txt was not found
               Write-Host "Cannot find suppress_version_control.txt file.`nPlease continue manually and execute pdm_server_control -v again." -Fore Yellow
          }          
     }
     else{
          #Error condition, altercol.txt or altertbl.txt not found
          Write-Host "Cannot find Alter Column or Table files.`nDid you publish the schema changes in Web Screen Painter?" -Fore Yellow
     }
}

Statistics
0 Favorited
8 Views
0 Files
0 Shares
0 Downloads

Related Entries and Links

No Related Resource entered.