Workload State
This module defines various classes and enumerations related to the state of workloads. It provides functionality to interpret and manage the states and sub-states of workloads, including converting between different representations and handling collections of workload states.
Classes
- WorkloadExecutionState
Represents the execution state and sub-state of a workload.
- WorkloadInstanceName:
Represents the name of a workload instance.
- WorkloadState:
Represents the state of a workload (execution state and name).
- WorkloadStateCollection:
A collection of workload states.
Enums
- WorkloadStateEnum:
Enumeration for different states of a workload.
- WorkloadSubStateEnum:
Enumeration for different sub-states of a workload.
Usage
- Get all workload states:
workload_state_collection = WorkloadStateCollection() list_of_workload_states = workload_state_collection.get_as_list() dict_of_workload_states = workload_state_collection.get_as_dict()
- Unpack a workload state:
workload_state = WorkloadState() agent_name = workload_state.workload_instance_name.agent_name workload_name = workload_state.workload_instance_name.workload_name state = workload_state.execution_state.state substate = workload_state.execution_state.substate info = workload_state.execution_state.additional_info
- Get the workload instance name as a dictionary:
workload_instance_name = WorkloadInstanceName() instance_name_dict = workload_instance_name.to_dict() json_instance_name = json.dumps(instance_name_dict)
WorkloadExecutionState Class
- class ankaios_sdk._components.workload_state.WorkloadExecutionState(state)[source]
Bases:
object
Represents the execution state of a workload.
- state
The state of the workload.
- Type:
- substate
The sub-state of the workload.
- Type:
- additional_info
Additional information about the workload state.
- Type:
str
WorkloadInstanceName Class
- class ankaios_sdk._components.workload_state.WorkloadInstanceName(agent_name, workload_name, workload_id)[source]
Bases:
object
Represents the name of a workload instance.
- agent_name
The name of the agent.
- Type:
str
- workload_name
The name of the workload.
- Type:
str
- workload_id
The ID of the workload.
- Type:
str
- __init__(agent_name, workload_name, workload_id)[source]
Initializes a WorkloadInstanceName instance.
- Parameters:
agent_name (str) – The name of the agent.
workload_name (str) – The name of the workload.
workload_id (str) – The ID of the workload.
- __str__()[source]
Returns the string representation of the workload instance name.
- Returns:
The string representation of the workload instance name.
- Return type:
str
WorkloadState Class
- class ankaios_sdk._components.workload_state.WorkloadState(agent_name, workload_name, workload_id, state)[source]
Bases:
object
Represents the state of a workload.
- execution_state
The execution state of the workload.
- Type:
- workload_instance_name
The name of the workload instance.
- Type:
- __init__(agent_name, workload_name, workload_id, state)[source]
Initializes a WorkloadState instance.
- Parameters:
agent_name (str) – The name of the agent.
workload_name (str) – The name of the workload.
workload_id (str) – The ID of the workload.
state (WorkloadExecutionState) – The execution state.
WorkloadStateCollection Class
- class ankaios_sdk._components.workload_state.WorkloadStateCollection[source]
Bases:
object
A class that represents a collection of workload states and provides methods to manipulate them.
- ExecutionsStatesForId
alias of
dict
[str
,WorkloadExecutionState
]
- ExecutionsStatesOfWorkload
alias of
dict
[str
,dict
[str
,WorkloadExecutionState
]]
- WorkloadStatesMap
alias of
dict
[str
,dict
[str
,dict
[str
,WorkloadExecutionState
]]]
- add_workload_state(state)[source]
Adds a workload state to the collection.
- Parameters:
state (WorkloadState) – The workload state to add.
- Return type:
None
- get_as_dict()[source]
Returns the workload states as a dict.
- Returns:
A dict of workload states.
- Return type:
WorkloadStatesMap
- get_as_list()[source]
Returns the workload states as a list.
- Returns:
A list of workload states.
- Return type:
list[WorkloadState]
- get_for_instance_name(instance_name)[source]
Returns the workload state for the given workload instance name.
- Parameters:
instance_name (WorkloadInstanceName) – The workload instance name to look up.
- Returns:
The workload state for the given instance name. None: If no workload state was found.
- Return type:
WorkloadStateEnum
- class ankaios_sdk._components.workload_state.WorkloadStateEnum(value)[source]
Bases:
Enum
Enumeration for different states of a workload.
-
AGENT_DISCONNECTED:
int
= 0 The agent is disconnected.
- Type:
(int)
-
PENDING:
int
= 1 The workload is pending.
- Type:
(int)
-
RUNNING:
int
= 2 The workload is running.
- Type:
(int)
-
STOPPING:
int
= 3 The workload is stopping.
- Type:
(int)
-
SUCCEEDED:
int
= 4 The workload has succeeded.
- Type:
(int)
-
FAILED:
int
= 5 The workload has failed.
- Type:
(int)
-
NOT_SCHEDULED:
int
= 6 The workload is not scheduled.
- Type:
(int)
-
REMOVED:
int
= 7 The workload has been removed.
- Type:
(int)
-
AGENT_DISCONNECTED:
WorkloadSubStateEnum
- class ankaios_sdk._components.workload_state.WorkloadSubStateEnum(value)[source]
Bases:
Enum
Enumeration for different sub-states of a workload.
-
AGENT_DISCONNECTED:
int
= 0 The agent is disconnected.
- Type:
(int)
-
PENDING_INITIAL:
int
= 1 The workload is in the initial pending state.
- Type:
(int)
-
PENDING_WAITING_TO_START:
int
= 2 The workload is waiting to start.
- Type:
(int)
-
PENDING_STARTING:
int
= 3 The workload is starting.
- Type:
(int)
-
PENDING_STARTING_FAILED:
int
= 4 The workload failed to start.
- Type:
(int)
-
RUNNING_OK:
int
= 5 The workload is running successfully.
- Type:
(int)
-
STOPPING:
int
= 6 The workload is stopping.
- Type:
(int)
-
STOPPING_WAITING_TO_STOP:
int
= 7 The workload is waiting to stop.
- Type:
(int)
-
STOPPING_REQUESTED_AT_RUNTIME:
int
= 8 The workload stop was requested at runtime.
- Type:
(int)
-
STOPPING_DELETE_FAILED:
int
= 9 The workload stop failed to delete.
- Type:
(int)
-
SUCCEEDED_OK:
int
= 10 The workload succeeded successfully.
- Type:
(int)
-
FAILED_EXEC_FAILED:
int
= 11 The workload failed due to execution failure.
- Type:
(int)
-
FAILED_UNKNOWN:
int
= 12 The workload failed due to an unknown reason.
- Type:
(int)
-
FAILED_LOST:
int
= 13 The workload failed because it was lost.
- Type:
(int)
-
NOT_SCHEDULED:
int
= 14 The workload is not scheduled.
- Type:
(int)
-
REMOVED:
int
= 15 The workload has been removed.
- Type:
(int)
-
AGENT_DISCONNECTED: