alab_management.device_manager module#
This module is adapted from Mause/rpc.
The task process can only get access to a wrapper over the real device object. The wrapper will redirect all the method calls to the real device object via RabbitMQ. The real device object is in DeviceManager class, which will handle all the request to run certain methods on the real device.
- class DeviceManager(_check_status=True)[source]#
Bases:
objectDevice manager is basically a rabbitmq-backed RPC server, which receives and executes commands on the device drivers, as requested by the task process.
- class DeviceMethodCallState[source]#
Bases:
objectholds the status of a pending method call to a device.
-
future:
Future#
-
last_updated:
float#
-
status:
MethodCallStatus#
-
future:
- class DeviceWrapper(name, devices_client)[source]#
Bases:
objectA wrapper over the device.
- class DeviceMethodWrapper(device_name, method, method_handler)[source]#
Bases:
objectA wrapper over a device method.
- property method: str#
The name of the method.
- property name: str#
The name of the device.
- class DevicesClient(task_id, timeout=None)[source]#
Bases:
objectA rabbitmq-backed RPC client for sending device requests to the Device Manager (server).
Use
create_device_wrapperto create Device Wrapper instance.- call(device_name, method, *args, **kwargs)[source]#
Call a method inside the device with name
device_name. args, kwargs will be feeded into the method directly.- Parameters:
device_name (
str) – the name of device, which is defined by administer.method (
str) – the class method to callargs – positional arguments to feed into the method function
kwargs – keyword arguments to feed into the method function
- Return type:
Any- Returns:
the result of function