Skip to content

Latest commit

 

History

History
159 lines (102 loc) · 3.31 KB

File metadata and controls

159 lines (102 loc) · 3.31 KB

Developer Documentation

This document provides instructions for setting up the development environment, running the application, and using the command-line interface (CLI).

🚀 Getting Started

Prerequisites

Environment Setup

  1. Clone the repository:

    git clone <repository-url>
    cd hiring-challenge-devops-python
  2. Build and start the services:

    Use Docker Compose to build the images and start the API, database, and other services. The --profile dev flag is used to activate the development-related services.

    docker compose up  db -d
    docker compose --profile dev up --build -d
  3. Apply database migrations:

    Should run atomatically

  4. Run test:

    docker compose run --build --rm test-runner

CLI Usage

The CLI provides a convenient way to interact with the server inventory management system.

create

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

List all servers in the inventory.

Usage:

python3 cli/main.py list

Example:

python3 cli/main.py list

get

Retrieve 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 1

update

Update 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

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 1

🧪 Running Tests

To 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