Command
Commands are core of Mpl. Mpl command syntax is similar to unix command just that they are prefixed by !
. All Mpl command return json
document, which could be assigned to a variable. This json
type variable can be then queried and used in subsequent commands.
One of the design goals of Mpl is to support a simple CLI interface to interact with different app tiers, such as Kubernetes, Databases, etc. Users can try automation steps in Mpl repl and submit the workflow to the orchestration system. For example, following k8s command queries pods, the result is input to the next step. Users can quickly verify these manually and submit them to Maira for execution on an event or fixed schedule. There is no need to rewrite these steps in a different language.
Note that one can pass mpl variable to commands as is. If you need to pass a string to Mpl command, it must be in quotes. e.g., ! k8ds delete-pod "pod1"
. Also, in above command --site <site>
was not entered, so Mpl takes the site from variable input.site
.
If output of a command is not assigned to a variable, user friendly output is printed on console. e.g.,
! k8s list-pods --namespace "default"
NAME STATUS RESTARTS CONTAINERS START TIME
gok8smetrics-deployment-866b448cd-5ff84 Running gok8smetrics 11-04-2021 09:37:34 pm PDT
hello-python-7ddcb6b95c-r52sd Running 2 hello-python 11-04-2021 09:37:35 pm PDT
hello-python-7ddcb6b95c-sns59 Running hello-python 11-04-2021 09:37:35 pm PDT
maira-agent-b8c9887c7-9g6r9 Running maira-agent 12-08-2021 03:57:24 pm PST
Mpl commands are an ever-growing list based on the integrations the platform supports. These commands are the only way to interact with the external world. The orchestration system (like Maira) is responsible for executing these commands. Execution typically involves calling an external API, and once the response is received, feed that to Mpl. The Maira platform supports a wide variety of integration commands to develop workflows in Mpl. The integration list and corresponding commands, supported by Maira, are outside this document's scope.
Custom commands:
Mpl executes the commands via the remote gateway. It communicates with a gateway on internal RPC. If the user wants to run some custom scripts/executables from Mpl, she can use raw mode. In raw mode, commands may or may not have a complete schema of the arguments. In this case, Mpl will pass those args in opaquely to the gateway. If the gateway accepts those args, the command will run successfully.
In raw mode, the command starts with !!
. Mpl variables must be prefixed with $
in this mode, else, Mpl will not resolve the variable. Quoting string is optional in this mode.
Above executes ps command on gateway listening on '10.1.1.120'.