ATS Client¶
The base ATS Client class(es) for KISS ATS
-
class
kissats.ats_client.
BaseATSClient
¶ Bases:
object
Base ATS Client Class
-
ats_server
¶ The address of the ATS Server
-
claim_reservation
(pre_reservation_id)¶ Claim a pre-reserved resource.
- If the reservation is claimed late and will not be available for the entire reservation_duration an exception will be raised.
- If claimed late and another slot is available a new pre-reservation will be provided, see Returns below
Parameters: pre_reservation_id (str) – The pre_reservation_id returned by get_future_reservation Returns: - Min keys if success
- reservation_id(str): if the reservation is a success.
- expire_time(float): epoch time when the reservation expires
- resource_config(object): Current configuration of the resource
- Min keys if failure
- pre_reservation_id (str): new pre_reservation ID
- new_avail (float): New available time
- new_expire (float): New expiration time
Return type: dict Raises: ResourceUnavailable
-
get_all_resources
()¶ Get a list of all resources managed by the ATS
Returns: List of all resources managed by the ATS Return type: list
-
get_available_resources
()¶ Get a list of available resources
Returns: List of available resources Return type: list
-
get_resource_availablity
(resource, start_time=None, end_time=None)¶ Get the time when a resource will become available.
If the resource is not available at the time requested, avail_start and avail_end will be the soonest time slot available.
Parameters: Returns: - min keys:
- available (bool) True if available at the time requested
- avail_start (float)
- avail_end (float)
Return type:
-
get_resource_config
(resource)¶ Get the current configuration of a resource
Parameters: resource (str) – name of resource Returns: the current configuration of the resource Return type: object
-
release_resource
(reservation_id)¶ Release a previously reserved resource
Parameters: reservation_id (str) – reservation_id or pre-reservation_id of resource Returns: True if released Return type: bool
-
request_reservation
(resource, res_config=None, time_needed=None, reservation_duration=3600.0, next_available=True, reservation_mode='exclusive')¶ Request resource reservation with an optional configuration.
this will put a preliminary lock on the resource, the final lock must be requested after the time_available using claim_reservation
Parameters: - resource (str) – The name of the resource requested
- res_config (object) – An object that can be serialized for transmission to the server. This optional object will define the requested configuration.
- time_needed (float) – time.time time the resource is needed. if not provided, default is now
- reservation_duration (float) – seconds the resource is requested for defaults to 3600 (1 hour)
- next_available (bool) – If the requested time_needed is not available, request the next available time.
- reservation_mode (str) – “exclusive” or “shared”, default “exclusive”
Returns: - (str): UUID of pre-reservation.
- (float): epoch time resource will be available with the requested configuration.
- (float): epoch time the pre_reservation_ID will expire.
Return type: tuple
Raises: ResourceUnavailable
-
server_communicate
(server_request)¶ Send a command to the server and return the server reply
Parameters: server_request (dict) – the request to be sent with a key “command”, all other keys will be placed in the extra data Returns: Dictionary of unflattened reply Return type: dict Raises: ServerCommandMissing
-