ankaios-sdk 0.5.0rc2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. ankaios_sdk-0.5.0rc2/LICENSE +202 -0
  2. ankaios_sdk-0.5.0rc2/MANIFEST.in +8 -0
  3. ankaios_sdk-0.5.0rc2/PKG-INFO +144 -0
  4. ankaios_sdk-0.5.0rc2/README.md +109 -0
  5. ankaios_sdk-0.5.0rc2/ankaios_sdk/__init__.py +41 -0
  6. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/__init__.py +43 -0
  7. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/complete_state.py +317 -0
  8. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/manifest.py +162 -0
  9. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/request.py +159 -0
  10. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/response.py +234 -0
  11. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/workload.py +791 -0
  12. ankaios_sdk-0.5.0rc2/ankaios_sdk/_components/workload_state.py +488 -0
  13. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/__init__.py +34 -0
  14. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/ank_base.proto +376 -0
  15. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/ank_base_pb2.py +154 -0
  16. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/ank_base_pb2_grpc.py +24 -0
  17. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/control_api.proto +65 -0
  18. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/control_api_pb2.py +43 -0
  19. ankaios_sdk-0.5.0rc2/ankaios_sdk/_protos/control_api_pb2_grpc.py +24 -0
  20. ankaios_sdk-0.5.0rc2/ankaios_sdk/ankaios.py +937 -0
  21. ankaios_sdk-0.5.0rc2/ankaios_sdk/exceptions.py +78 -0
  22. ankaios_sdk-0.5.0rc2/ankaios_sdk/utils.py +77 -0
  23. ankaios_sdk-0.5.0rc2/ankaios_sdk.egg-info/PKG-INFO +144 -0
  24. ankaios_sdk-0.5.0rc2/ankaios_sdk.egg-info/SOURCES.txt +83 -0
  25. ankaios_sdk-0.5.0rc2/ankaios_sdk.egg-info/dependency_links.txt +1 -0
  26. ankaios_sdk-0.5.0rc2/ankaios_sdk.egg-info/requires.txt +15 -0
  27. ankaios_sdk-0.5.0rc2/ankaios_sdk.egg-info/top_level.txt +2 -0
  28. ankaios_sdk-0.5.0rc2/pyproject.toml +3 -0
  29. ankaios_sdk-0.5.0rc2/setup.cfg +33 -0
  30. ankaios_sdk-0.5.0rc2/setup.py +139 -0
  31. ankaios_sdk-0.5.0rc2/tests/__init__.py +13 -0
  32. ankaios_sdk-0.5.0rc2/tests/response/__init__.py +13 -0
  33. ankaios_sdk-0.5.0rc2/tests/response/test_response.py +131 -0
  34. ankaios_sdk-0.5.0rc2/tests/response/test_response_event.py +41 -0
  35. ankaios_sdk-0.5.0rc2/tests/test_ankaios.py +869 -0
  36. ankaios_sdk-0.5.0rc2/tests/test_complete_state.py +288 -0
  37. ankaios_sdk-0.5.0rc2/tests/test_manifest.py +154 -0
  38. ankaios_sdk-0.5.0rc2/tests/test_request.py +90 -0
  39. ankaios_sdk-0.5.0rc2/tests/test_utils.py +35 -0
  40. ankaios_sdk-0.5.0rc2/tests/workload/__init__.py +13 -0
  41. ankaios_sdk-0.5.0rc2/tests/workload/test_workload.py +347 -0
  42. ankaios_sdk-0.5.0rc2/tests/workload/test_workload_builder.py +208 -0
  43. ankaios_sdk-0.5.0rc2/tests/workload_state/__init__.py +13 -0
  44. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_execution_state.py +54 -0
  45. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_instance_name.py +59 -0
  46. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_state.py +55 -0
  47. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_state_collection.py +142 -0
  48. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_state_enum.py +35 -0
  49. ankaios_sdk-0.5.0rc2/tests/workload_state/test_workload_substate_enum.py +85 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ # Include all .proto files in the _protos directory
2
+ recursive-include ankaios_sdk/_protos *.proto
3
+
4
+ # Include the README file
5
+ include README.md
6
+
7
+ # Include the license file
8
+ include LICENSE
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.1
2
+ Name: ankaios-sdk
3
+ Version: 0.5.0rc2
4
+ Summary: Eclipse Ankaios Python SDK - provides a convenient Python interface for interacting with the Ankaios platform.
5
+ Home-page: https://eclipse-ankaios.github.io/ankaios/latest/
6
+ Author: Elektrobit Automotive GmbH and Ankaios contributors
7
+ License: Apache-2.0
8
+ Project-URL: Documentation, https://eclipse-ankaios.github.io/ankaios/latest/
9
+ Project-URL: Source, https://github.com/eclipse-ankaios/ank-sdk-python
10
+ Project-URL: Bug Tracker, https://github.com/eclipse-ankaios/ank-sdk-python/issues
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: protobuf==5.27.2
23
+ Requires-Dist: PyYAML
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Requires-Dist: pytest-cov; extra == "dev"
27
+ Requires-Dist: pylint; extra == "dev"
28
+ Requires-Dist: pycodestyle; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: sphinx; extra == "docs"
31
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
32
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
33
+ Requires-Dist: sphinx-mdinclude; extra == "docs"
34
+ Requires-Dist: google-api-python-client; extra == "docs"
35
+
36
+ <picture style="padding-bottom: 1em;">
37
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_dark_bgrd_clipped.png">
38
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_light_bgrd_clipped.png">
39
+ <img alt="Shows Ankaios logo" src="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_light_bgrd_clipped.png">
40
+ </picture>
41
+
42
+ # Ankaios Python SDK for Eclipse Ankaios
43
+
44
+ Eclipse Ankaios provides workload and container orchestration for automotive
45
+ High Performance Computers (HPCs). While it can be used for various fields of
46
+ applications, it is developed from scratch for automotive use cases and provides
47
+ a slim yet powerful solution to manage containerized applications.
48
+
49
+ The Python SDK provides easy access from the container (workload) point-of-view
50
+ to manage the Ankaios system. A workload can use the Python SDK to run other workloads
51
+ and get the state of the Ankaios system.
52
+
53
+ ## Installation
54
+
55
+ ### Install via pip
56
+
57
+ ```sh
58
+ pip install ankaios-sdk
59
+ ```
60
+
61
+ ### Clone and Local Build
62
+
63
+ ```sh
64
+ # Clone repository
65
+ git clone https://github.com/eclipse-ankaios/ank-sdk-python.git
66
+ cd ank-sdk-python
67
+
68
+ # Install in editable mode
69
+ pip install -e .
70
+
71
+ # If you plan on contributing or running tests locally
72
+ pip install -e ".[dev]"
73
+ ```
74
+
75
+ > **Note:**
76
+ > Depending on your Linux distribution, it could be that you need to create and activate a [virtual environment](https://docs.python.org/3/library/venv.html) to run the pip commands.
77
+
78
+ ## Usage
79
+
80
+ After installation, you can use the Ankaios SDK to configure and run workloads and request
81
+ the state of the Ankaios system and the connected agents.
82
+
83
+ Example:
84
+ ```python
85
+ from ankaios_sdk import Workload, Ankaios, WorkloadStateEnum, WorkloadSubStateEnum
86
+
87
+ # Create a new Ankaios object.
88
+ # The connection to the control interface is automatically done at this step.
89
+ ankaios = Ankaios()
90
+
91
+ # Create a new workload
92
+ workload = Workload.builder() \
93
+ .workload_name("dynamic_nginx") \
94
+ .agent_name("agent_A") \
95
+ .runtime("podman") \
96
+ .restart_policy("NEVER") \
97
+ .runtime_config("image: docker.io/library/nginx\ncommandOptions: [\"-p\", \"8080:80\"]") \
98
+ .build()
99
+
100
+ # Run the workload
101
+ ret = ankaios.apply_workload(workload)
102
+
103
+ # Get the WorkloadInstanceName to check later if the workload is running
104
+ if ret is not None:
105
+ workload_instance_name = ret["added_workloads"][0]
106
+
107
+ # Request the execution state based on the workload instance name
108
+ ret = ankaios.get_execution_state_for_instance_name(workload_instance_name)
109
+ if ret is not None:
110
+ print(f"State: {ret.state}, substate: {ret.substate}, info: {ret.additional_info}")
111
+
112
+ # Wait until the workload reaches the running state
113
+ ret = ankaios.wait_for_workload_to_reach_state(
114
+ workload_instance_name,
115
+ state=WorkloadStateEnum.RUNNING,
116
+ timeout=5
117
+ )
118
+ if ret:
119
+ print("Workload reached the RUNNING state.")
120
+
121
+ # Request the state of the system, filtered with the agent name
122
+ complete_state = ankaios.get_state(
123
+ timeout=5,
124
+ field_masks=["workloadStates.agent_A"])
125
+
126
+ # Get the workload states present in the complete_state
127
+ workload_states_dict = complete_state.get_workload_states().get_as_dict()
128
+
129
+ # Print the states of the workloads:
130
+ for workload_name in workload_states_dict["agent_A"]:
131
+ for workload_id in workload_states_dict["agent_A"][workload_name]:
132
+ print(f"Workload {workload_name} with id {workload_id} has the state "
133
+ + str(workload_states_dict["agent_A"] \
134
+ [workload_name][workload_id].state))
135
+ ```
136
+
137
+ ## Contributing
138
+
139
+ This project welcomes contributions and suggestions. Before contributing, make sure to read the
140
+ [contribution guideline](CONTRIBUTING.md).
141
+
142
+ ## License
143
+
144
+ Ankaios Python SDK is licensed using the Apache License Version 2.0.
@@ -0,0 +1,109 @@
1
+ <picture style="padding-bottom: 1em;">
2
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_dark_bgrd_clipped.png">
3
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_light_bgrd_clipped.png">
4
+ <img alt="Shows Ankaios logo" src="https://github.com/eclipse-ankaios/ankaios/blob/main/logo/Ankaios__logo_for_light_bgrd_clipped.png">
5
+ </picture>
6
+
7
+ # Ankaios Python SDK for Eclipse Ankaios
8
+
9
+ Eclipse Ankaios provides workload and container orchestration for automotive
10
+ High Performance Computers (HPCs). While it can be used for various fields of
11
+ applications, it is developed from scratch for automotive use cases and provides
12
+ a slim yet powerful solution to manage containerized applications.
13
+
14
+ The Python SDK provides easy access from the container (workload) point-of-view
15
+ to manage the Ankaios system. A workload can use the Python SDK to run other workloads
16
+ and get the state of the Ankaios system.
17
+
18
+ ## Installation
19
+
20
+ ### Install via pip
21
+
22
+ ```sh
23
+ pip install ankaios-sdk
24
+ ```
25
+
26
+ ### Clone and Local Build
27
+
28
+ ```sh
29
+ # Clone repository
30
+ git clone https://github.com/eclipse-ankaios/ank-sdk-python.git
31
+ cd ank-sdk-python
32
+
33
+ # Install in editable mode
34
+ pip install -e .
35
+
36
+ # If you plan on contributing or running tests locally
37
+ pip install -e ".[dev]"
38
+ ```
39
+
40
+ > **Note:**
41
+ > Depending on your Linux distribution, it could be that you need to create and activate a [virtual environment](https://docs.python.org/3/library/venv.html) to run the pip commands.
42
+
43
+ ## Usage
44
+
45
+ After installation, you can use the Ankaios SDK to configure and run workloads and request
46
+ the state of the Ankaios system and the connected agents.
47
+
48
+ Example:
49
+ ```python
50
+ from ankaios_sdk import Workload, Ankaios, WorkloadStateEnum, WorkloadSubStateEnum
51
+
52
+ # Create a new Ankaios object.
53
+ # The connection to the control interface is automatically done at this step.
54
+ ankaios = Ankaios()
55
+
56
+ # Create a new workload
57
+ workload = Workload.builder() \
58
+ .workload_name("dynamic_nginx") \
59
+ .agent_name("agent_A") \
60
+ .runtime("podman") \
61
+ .restart_policy("NEVER") \
62
+ .runtime_config("image: docker.io/library/nginx\ncommandOptions: [\"-p\", \"8080:80\"]") \
63
+ .build()
64
+
65
+ # Run the workload
66
+ ret = ankaios.apply_workload(workload)
67
+
68
+ # Get the WorkloadInstanceName to check later if the workload is running
69
+ if ret is not None:
70
+ workload_instance_name = ret["added_workloads"][0]
71
+
72
+ # Request the execution state based on the workload instance name
73
+ ret = ankaios.get_execution_state_for_instance_name(workload_instance_name)
74
+ if ret is not None:
75
+ print(f"State: {ret.state}, substate: {ret.substate}, info: {ret.additional_info}")
76
+
77
+ # Wait until the workload reaches the running state
78
+ ret = ankaios.wait_for_workload_to_reach_state(
79
+ workload_instance_name,
80
+ state=WorkloadStateEnum.RUNNING,
81
+ timeout=5
82
+ )
83
+ if ret:
84
+ print("Workload reached the RUNNING state.")
85
+
86
+ # Request the state of the system, filtered with the agent name
87
+ complete_state = ankaios.get_state(
88
+ timeout=5,
89
+ field_masks=["workloadStates.agent_A"])
90
+
91
+ # Get the workload states present in the complete_state
92
+ workload_states_dict = complete_state.get_workload_states().get_as_dict()
93
+
94
+ # Print the states of the workloads:
95
+ for workload_name in workload_states_dict["agent_A"]:
96
+ for workload_id in workload_states_dict["agent_A"][workload_name]:
97
+ print(f"Workload {workload_name} with id {workload_id} has the state "
98
+ + str(workload_states_dict["agent_A"] \
99
+ [workload_name][workload_id].state))
100
+ ```
101
+
102
+ ## Contributing
103
+
104
+ This project welcomes contributions and suggestions. Before contributing, make sure to read the
105
+ [contribution guideline](CONTRIBUTING.md).
106
+
107
+ ## License
108
+
109
+ Ankaios Python SDK is licensed using the Apache License Version 2.0.
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2024 Elektrobit Automotive GmbH
2
+ #
3
+ # This program and the accompanying materials are made available under the
4
+ # terms of the Apache License, Version 2.0 which is available at
5
+ # https://www.apache.org/licenses/LICENSE-2.0.
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+ #
13
+ # SPDX-License-Identifier: Apache-2.0
14
+
15
+ """
16
+ Ankaios Python SDK
17
+
18
+ Classes
19
+ -------
20
+
21
+ - Ankaios:
22
+ The main SDK class.
23
+ - Workload:
24
+ Represents a workload.
25
+ - WorkloadBuilder:
26
+ A builder class for workloads.
27
+ - WorkloadState:
28
+ Represents the state of a workload.
29
+ - WorkloadStateCollection:
30
+ A collection of workload states.
31
+ - Manifest:
32
+ Represents a workload manifest.
33
+ - CompleteState:
34
+ Represents the complete state of the Ankaios cluster.
35
+ """
36
+
37
+ from .exceptions import *
38
+ from .ankaios import *
39
+ from ._components import *
40
+
41
+ __all__ = [name for name in globals() if not name.startswith('_')]
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2024 Elektrobit Automotive GmbH
2
+ #
3
+ # This program and the accompanying materials are made available under the
4
+ # terms of the Apache License, Version 2.0 which is available at
5
+ # https://www.apache.org/licenses/LICENSE-2.0.
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+ # License for the specific language governing permissions and limitations
11
+ # under the License.
12
+ #
13
+ # SPDX-License-Identifier: Apache-2.0
14
+
15
+ """
16
+ This module initializes the ankaios_sdk package by importing all
17
+ necessary components.
18
+
19
+ Imports
20
+ -------
21
+
22
+ - Workload component:
23
+ responsible for defining the workload of the system.
24
+ - WorkloadState component:
25
+ responsible for accessing the state of the workload.
26
+ - CompleteState component:
27
+ responsible for accessing the complete state of the system.
28
+ - Request component:
29
+ responsible for defining a request to be sent to the system.
30
+ - Response component:
31
+ responsible for defining a response from the system.
32
+ - Manifest component:
33
+ responsible for defining a manifest object.
34
+ """
35
+
36
+ from .workload import *
37
+ from .workload_state import *
38
+ from .complete_state import *
39
+ from .request import *
40
+ from .response import *
41
+ from .manifest import *
42
+
43
+ __all__ = [name for name in globals() if not name.startswith('_')]