Check / dataset.txt
Rajesh3338's picture
Update dataset.txt
9e610ab verified
raw
history blame contribute delete
9.2 kB
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 "<Server_Name>"
- 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("<Environment>", "<Server>", "<Key>")
- GetServerUser: Retrieves the username for a server.
Example:
GetServerUser("<Environment>", "<Server>", "<Key>")
3. Common Scripting Tasks
3.1 Update Hostname
Updates the hostname on a server and verifies the change.
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "sudo su - root", "$", 5000
ExecuteShellCommandEnter "hostnamectl set-hostname <New_Hostname>", "$", 5000
$v1 = ExecuteShellCommandEnter "hostname", "$", 5000
if (v1.contains("<New_Hostname>")) then
R_DisconnectSSH
return true
else
R_DisconnectSSH
return false
end
3.2 Container Platform Operations
Example for OCP login and operations:
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "oc login <Protocol>://<FQDN>:<Port> -u <Username> -p <Password>", "$", <Login_Timeout>
ExecuteShellCommandEnter "oc project <Project_Name>", "$", <Project_Timeout>
ExecuteShellCommandEnter "<Scale_Command>", "$", <Operation_Timeout>
$v1 = ExecuteShellCommandEnter "<Status_Command>", "$", <Status_Timeout>
if (v1.contains("<Status_Pattern>")) then
R_DisconnectSSH
return true
else
R_DisconnectSSH
return false
end
3.3 Service Instance Management
Example for service control:
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "sudo su - <Service_User>", "$", <Auth_Timeout>
ExecuteShellCommandEnter "cd <Service_Path>", "$", <Path_Timeout>
$v1 = ExecuteShellCommandEnter "sh <Service_Script>", "$", <Execute_Timeout>
if (v1.contains("<Status_Pattern>")) then
R_DisconnectSSH
return true
else
R_DisconnectSSH
return false
end
3.4 Log Monitoring with Loop
Example for continuous log monitoring:
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "cd <Log_Path>", "$", <Path_Timeout>
loop
$v1 = ExecuteShellCommandEnter "tail -100 <Log_File>", "$", <Monitor_Timeout>
if (v1.contains("<Success_Pattern>")) then
R_DisconnectSSH
clearfile
else
Wait <Interval>
Breakloopaftercycle(<Max_Cycles>)
goto loop
end
3.5 File Operations
Example for file management:
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "cd <Path>", "$", <Path_Timeout>
$v1 = ExecuteShellCommandEnter "<File_Operation>", "$", <Operation_Timeout>
if (v1.contains("<Success_Pattern>")) 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 "<Server_Name>"
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 "<Source_Server_Name>"
ExecuteShellCommandEnter "scp <File_Path> <Destination_User>@<Destination_IP>:<Destination_Path>", "$", 5000
ExecuteShellCommandEnter "yes", "$", 5000
$v1 = ExecuteShellCommandEnter "ls <Destination_Path>", "$", 5000
if (v1.contains("<File_Name>")) then
R_DisconnectSSH
return true
else
R_DisconnectSSH
return false
end
3.8 MySQL Operations
Starts MySQL replication and verifies the process.
R_ConnectServer "<Server_Name>"
ExecuteShellCommandEnter "mysql -u <Username> -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 "<Storage_Server_Name>"
$v1 = ExecuteShellCommandEnter "snapmirror quiesce -destination-path <Path>", "$", 5000
if (v1.contains("Operation succeeded")) then
R_DisconnectSSH
return true
else
R_DisconnectSSH
return false
end
Break SnapMirror Replication:
R_ConnectServer "<Storage_Server_Name>"
$v1 = ExecuteShellCommandEnter "snapmirror break -destination-path <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 "<Server_Name>"
ExecuteShellCommandEnter "sudo su - <User>","",<Timeout>
$v1 = ExecuteShellCommandEnter "<Command_1>","",<Timeout_1>
if($v1.notcontains("<Success_Pattern_1>")) then
R_DisconnectSSH
return false
else
$v2 = ExecuteShellCommandEnter "<Command_2>","",<Timeout_2>
if($v2.notcontains("<Success_Pattern_2>")) then
R_DisconnectSSH
return false
else
R_DisconnectSSH
return true
end
end
4.2 Multiple Servers, Sequential Operations
R_Connect Server "<Server_1>"
ExecuteShellCommandEnter "sudo su - <User_1>","",<Timeout>
$v1 = ExecuteShellCommandEnter "<Command_1>","",<Timeout_1>
if($v1.notcontains("<Success_Pattern_1>")) then
R_DisconnectSSH
return false
else
R_Connect Server "<Server_2>"
ExecuteShellCommandEnter "sudo su - <User_2>","",<Timeout>
$v2 = ExecuteShellCommandEnter "<Command_2>","",<Timeout_2>
if($v2.notcontains("<Success_Pattern_2>")) then
R_DisconnectSSH
return false
else
R_DisconnectSSH
return true
end
end
4.3 Multiple Servers, Parallel Operations
R_Connect Server "<Server_1>"
ExecuteShellCommandEnter "sudo su - <User_1>","",<Timeout>
$v1 = ExecuteShellCommandEnter "<Command_1>","",<Timeout_1>
R_DisconnectSSH
R_Connect Server "<Server_2>"
ExecuteShellCommandEnter "sudo su - <User_2>","",<Timeout>
$v2 = ExecuteShellCommandEnter "<Command_2>","",<Timeout_2>
R_DisconnectSSH
R_Connect Server "<Server_3>"
ExecuteShellCommandEnter "sudo su - <User_3>","",<Timeout>
$v3 = ExecuteShellCommandEnter "<Command_3>","",<Timeout_3>
R_DisconnectSSH
if($v1.notcontains("<Success_Pattern_1>") or $v2.notcontains("<Success_Pattern_2>") or $v3.notcontains("<Success_Pattern_3>")) 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