This Blog has been prepared to assist you in becoming familiar with the Pre & Post Migration steps within Stat specific to using Stat and the PuTTY Telnet/SSH application in command line mode.
Pre and Post migration steps define activities you perform before and after a migration an archive set occurs. These steps are performed either manually by the user or automatically by Stat. The steps are meant to promote adherence to development standards and are not mandatory or enforced.
Migration steps can be associated with specific object types and within specific target environments. This means that when you migrate anarchive set that includes an associated object type, or when you migrate an archive set to an associated environment, Stat opens the Pre Migration Steps window.
The window displays a checklist of actions that need to be taken immediately before the archive set is migrated.
Below are sample screens of the different types of calls we can make.
The “Step Name” field indicates its use, and the “Object Type” field indicates the type of object that this step, or process, is to watch for and react appropriately.
Pre-Migration Steps Setup Screen for Custom Application Processes:
Pre-Migration Steps Setup Screen for PeopleSoft Processes:
Please Note: Post-Migration Steps are setup in the exact same fashion.
The following is an example of calling a Linux Shell Script to delete a file prior to a new file being migrated to that server. The call utilizes PuTTY’s PLink functionality to SSH into the remote machine, execute steps as required and return control to the local calling machine. For additional Command Line Calls or information on using PLink, please see Appendix A at the end of this post.
Step I: Pre Migration Step Record Setup:
Once you hit the Apply button the “Define Command” button is enabled.
Select the “Define Command” button to enter in the scripts, or processes, that we want run when this item gets triggered.
Return to TopStep II: Pre-Migration Step Command Setup:
We enter our command, with parameters to be included, in the lower left hand box. We can select the “Interpret Command” at anytime to see what the parameters will be interpreted into. (Provided there is a value to get at the time.)
The follow two values show how the Stat Stored Parameters are automatically interpreted and inserted into the command call at runtime so the process can run based on the proper location and permissions that are needed.
The following two values, Uninterrupted and Interpreted, shows how the command line parameters are converted from a stored/encrypted value, to therequired value needed to properly execute the job at runtime.
Uninterrupted: (Pre-Migration Step Setup):
CMD /C %%MyIPAddress%%\%%BatchDirectory%%\Linux_Scripts\PLinkLinuxDelSQR.bat %%TARGET_OBJECT_NAME%%
Interpreted: : (Runtime Interpretation of the Values):
CMD /C 127.0.0.1\P:\BatchFiles\BatchScripts\BAT_Scripts\Linux_Scripts\PLinkLinuxDelSQR.bat MyJavaBld.war
When the Stat Migration starts, and you drag-n-drop the archive code set from one environment to another Stat looks through the objects that are physically getting moved and checks to see if there are processes that need to be run prior to their migration.
When we migrate an object, such as a Java WAR file in our example, Stat will do a look-up in the pre-migration steps command and pull back the matching job that must get executed prior to the migration.
The Pre-Migration Runtime Window will appear at the time of migration. The jobs listed in the below screenshot are controlled by the items included in the migration package.
Pre-Migration Steps Execution at Runtime:
The highlighted row above in green indicates that we are migrating an Object Type of "Java WAR" file. When Stat see's one of these files in a migration action, it knows to call the associated step "RMV_LINUX_FILE_B4_MIGR" prior to 'physically' moving the objects in this migration package. The call will remove a file that is hosted out on our Linux Server at another location.
However, we are currently running on a Windows Machine in another location... What’s an Administrator to do! (Oh My!)
Our PLink Pre-Migration Step to the Rescue!
Our command calls a local script to run PuTTY’s PLink application for us. This script will do the following:
As mentioned above, our PuTTY PLink script as busy task list to accomplish, so let’s get cracking!
Below is a copy of our local call, or parent, script: PLinkLinuxDelSQR.bat
Below is the script to be run on the local machine that will launch PuTTY PLink, connect to my Linux machine, login, authenticate, and call a shell script on the remote machine to remove the file as needed.
REM PLink_Lnx_DelFile.bat: CMI Connect Remote Linux & Execute Remote Script.
REM Written By William R. Hart, Solutions Architect.
REM Quest Software, Inc. Copyright 2011
REM The following script is a sample of using PuTTy P-Link,
REM or PLink, which is a Command Line interface into the
REM PuTTY tool which can log into remote servers, execute steps
REM as required, and return results as requested.
REM A simple explanation would be that you are running
REM PuTTY, using profiles previously setup, and calling into
REM a remote server with the profile params and executing processes
REM as needed.
REM In this case: YOU'RE doing ALL of THIS in a SINGLE COMMAND LINE CALL!
REM (-You Rock!)
REM 1. Takes the Command Line FileName To Be Deleted.
REM 2. Load PuTTY's PLINK Command Line Interface Utility.
REM 3. Log into Remote Linux Environment.
REM 4. Execute Remote Shell Script: delfile.sh
REM 5. Capture Output and Return.
REM CALL PLINK: CLP: (Cmd Line Params)
REM CmdLine: N:\Program Files\Putty\PLink -v (Verbose)
REM -ssh (Run via SSH)
REM -batch (Batch Mode)
REM -pw (Encrypted KEY or PWD)
REM firstname.lastname@example.org (Target Server)
REM sh DelFile.sh (Run This Script)
REM Test Call:
REM N:\Putty\PLink -v -ssh -batch -pw pwd email@example.com sh DelFile.sh %1
REM Stat Post Migration Call:
REM CMD /C N:\Putty\PLink -v -ssh -batch -pw pwd firstname.lastname@example.org sh %1
REM --- SAMPLE ONLY ---
REM ***** NOT RESPONSIBLE FOR USE, MISUSE OR RESULTS OF USE *****
REM *** IF YOU DONT FULLY UNDERSTAND IT, PLEASE DO NOT USE IT ***
REM Confirm we have a Valid Command Line Params.
IF "%1"=="" GOTO CmdLnPrmsNotFnd
ECHO "Processing the Following Commands: " %0
ECHO "Command Line Param #1 = " %1
START C:\Program Files\Putty\PLink -v -ssh -batch -pw pwd email@example.com sh DelFile.sh
REM SCRIPT SUCCESS: Tell User - Exit Clean.
Echo "Script Process " %1 " Completed Activities For " %2
ECHO "Please Check Above For Errors Before Closing!"
REM SCRIPT FAIL: No Command Line Params - Tell User - Exit.
Echo "FAIL: INVALID Cmd Line Params Passed."
ECHO "Please Check Values and Try Again. Exiting..."
REM < End of Script >
When the script completes, we interpret the results and close the window. If there are other objects in our migration that also need to do particular functions or processes, they too will be called following the pre-established firing order we configured.
Return to Top
Stat’s Pre & Post Migration steps make the everyday, monotonous and repetitive, tasks easier to remember and easier to automate. There are always things we would like to do ‘If we had the time’. Let Stat give you that time back by handling these types of tasks for you!
In summary, the value of using Stat’s Pre & Post Migration Steps to streamline the migration process.
The resulting combination gives Developers, System Administrators, and Migrators the ability to pursue even more capabilities to further enhance and improve other area of their system, and free them up to take advantage of other opportunities within the organization.
For a direct link to the PuTTY PLink command line options please see the following reference: Chapter 7 Help on PLink
PuTTY homepage is located here: PuTTY_Home_Page
Thank you for taking the time to read this Blog and I hope that you found it useful.
William R. HartSolutions ArchitectQuest Software, Inc.