Use mtl init to initialize the environment for mtl. Creates a workspace in current working directory.
mtl init Default values are: --name $(hostname) --dir $(pwd)
Initialize mtl with a specific name and base directory.
mtl init --name Targa.local --dir /home/alexh/mtlReturn a metadata value by specifying the name of the property.
mtl info --name|-n <property>Get the value of the name property.
mtl info --name namereturns ...
web1.local Get the value of the dir property.
mtl info -n dirreturns ...
/home/alexh/mtlUse mtl attribute to declare attributes about this instance.
Can describe properties and state.
mtl attribute -n listen_port -v 8080
mtl attribute -n mypath -v /my/path
mtl attribute -n status -v activeReturn the value of an attribute.
mtl attribute -n listen_port returns... 8080
Use a prefix in the attribute to organize them. Use machine-tags format.
mtl attribute -n namespace:predicate -v value Declare some attributes across several namespaces.
mtl attribute -n packages:tomcat -v tomcat-7.0.42.zip
mtl attribute -n packages:estore -v estore-1.0.42.war
mtl attribute -n estore:customer -v acme.com
mtl attribute -n estore:url -v http://192.168.50.12:8080/estore
mtl attribute -n tomcat:listen_port -v 8080
mtl attribute -n tomcat:catalina_base -v /home/tomcatAlternative mtl syntax using long option name for name and value parameters.
mtl attribute --name listen_port --value 8080Use attributes to model metrics.
mtl attribute -n metrics:estore.deploys -v 5
mtl attribute -n metrics:estore.restarts -v 5mtl attribute --name|-n <attribute> [--clear --remove]Clear the value for status.
mtl attribute -n status --clearRemove status.
mtl attribute -n status --removeUse mtl attributes to list all the attributes for this instance.
mtl attributesList attribute names in foo namespace.
mtl attributes -n "tomcat:*"returns...
tomcat:listen_port
tomcat:catalina_baseList attributes and show their values.
mtl attributes -n "tomcat:*" --valuereturns...
tomcat:listen_port 8080
tomcat:catalina_base /home/tomcatDeclare new commands with mtl command.
Define status command with an inline script:
mtl command -n status --script "curl -sf `mtl attribute -n estore:url`; exit $?"A stop command that executes a script file:
mtl command -n stop --scriptfile $(mtl info -n dir)/bin/stopDefine stop command but scriptfile is a url address:
mtl command -n stop --scriptfile http://repo/scriptDelegate command to another module. The other module must contain the same command.
mtl command -n start --delegate altmoduleList the commands with mtl commands.
mtl commandsreturns ...
start
status
stopList commands starting with 'sto':
mtl commands -n "sto*"returns ...
stopUse mtl exec to execute declared commands.
Execute start command defined in this instance:
mtl exec -n stopExecute a command with options:
mtl exec -n status --url $(mtl attribute estore:url)Execute a command in another mtl module
mtl exec -m othermodule -n commandUse mtl option to declare an option for a command.
mtl option -n <name> --command <> --arguments <> --default <> --description <>Create an option called --jumps for the command, dance:
mtl option -n jumps --command dance --arguments true --default 3 --description 'num times to jump'Changes usage for the dance command to:
mtl exec dance --jumps <3>Similar usage as stubbs:add-option.
Specify the command name:
mtl option --command dancereturns ...
jumpsThe mtl init initializes a directory structure and stores metadata for the new mtl instance
.
|-- attributes/
|-- commands/
`-- metadataThe metadata file contains the name and dir values used by mtl init
name="Targa.local"
dir="/home/alexh/mtl
created_at="Thu Jan 16 09:20:56 PST 2014"
created_by="alexh"The attributes and commands directory are discussed in sections below.
Attribute metadata stored in flat files
.
|-- attributes/
| |-- listen_port/
| |-- mypath/
| `-- status/
| `-- metadata
|-- commands/
`-- metadataThe metadata file contains the properties about the attribute
cat ./attributes/status/metadata
NAME="status"
VALUE="myvalue"Command metadata stored in flat files
.
|-- attributes/
|-- commands/
| |-- start/
| |-- status/
| `-- stop/
| `-- metadata
`-- metadataThe metadata file contains the properties about the attribute
cat ./commands/stop/metadata
NAME="stop"
DESCRIPTION="stop command"
OPTIONS=""mtl data can be shared with other nodes through synchronization of the mtl metadata. How synchronization is done depends on the backend.
Module containing backend implementation is defaulted to ... env_var or attribute?
The publish flag synchronizes mtl state with the backend.
Publish a single attribute to a backing store
mtl attribute -n myvar --publishPush all attributes matching pattern
mtl attributes -n "stuff:*" --publishPush the commands
mtl commands --publishThe refresh flag retrieves the latest update from the backing store.
Refresh value for attribute myvar
mtl attribute -n myvar --refreshPull all the attributes
mtl attributes --refreshA defaults system could store handlers for invoking user defined mtl commands.
Here a script handles calls to mtl defined commands.
mtl defaults handler --script "$(mtl exec ${1} ${2} ${@:3})"Turns user defined commands into mtl sub commands.
mtl stop --foo barDefault handler resolves to: mtl exec stop --foo bar
Alternative names to mtl.
meta.
meta attribute -n sayhi -v hi
meta command -n sayhi -script "echo ${1:-$(yo:attribute sayhi:message)}"
meta exec sayhi --message "hello"
meta sayhi --message "hello"node.
node attribute sayhi hi
node command sayhi -script "echo ${1:-$(yo:attribute sayhi:message)}"
node exec sayhi "hello"
node sayhi "hello"self.
self attribute sayhi:message hi
self attribute --name sayhi:message --value hi
self exec statusyo. Yo is self in spanish:
yo:attribute sayhi:message hi
yo:command sayhi -script "echo ${1:-$(yo:attribute sayhi:message)}"
yo:exec sayhi "hello"
yo:sayhi "hello"proto. because it's a prototype object system design:
proto:attribute fooattry value_1 ;# alternative namespace ideasobject. object system:
object:attribute fooattry value_1 ;# dittoinstance. same as object:
instance:attribute fooattry value_1 ;# dittomtl exec mtl command -n stop