Blob Blame History Raw
# SOP to create Duffy tenant
This SOP covers the process of how to create a duffy tenant

## Steps
1. Connect to duffy.ci.centos.org 
```shell
ssh duffy.ci.centos.org
```

2. Change to duffy user
```shell
sudo su - duffy
```

3. Create tenant with the command below and save api key somewhere safe, it outputs the key as `<tenant name>: <API key>`
```shell
duffy admin create-tenant <tenant name> <ssh pub-key>
``` 

4. Connect to the host that will have duffy client
```shell
ssh <host user>@<target host>
```

5. Install duffy client using `pip`
```shell
pip3.8 install --user duffy[client]
```

6. In the home path of the user, create `.config` directory if it doesn’t exist and create `.config/duffy` with the following content
```
client:
  url: https://duffy.ci.centos.org/api/v1
  auth:
    name: <tenant name>
    key: <API key>
```

7. To create a session, the name of the pool is required. Check the pool available executing the command **_(Optional)_**
```shell
duffy client list-pools
```

8. Request a session
```shell
duffy client request-session pool=<name of the pool>,quantity=<number of sessions wanted>
``` 

By default this command outputs a _json_, but it's possible to change the format to _yaml_ or _flat_ using `--format`. Under "node" key it's possible to find the hostname to be used. Log in to it as `root` user, using `ssh`.

```json
{
...output ommited...

"nodes": [
    {
        "hostname": "<hostname>.ci.centos.org",
        "ipaddr": "<ip address>",

...output ommited...
}
```

9. When needed to retire the session, connect to your duffy client host and execute the command
```shell
duffy client retire-session <session id>
```

It's possible to check the session id either when the session is requested, in the output under "session" key, or using the following command:
```shell
duffy client list-sessions
```