CPSL (Custom Process Scripting Language) Documentation 1. Introduction CPSL is a domain-specific scripting language designed for automating server management, database operations, and system administration tasks. It enables efficient interaction with servers, execution of shell commands, and control over processes and services. 2. Commands Overview - R_ConnectServer: Connects to a remote server using its hostname or IP address. Example: R_ConnectServer "" - ExecuteShellCommandEnter: Executes a shell command on the connected server with an optional timeout. Example: ExecuteShellCommandEnter "hostname", "$", 5000 - R_DisconnectSSH: Disconnects the session from the connected server. Example: R_DisconnectSSH - GetServerPass: Retrieves the password for a server. Example: GetServerPass("", "", "") - GetServerUser: Retrieves the username for a server. Example: GetServerUser("", "", "") 3. Common Scripting Tasks 3.1 Update Hostname Updates the hostname on a server and verifies the change. R_ConnectServer "" ExecuteShellCommandEnter "sudo su - root", "$", 5000 ExecuteShellCommandEnter "hostnamectl set-hostname ", "$", 5000 $v1 = ExecuteShellCommandEnter "hostname", "$", 5000 if (v1.contains("")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.2 Container Platform Operations Example for OCP login and operations: R_ConnectServer "" ExecuteShellCommandEnter "oc login ://: -u -p ", "$", ExecuteShellCommandEnter "oc project ", "$", ExecuteShellCommandEnter "", "$", $v1 = ExecuteShellCommandEnter "", "$", if (v1.contains("")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.3 Service Instance Management Example for service control: R_ConnectServer "" ExecuteShellCommandEnter "sudo su - ", "$", ExecuteShellCommandEnter "cd ", "$", $v1 = ExecuteShellCommandEnter "sh ", "$", if (v1.contains("")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.4 Log Monitoring with Loop Example for continuous log monitoring: R_ConnectServer "" ExecuteShellCommandEnter "cd ", "$", loop $v1 = ExecuteShellCommandEnter "tail -100 ", "$", if (v1.contains("")) then R_DisconnectSSH clearfile else Wait Breakloopaftercycle() goto loop end 3.5 File Operations Example for file management: R_ConnectServer "" ExecuteShellCommandEnter "cd ", "$", $v1 = ExecuteShellCommandEnter "", "$", if (v1.contains("")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.6 Start EnterpriseLink Cluster Server Starts the EnterpriseLink Cluster Server service and verifies it. R_ConnectServer "" ExecuteShellCommandEnter "sudo su - root", "$", 5000 $v1 = ExecuteShellCommandEnter "/etc/init.d/EnterpriseLinkClusterServer start", "$", 5000 if (v1.contains("Starting EnterpriseLink Cluster Server")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.7 Copy Files to Another Server Copies a file from one server to another using SCP. R_ConnectServer "" ExecuteShellCommandEnter "scp @:", "$", 5000 ExecuteShellCommandEnter "yes", "$", 5000 $v1 = ExecuteShellCommandEnter "ls ", "$", 5000 if (v1.contains("")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.8 MySQL Operations Starts MySQL replication and verifies the process. R_ConnectServer "" ExecuteShellCommandEnter "mysql -u -p", "$", 5000 ExecuteShellCommandEnter "start slave;", "$", 5000 $v1 = ExecuteShellCommandEnter "show slave status\G", "$", 5000 if (v1.contains("Running")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 3.9 Manage SnapMirror Quiesce SnapMirror Replication: R_ConnectServer "" $v1 = ExecuteShellCommandEnter "snapmirror quiesce -destination-path ", "$", 5000 if (v1.contains("Operation succeeded")) then R_DisconnectSSH return true else R_DisconnectSSH return false end Break SnapMirror Replication: R_ConnectServer "" $v1 = ExecuteShellCommandEnter "snapmirror break -destination-path ", "$", 5000 if (v1.contains("Operation succeeded")) then R_DisconnectSSH return true else R_DisconnectSSH return false end 4. Multiple Server Operation Patterns 4.1 Single Server, Multiple Operations R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v1 = ExecuteShellCommandEnter "","", if($v1.notcontains("")) then R_DisconnectSSH return false else $v2 = ExecuteShellCommandEnter "","", if($v2.notcontains("")) then R_DisconnectSSH return false else R_DisconnectSSH return true end end 4.2 Multiple Servers, Sequential Operations R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v1 = ExecuteShellCommandEnter "","", if($v1.notcontains("")) then R_DisconnectSSH return false else R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v2 = ExecuteShellCommandEnter "","", if($v2.notcontains("")) then R_DisconnectSSH return false else R_DisconnectSSH return true end end 4.3 Multiple Servers, Parallel Operations R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v1 = ExecuteShellCommandEnter "","", R_DisconnectSSH R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v2 = ExecuteShellCommandEnter "","", R_DisconnectSSH R_Connect Server "" ExecuteShellCommandEnter "sudo su - ","", $v3 = ExecuteShellCommandEnter "","", R_DisconnectSSH if($v1.notcontains("") or $v2.notcontains("") or $v3.notcontains("")) then return false else return true end 4.4 Best Practices for Multiple Server Operations: - Use appropriate timeout values for each operation - Implement proper error handling and validation for each server connection and command execution - Disconnect from servers after completing operations or in case of errors - Use consistent naming conventions for variables and placeholders - Structure the script logically, grouping related operations together - Consider using loops for repetitive operations across multiple servers - Implement appropriate logging or output messages for troubleshooting - Use .contains() or .notcontains() based on the expected output patterns - Ensure proper indentation and nesting of if-else statements for readability Common Timeout Values: - Authentication: 5000-60000 - Basic operations: 5000 - Service operations: 120000-300000 - Platform operations: 60000-120000 - Recovery operations: 300000-1200000 Best Practices: - Use empty string for second parameter - Include R_DisconnectSSH in all paths - Validate each operation before proceeding - Match number of 'end' statements with if blocks - Follow proper nesting structure - Use appropriate timeout values - Use .contains() or .notcontains() based on validation needs 4.5 Best Practices for Multiple Server Operations: - Use empty string "" for second parameter in ExecuteShellCommandEnter - Implement proper timeout values for each operation - Follow nested if-else structure for validations - Include R_DisconnectSSH in each failure path - Match 'end' statements with if blocks - Use .contains() or .notcontains() based on validation needs - Maintain consistent prompt patterns - Follow proper command sequence - Implement appropriate validation checks 5. Best Practices - Always sanitize inputs to avoid hardcoding sensitive information - Use placeholders in templates and replace them with real values during execution - Test scripts in a controlled environment before deploying them in production - Set appropriate timeout values based on operation type - Implement proper validation checks for operations - Include error handling for all operations 6. Common Timeout Values - Basic operations: 5000 - Authentication operations: 60000 - Path operations: 60000 - Service operations: 300000 - Build operations: 900000