This document provides instructions for setting up the development environment, running the application, and using the command-line interface (CLI).
-
Clone the repository:
git clone <repository-url> cd hiring-challenge-devops-python
-
Build and start the services:
Use Docker Compose to build the images and start the API, database, and other services. The
--profile devflag is used to activate the development-related services.docker compose up db -d docker compose --profile dev up --build -d
-
Apply database migrations:
Should run atomatically
-
Run test:
docker compose run --build --rm test-runner
The CLI provides a convenient way to interact with the server inventory management system.
Create a new server.
Usage:
python3 cli/main.py create <HOSTNAME> <IP_ADDRESS> <STATE>Arguments:
| Argument | Description | Required |
|---|---|---|
HOSTNAME |
Server hostname | Yes |
IP_ADDRESS |
Server IP address | Yes |
STATE |
Server state (active, offline, retired) | Yes |
Example:
python3 cli/main.py create "web-server-01" "192.168.1.10" "active"List all servers in the inventory.
Usage:
python3 cli/main.py listExample:
python3 cli/main.py listRetrieve a single server by its ID.
Usage:
python3 cli/main.py get <SERVER_ID>Arguments:
| Argument | Description | Required |
|---|---|---|
SERVER_ID |
ID of the server to retrieve | Yes |
Example:
python3 cli/main.py get 1Update a server's details.
Usage:
python3 cli/main.py update <SERVER_ID> <HOSTNAME> <IP_ADDRESS> <STATE>Arguments:
| Argument | Description | Required |
|---|---|---|
SERVER_ID |
ID of the server to update | Yes |
HOSTNAME |
New server hostname | Yes |
IP_ADDRESS |
New server IP address | Yes |
STATE |
New server state (active, offline, retired) | Yes |
Example:
python3 cli/main.py update 1 "updated-server-01" "192.168.1.11" "offline"Delete a server from the inventory.
Usage:
python3 cli/main.py delete <SERVER_ID>Arguments:
| Argument | Description | Required |
|---|---|---|
SERVER_ID |
ID of the server to delete | Yes |
Example:
python3 cli/main.py delete 1To run the test suite, use the test-runner service. This will set up a dedicated test database, apply migrations, and then execute the tests.
docker-compose --profile test up --build --abort-on-container-exit