rdkcentral / xts_allocator_server

The python code here will run a simple allocator service with a REST API, capable of managing rack slots for test devices
0 stars 0 forks source link

Initial creation of allocator server #1

Open TB-1993 opened 1 week ago

TB-1993 commented 1 week ago

Description:

Problem/Opportunity: Sharing test devices requires close management to prevent users from interrupting each other's tests.

Proposed Solution: Having a service to manage the allocation of shared devices would prevent users from attempting to use the same test device at the same time, preventing test interruptions. This would have the additional benefits of simplifying device management and promoting device sharing among the testing team.

Acceptance Criteria:

TB-1993 commented 9 hours ago

Below is a rough design of the yaml database and endpoints required

Client side

Allocator command:

xts alloc/allocate --id --platform --tags --duration --server
xts allocator list 
xts allocator search --platform --description --tags --server
xts deallocate --id
xts allocator add 
xts allocator remove --id
xts allocator server add
xts allocator server remove
xts allocator login

Allocator Configuration:

xts:
  servers:
    name:
      url:
        description:
    name2:
      url:
      description:

Server side

XTS Allocator Server

SQL Database

id: 123
  state: free/allocated/offline/maintenance/reservable
  owner:
  # Separate table with history maintained
  allocated:
    user:
    email:
    name:
    duration:
      start:
      end:
  devices: rackB03slot1.yaml
    # Populated from yaml
    name:
    description:
    tags:
     - pi2
     - remoteController
     - HDMICECController
     - powerController

Slot yamls

rackB03slot1.yaml
name:
description:
tags:
 - pi2
 - remoteController
 - HDMICECController
 - powerController
devices:
  - dut:
      ip: "127.0.0.1"  # IP Address of the ADA Hub
      platform: "linux PC"
      consoles:
        - default:
            type: "serial"
            port: "/dev/ttyUSB0"
        - ssh:
            port: 22
            username: "root"
            ip: "192.168.99.1"
      remoteController:
        type: "none"
        map: "skyq_map"
        config: "example_remote_commander.yml"
      outbound:
        download_url: "tftp://tftp-server.com/rack1/slot1/"    # download location for the CPE device
        upload_url: "sftp://server-address/home/workspace/tftp/rack1/slot1/" # upload location
        upload_url_base_dir: "sftp://server-address/home/workspace/tftp/rack1/slot1" # alternative upload location
        httpProxy: 'socks5h://localhost:1234'   # Local Proxy if required
        workspaceDirectory: './logs/workspace'   # Local working directory
      powerSwitch:
        type: "HS100"
        ip: "192.168.1.7"
        port: 9999
      # hdmiCECController: Specific hdmiCECController for the slot
         # supported types:
         # [type: "cec-client", adaptor: "/dev/ttycec"]
 - pi2:
     ip: "192.168.99.1"
     description: "local pi4"
     platform: "pi4"
     consoles:
      - ssh:
          type: "ssh"
          port: 22
          username: "root"

API Endpoints

xts allocate --id --platform --tags --duration --server POST /allocate_slot

xts allocator list GET /list_slots

xts allocator search --platform --description --tags --server POST /search_slots

xts deallocate --id POST /deallocate_slot

// Out of scope for first release xts allocator add POST /add_slot

xts allocator remove --id POST /remove_slot

TB-1993 commented 9 hours ago

I have begun looking into this, I'm currently thinking for simplicity, using Flask, and it's built in development server would be the quickest route to getting this out. This on top of a simple database backing (possibly just pickling dictionaries).