Introduction
Learn how to use Luxor's open source api tool.
Welcome to Luxos tooling
The luxos python package provides:
- A cli script
luxos
, allowing to run a single command on miners - A script
luxos-run
to run scriptlets on miners in parallel (using asyncio) - A consistent API to access miners functionality through the the
luxos
python package
For simple to follow example on how to use the API, click here.
Install
Detailed instruction on how to install it are provided 👉 here, to install the latest released code:
luxos
command line tool
The luxos python package comes with a command line script
called luxos
: it can issue a command (with parameters) to a list of miners' ips
in a csv file.
This will launch the version command on a miner, returning the json output:
The --range
flag can take:
- a single ip address, eg:
--range 127.0.0.1
- a range like:
--range 127.0.0.1-127.0.0.5
- or addresses from a file:
--range @miners.csv
.
Other examples:
NOTE
--ipfile
is an alternative way to load miners from a csv file, it's the same as--range
flag: it can take addresses like127.0.0.1
, ranges as127.0.0.1-127.0.0.5
or filenames as@miners.csv
.- you can use the
--json
to save the results in json format (to stdout).
luxos-run
command line tool
The luxos-run
is an alternative to luxos
command line script,
allowing to run as scriptlet (a small python script) targeting miners:
a scriptlet usually can contain some logic and or longer commands sequences.
hello-world.py scriplet:
Running the luxos-run
will execute the scriptlet aggregating the results in
a dictionary with key set to the miner address:
The python api
luxos python package comes with an API to support miners operations. The main fuctions are stored in the module for convenience and they are:
- luxos.util.load_ips_from_csv - utility to load miners addresses from a CSV file
- luxos.util.rexec - an async function to launch commands on a miner
- luxos.util.execute_command -
the syncronous
rexec
version - luxos.util.validate - validate a message from a miner
- luxos.util.launch - run a command on multiple miners
the rexec function
The rexec function allows to send a command to a miner and return the response:
The full signature for rexec
takes care of formatting the parameters, the full signature is:
parameters
can be a string, a list of any type (it will be converted into a str)
or a dictionary (same conversion to string will apply).
timeout
is the timeout for a call retry
is the number of try
before giving up retry_delay
controls the delay between retry.
NOTE
rexec
is an async function, but there's a sync version underluxos.syncops.rexec
.
launch
The luxos.utils.lauch
allows to rexec commands to a list of miners stored in a csv file.
This all-in-one function, allows batched operations on a set of miners, taking care of all details.