Skip to content

Commit 40acb67

Browse files
authored
Update ReadMe example (#25)
1 parent 2855f7b commit 40acb67

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,21 @@ with Ankaios() as ankaios:
109109
except AnkaiosException as e:
110110
print("Ankaios Exception occured: ", e)
111111

112-
# Request the state of the system, filtered with the agent name
112+
# Request the state of the system, filtered with the workloadStates
113113
complete_state = ankaios.get_state(
114114
timeout=5,
115-
field_masks=["workloadStates.agent_A"])
115+
field_masks=["workloadStates"])
116116

117117
# Get the workload states present in the complete_state
118118
workload_states_dict = complete_state.get_workload_states().get_as_dict()
119119

120120
# Print the states of the workloads:
121-
for workload_name in workload_states_dict["agent_A"]:
122-
for workload_id in workload_states_dict["agent_A"][workload_name]:
123-
print(f"Workload {workload_name} with id {workload_id} has the state "
124-
+ str(workload_states_dict["agent_A"] \
125-
[workload_name][workload_id].state))
121+
for agent_name in workload_states_dict:
122+
for workload_name in workload_states_dict[agent_name]:
123+
for workload_id in workload_states_dict[agent_name][workload_name]:
124+
print(f"Workload {workload_name} on agent {agent_name} has the state "
125+
+ str(workload_states_dict[agent_name] \
126+
[workload_name][workload_id].state))
126127
```
127128

128129
For more details, please visit the [Documentation](https://eclipse-ankaios.github.io/ank-sdk-python/).

0 commit comments

Comments
 (0)