Commands
Command is a core entity used to execute various actions in Cetmix Tower. Depending on the action selected, it can be executed on a remote server or locally on the Cetmix Tower server.
Commands are located under the Cetmix Tower > Commands > Commands
menu.
Fields
Field | Description |
---|---|
Name | Command readable name. |
Reference | Used for Odoo automation and YAML export/import. Leave blank to generate it automatically. |
Action | Action executed by the Command. |
File Template | File template that will be used to create or update file. Check File Templates for more details. |
Default Path | Specify path where Command will be executed. This field supports Variables. |
Allow Parallel Run | If disabled, only one copy of this Command can be run on the same server at the same time. Otherwise, the same Command can be run in parallel. |
Note | Comments or user notes. |
Servers | List of Servers this Command can be run on. Leave this field blank to make the Command available to all servers. |
OSes | List of operating systems this Command is available. Leave this field blank to make the Command available for all OSes. |
Tags | Make usage as search more convenient |
Access Level | Minimum access level required to run this Command. |
Server Status | Server Status upon successful Command execution. Leave Undefined to keep status unchanged. |
Warning
Ensure ssh user has access to the location where Command is executed even when executing Command using sudo.
Warning
Variables used in Command are rendered in different modes based on the Command action.
Notebook Tabs
Tab | Description |
---|---|
Code | Code to execute. Can be an SSH command or Python code based on selected action. This field supports Variables. |
YAML | YAML code of the Command. This tab is visible only to users with "Cetmix Tower YAML > Export" setting enabled. |
Command Actions
Action | Description |
---|---|
SSH command | Execute a shell command using ssh connection on remote server. |
Execute Python code | Execute a Python code on the Tower Server. |
Create file using template | Create or update a file using selected file template and push/pull it to remote server/tower. If the file already exists on server, it will be overwritten. Important: this action can be used only in Flight Plans. |
Run flight plan | Run a Flight Plan from Command. Important: this action can be used only in Flight Plans. |
Python Code Command result
To return result from Python assign exit code and message to the COMMAND_RESULT
variable of type dict
like this:
# Success
COMMAND_RESULT = {
"exit_code": 0,
"message": "This will be logged as a result message because exit code == 0",
}
# Error
COMMAND_RESULT = {
"exit_code": 21,
"message": "This will be logged as an error message because exit code != 0",
}
exit_code
value will be used as a Command result status. message
will be logged as a result message if exit_code
is 0
or an error message if exit_code
is not 0
.