Module Name: rackController.py
Directory: framework/core/rackController.py
Purpose:
- Defines the structure and configuration of a testing rack.
- Manages slots within a rack, each slot potentially representing a device under test (DUT).
- Provides methods to access and retrieve information about racks and their associated devices.
Key Classes:
-
configDecoderClass:
- Base class that handles decoding of configuration settings.
- Checks for required fields in the configuration.
- Maps configuration items to specific handling functions.
-
rackSlot:
- Represents a single slot within a rack.
- Stores configuration details about the device in that slot:
- Device Name
- Remote control type
- IP address or hostname
- Platform type
- Outbound upload/download directories (for file exchange)
-
rack:
- Represents an entire testing rack.
- Contains a list of
rackSlotobjects. - Provides methods to get slots by index or name.
-
rackController:
- Top-level class managing multiple racks within the system.
- Decodes the main rack configuration file.
- Provides methods to get racks by index or name.
How to Use:
-
Configuration File: Create a configuration file (likely in YAML format) that defines the following:
- Racks: Each rack has a name and contains slots.
- Slots: Each slot defines the device within it, including its name, address, platform, etc.
-
Initialization: Include the
racks.pymodule and load the configuration. This initializes therackControllerand its internal representation of your racks. -
Accessing Information:
- Use methods of the
rackControllerto retrieve specific racks:getRackByName()getRackByIndex()
- Once you have a
rackobject:- Use
getSlot()orgetSlotByName()to get arackSlotobject. - Access device information from the
rackSlotobject.
- Use
- Use methods of the
Example:
YAML Configuration:
rack1:
name: MyTestingRack
slot1:
name: DUT1
deviceType: STB
address: 192.168.1.100
platform: XYZPython Code:
import racks
config = # Load your YAML configuration
racks_obj = racks.rackController(config)
my_rack = racks_obj.getRackByName("MyTestingRack")
device_slot = my_rack.getSlotByName("DUT1")
ip_address = device_slot.getDeviceIp()
platform = device_slot.getPlatform()
print("Device IP:", ip_address)
print("Device Platform:", platform)