Blame docs/apps/duffy/Usage.md

fd40ec
## CLI usage overview
fd40ec
fd40ec
```
fd40ec
duffy --help
fd40ec
```
fd40ec
fd40ec
The rewritten version of Duffy includes a lot of functionality under one umbrella, making it convenient for the maintainers to operate upon the following things from a single command.
fd40ec
fd40ec
1. [Configuring the variables](https://github.com/CentOS/duffy/wiki/Usage#the-config-command)
fd40ec
2. [Migrating the database](https://github.com/CentOS/duffy/wiki/Usage#the-migration-command)
fd40ec
3. [Serving the primary web application](https://github.com/CentOS/duffy/wiki/Usage#the-serve-command)
fd40ec
4. [Serving the legacy web application](https://github.com/CentOS/duffy/wiki/Usage#the-serve-legacy-command)
fd40ec
5. [Setting up the database](https://github.com/CentOS/duffy/wiki/Usage#the-setup-db-command)
fd40ec
6. [Interact with a running instance](https://github.com/CentOS/duffy/wiki/Usage#the-shell-command)
fd40ec
7. Starting a backend processor 
fd40ec
fd40ec
```
fd40ec
Usage: duffy [OPTIONS] COMMAND [ARGS]...
fd40ec
fd40ec
Options:
fd40ec
  -c, --config FILE  Read option defaults from the specified YAML file.
fd40ec
                     [default: /etc/duffy.yaml]
fd40ec
  --version          Show the version and exit.
fd40ec
  --help             Show this message and exit.
fd40ec
fd40ec
Commands:
fd40ec
  config        Check and dump configuration.
fd40ec
  migration     Handle database migrations.
fd40ec
  serve         Run the Duffy web application server.
fd40ec
  serve-legacy  Serve the Duffy Metaclient for Legacy Support app.
fd40ec
  setup-db      Create tables from the database model.
fd40ec
  shell         Run an interactive shell.
fd40ec
  worker        Start a Celery worker to process backend tasks.
fd40ec
```
fd40ec
fd40ec
We will go in detail about each of the aforementioned functionalities in the sections below.
fd40ec
fd40ec
### The `config` command
fd40ec
fd40ec
To understand how the config command makes use of a YAML-based configuration, please refer to [the configuration documentation](https://github.com/CentOS/duffy/wiki/Configuration).
fd40ec
fd40ec
```
fd40ec
duffy config --help
fd40ec
```
fd40ec
fd40ec
Duffy is written to be flexible enough to allow for smaller configurations (like setting log levels for an operation, selecting port number for publishing etc.) to be quickly appended to the command as options as well as for bigger configurations (like setting up the worker environment, pointing to Ansible Playbook locations etc.) to be descriptively specified in a YAML-based configuration file. The subcommands included in the CLI allows for verifying the correctness of and, dumping merged configurations of the latter kind.
fd40ec
fd40ec
```
fd40ec
Usage: duffy config [OPTIONS] COMMAND [ARGS]...
fd40ec
fd40ec
  Check and dump configuration.
fd40ec
fd40ec
Options:
fd40ec
  --help  Show this message and exit.
fd40ec
fd40ec
Commands:
fd40ec
  check  Validate configuration structure.
fd40ec
  dump   Dump merged configuration.
fd40ec
```
fd40ec
fd40ec
### The `migration` command
fd40ec
fd40ec
```
fd40ec
duffy migration --help
fd40ec
```
fd40ec
fd40ec
With the use of SQLAlchemy, the interactions with the database are abstracted enough such that, Duffy becomes agnostic of the kind of database that it makes use of. It does allow for migrating schemas and managing changes with the use of the said command. The command requires URL of the database for both synchronous and asynchronous operations with it. As Duffy is agnostic of what database it makes use of, any kind of relational database can be used but we strongly recommend the use of Postgres.
fd40ec
fd40ec
```
fd40ec
Usage: duffy migration [OPTIONS] COMMAND [ARGS]...
fd40ec
fd40ec
  Handle database migrations.
fd40ec
fd40ec
Options:
fd40ec
  --help  Show this message and exit.
fd40ec
fd40ec
Commands:
fd40ec
  create      Create a new migration.
fd40ec
  db-version
fd40ec
  downgrade
fd40ec
  upgrade
fd40ec
```
fd40ec
fd40ec
### The `serve` command
fd40ec
fd40ec
```
fd40ec
duffy serve --help
fd40ec
```
fd40ec
fd40ec
The primary web server is the main interface with which clients can connect to Duffy and perform tasks like create a session, request baremetal or virtual nodes etc. The server can be started up using the aforementioned command by providing parameters like host address, port number, log level etc. These variables can either be passed as options appended to a command or be listed under the `app` section of the YAML-based configuration file. 
fd40ec
fd40ec
```
fd40ec
Usage: duffy serve [OPTIONS]
fd40ec
fd40ec
  Run the Duffy web application server.
fd40ec
fd40ec
  Duffy is the middle layer running ci.centos.org that manages the
fd40ec
  provisioning, maintenance, teardown and rebuild of the Nodes (physical
fd40ec
  hardware and virtual machines) that are used to run the tests in the CI
fd40ec
  Cluster.
fd40ec
fd40ec
Options:
fd40ec
  --reload / --no-reload          Automatically reload if the code is changed.
fd40ec
  -H, --host TEXT                 Set the host address to listen on.
fd40ec
  -p, --port INTEGER RANGE        Set the port value.  [1<=x<=65535]
fd40ec
  -l, --loglevel [critical|error|warning|info|debug|trace]
fd40ec
                                  Set the log level.
fd40ec
  --help                          Show this message and exit.
fd40ec
```
fd40ec
fd40ec
### The `serve-legacy` command
fd40ec
fd40ec
```
fd40ec
duffy serve-legacy --help
fd40ec
```
fd40ec
fd40ec
The legacy web server is the secondary interface for existing clients of legacy Duffy that provides for a 1:1 compatibility with the older endpoints. Clients can connect here to do the same tasks that they could in the primary interface with minimal changes to the workflow. As like the primary interface, this command can be customized with the use of appended options or as variables under the `metaclient` section of the YAML-based configuration file.
fd40ec
fd40ec
```
fd40ec
Usage: duffy serve-legacy [OPTIONS]
fd40ec
fd40ec
  Serve the Duffy Metaclient for Legacy Support app.
fd40ec
fd40ec
  Duffy is the middle layer running ci.centos.org that manages the
fd40ec
  provisioning, maintenance and teardown / rebuild of the Nodes (physical
fd40ec
  hardware for now, VMs coming soon) that are used to run the tests in the CI
fd40ec
  Cluster.
fd40ec
fd40ec
  This metaclient exposes older endpoints for legacy support and connects them
fd40ec
  to the path operations introduced by the newer version of the Duffy
fd40ec
  endpoint, until the support for the older endpoints is deprecated.
fd40ec
fd40ec
Options:
fd40ec
  --reload / --no-reload          Automatically reload if the code is changed.
fd40ec
  -H, --host TEXT                 Set the host address to listen on.
fd40ec
  -p, --port INTEGER RANGE        Set the port value.  [1<=x<=65535]
fd40ec
  -D, --dest TEXT                 Set the destination address of Duffy
fd40ec
                                  deployment.
fd40ec
  -l, --loglevel [critical|error|warning|info|debug|trace]
fd40ec
                                  Set the log level.
fd40ec
  --help                          Show this message and exit.
fd40ec
```
fd40ec
fd40ec
### The `setup-db` command
fd40ec
fd40ec
```
fd40ec
duffy setup-db --help
fd40ec
```
fd40ec
fd40ec
According to the database of the maintainer's choice, Duffy can set up tables from the included database model. To facilitate for a development and testing environment, contributors can also populate the created database with test data - although the same database must not be used in a production environment. The command requires URL of the database for both synchronous and asynchronous operations with it. As Duffy is agnostic of what database it makes use of, any kind of relational database can be used but we strongly recommend the use of Postgres.
fd40ec
fd40ec
```
fd40ec
Usage: duffy setup-db [OPTIONS]
fd40ec
fd40ec
  Create tables from the database model.
fd40ec
fd40ec
Options:
fd40ec
  --test-data / --no-test-data  Initialized database with test data.
fd40ec
  --help                        Show this message and exit.
fd40ec
```
fd40ec
fd40ec
### The `shell` command
fd40ec
fd40ec
```
fd40ec
duffy shell --help
fd40ec
```
fd40ec
fd40ec
Performing management tasks on a currently running instance of Duffy is made possible with the inclusion of an interactive shell - that can be run on the same environment as the one where the application is deployed. The shell can be managed either by a Python interpreter or an IPython interpreter - with IPython providing additional enrichment to a normal REPL-based interface. Maintainers can use the shell to perform CRUD operations on the attached database with respect to sessions, tenants, nodes, projects etc.
fd40ec
fd40ec
```
fd40ec
Usage: duffy shell [OPTIONS]
fd40ec
fd40ec
  Run an interactive shell.
fd40ec
fd40ec
Options:
fd40ec
  -t, --shell-type [python|ipython]
fd40ec
                                  Type of interactive shell to use.
fd40ec
  --help                          Show this message and exit.
fd40ec
```