holado 0.11.2__py3-none-any.whl → 0.11.4__py3-none-any.whl

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.

Potentially problematic release.


This version of holado might be problematic. Click here for more details.

Files changed (48) hide show
  1. {holado-0.11.2.dist-info → holado-0.11.4.dist-info}/METADATA +2 -2
  2. {holado-0.11.2.dist-info → holado-0.11.4.dist-info}/RECORD +48 -14
  3. holado_ais/ais/ais_messages.py +2 -2
  4. holado_ais/tests/behave/steps/ais/ais_messages_steps.py +1 -1
  5. holado_core/common/resource/persisted_method_to_call_manager.py +1 -1
  6. holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +16 -16
  7. holado_python/standard_library/ssl/resources/certificates/tcpbin.key +26 -26
  8. holado_report/report/builders/summary_by_category_report_builder.py +86 -0
  9. holado_report/report/report_manager.py +4 -0
  10. holado_test/tools/test_server/client/rest/test_server_client.py +20 -0
  11. holado_test/tools/test_server/server/rest/api/__init__.py +6 -5
  12. holado_test/tools/test_server/server/rest/openapi.yaml +11 -0
  13. holado_tools/__init__.py +38 -0
  14. holado_tools/scripts/execute_persisted_post_processes/execute_persisted_post_processes.py +36 -0
  15. holado_tools/scripts/execute_persisted_post_processes/execute_persisted_post_processes.sh +6 -0
  16. holado_tools/scripts/execute_persisted_post_processes/initialize_holado.py +62 -0
  17. holado_tools/tests/behave/steps/__init__.py +16 -0
  18. holado_tools/tests/behave/steps/tools/host_controller/client_steps.py +97 -0
  19. holado_tools/tools/host_controller/client/rest/host_controller_client.py +168 -0
  20. holado_tools/tools/host_controller/server/Dockerfile +60 -0
  21. holado_tools/tools/host_controller/server/grpc/README +2 -0
  22. holado_tools/tools/host_controller/server/grpc/__init__.py +26 -0
  23. holado_tools/tools/host_controller/server/grpc/proto/compile_proto.py +60 -0
  24. holado_tools/tools/host_controller/server/grpc/proto/definitions/docker_controler.proto +63 -0
  25. holado_tools/tools/host_controller/server/requirements.txt +2 -0
  26. holado_tools/tools/host_controller/server/rest/README +2 -0
  27. holado_tools/tools/host_controller/server/rest/api/__init__.py +24 -0
  28. holado_tools/tools/host_controller/server/rest/api/config.py +57 -0
  29. holado_tools/tools/host_controller/server/rest/api/docker/__init__.py +40 -0
  30. holado_tools/tools/host_controller/server/rest/api/docker/container.py +55 -0
  31. holado_tools/tools/host_controller/server/rest/api/os.py +47 -0
  32. holado_tools/tools/host_controller/server/rest/initialize_holado.py +72 -0
  33. holado_tools/tools/host_controller/server/rest/openapi.yaml +276 -0
  34. holado_tools/tools/host_controller/server/rest/run.py +31 -0
  35. holado_tools/tools/host_controller/server/run_host_controller_in_docker.sh +107 -0
  36. holado_tools/tools/host_viewer/client/rest/host_viewer_client.py +96 -0
  37. holado_tools/tools/host_viewer/server/Dockerfile +60 -0
  38. holado_tools/tools/host_viewer/server/requirements.txt +2 -0
  39. holado_tools/tools/host_viewer/server/rest/README +2 -0
  40. holado_tools/tools/host_viewer/server/rest/api/__init__.py +24 -0
  41. holado_tools/tools/host_viewer/server/rest/api/docker/__init__.py +40 -0
  42. holado_tools/tools/host_viewer/server/rest/initialize_holado.py +72 -0
  43. holado_tools/tools/host_viewer/server/rest/openapi.yaml +113 -0
  44. holado_tools/tools/host_viewer/server/rest/run.py +31 -0
  45. holado_tools/tools/host_viewer/server/run_host_viewer_in_docker.sh +107 -0
  46. test_holado/environment.py +7 -0
  47. {holado-0.11.2.dist-info → holado-0.11.4.dist-info}/WHEEL +0 -0
  48. {holado-0.11.2.dist-info → holado-0.11.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,55 @@
1
+ #################################################
2
+ # HolAdo (Holistic Automation do)
3
+ #
4
+ # (C) Copyright 2021-2025 by Eric Klumpp
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+ #
8
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
11
+ #################################################
12
+
13
+ from flask.views import MethodView
14
+ from holado.common.context.session_context import SessionContext
15
+
16
+ def _get_session_context():
17
+ return SessionContext.instance()
18
+
19
+
20
+ class RestartView(MethodView):
21
+
22
+ def put(self, name, body: dict):
23
+ if not _get_session_context().docker_client.has_container(name):
24
+ return f"Container '{name}' doesn't exist", 410
25
+
26
+ res = _get_session_context().docker_client.restart_container(name, wait_running=False)
27
+ return res
28
+
29
+ class StartView(MethodView):
30
+
31
+ def put(self, name, body: dict):
32
+ if not _get_session_context().docker_client.has_container(name, all_=True):
33
+ return f"Container '{name}' doesn't exist", 410
34
+
35
+ res = _get_session_context().docker_client.start_container(name, wait_running=False)
36
+ return res
37
+
38
+ class StopView(MethodView):
39
+
40
+ def put(self, name, body: dict):
41
+ if not _get_session_context().docker_client.has_container(name):
42
+ return f"Container '{name}' doesn't exist", 410
43
+
44
+ res = _get_session_context().docker_client.stop_container(name)
45
+ return res
46
+
47
+ class WaitView(MethodView):
48
+
49
+ def put(self, name, body: dict):
50
+ if not _get_session_context().docker_client.has_container(name):
51
+ return f"Container '{name}' doesn't exist", 410
52
+
53
+ res = _get_session_context().docker_client.get_container(name).wait()
54
+ return res
55
+
@@ -0,0 +1,47 @@
1
+ #################################################
2
+ # HolAdo (Holistic Automation do)
3
+ #
4
+ # (C) Copyright 2021-2025 by Eric Klumpp
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+ #
8
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
11
+ #################################################
12
+
13
+ from flask.views import MethodView
14
+ from holado.common.context.session_context import SessionContext
15
+ import os
16
+
17
+ def _get_session_context():
18
+ return SessionContext.instance()
19
+
20
+
21
+ class EnvView(MethodView):
22
+
23
+ def get(self, body: list):
24
+ res = [os.getenv(name) for name in body]
25
+ return res
26
+
27
+
28
+ class LsView(MethodView):
29
+
30
+ def get(self, body: dict):
31
+ dir_path = body['path']
32
+ extension = body.get('extension', None)
33
+
34
+ if not os.path.exists(dir_path) or not os.path.isdir(dir_path):
35
+ return f"Directory '{dir_path}' doesn't exist", 406
36
+
37
+ res = []
38
+ for filename in os.listdir(dir_path):
39
+ if extension is not None and not filename.endswith(extension):
40
+ continue
41
+ if os.path.isfile(os.path.join(dir_path, filename)):
42
+ res.append(filename)
43
+
44
+ return res
45
+
46
+
47
+
@@ -0,0 +1,72 @@
1
+
2
+ #################################################
3
+ # HolAdo (Holistic Automation do)
4
+ #
5
+ # (C) Copyright 2021-2025 by Eric Klumpp
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
12
+ #################################################
13
+
14
+
15
+ #################################################
16
+ # GOAL: Tools when using a clone of HolAdo project.
17
+ #
18
+ # This file contains methods usefull to initialize environments using a clone of HolAdo project.
19
+ #
20
+ # USAGE:
21
+ # - Copy this file in projects using HolAdo.
22
+ # - Define environment variable HOLADO_PATH with path to cloned HolAdo project.
23
+ # If HOLADO_PATH is defined, sources of cloned HolAdo project are used, else installed holado package is used.
24
+ #################################################
25
+
26
+
27
+
28
+ import os
29
+ import sys
30
+
31
+
32
+ def insert_sys_path(path, index=0):
33
+ """Insert a path in sys.path if it doesn't already exists.
34
+ """
35
+ if path not in sys.path:
36
+ sys.path.insert(index, path)
37
+
38
+ def insert_sys_paths(list_paths, index=0):
39
+ """Insert a list of path in sys.path if it doesn't already exists.
40
+ """
41
+ if list_paths:
42
+ for path in list_paths:
43
+ insert_sys_path(path, index=index)
44
+
45
+ def insert_holado_source_paths(with_test_behave=True):
46
+ """Insert in sys.path all HolAdo source paths.
47
+ If environment variable HOLADO_PATH is defined with path to HolAdo project, following paths are inserted in sys.path:
48
+ - HOLADO_PATH/src: path to holado modules sources
49
+ - HOLADO_PATH/tests/behave (if with_test_behave==True): path to holado test sources, needed by testing solutions
50
+ """
51
+ holado_path = os.getenv('HOLADO_PATH')
52
+ if holado_path is None:
53
+ try:
54
+ import holado # @UnusedImport
55
+ except Exception as exc:
56
+ if "No module named" in str(exc):
57
+ raise Exception(f"If environment variable HOLADO_PATH is not defined with path to HolAdo project, 'holado' python package must be installed")
58
+ else:
59
+ raise exc
60
+ else:
61
+ # holado is installed, and all sources are already accessible
62
+ pass
63
+ else:
64
+ print(f"Using HolAdo project installed in '{holado_path}'")
65
+ # import traceback
66
+ # print("".join(traceback.format_list(traceback.extract_stack())))
67
+ # insert_sys_path(holado_path)
68
+ insert_sys_path(os.path.join(holado_path, "src"))
69
+ if with_test_behave:
70
+ insert_sys_path(os.path.join(holado_path, "tests", "behave"))
71
+
72
+
@@ -0,0 +1,276 @@
1
+ openapi: "3.0.0"
2
+ info:
3
+ version: "1"
4
+ title: "Host Controller API"
5
+ description: |
6
+ API to process some host actions from anywhere on the network.
7
+ In a microservice architecture, the host-controller can be run in a docker with special privileges,
8
+ whereas all other microservices have user privileges.
9
+ For example, it is usefull for a testing solution needing to restart a microservice of the SUT (System Under Test),
10
+ but the testing solution docker image has not the privileges to do it.
11
+ paths:
12
+ /health:
13
+ get:
14
+ description: "Healthcheck"
15
+ responses:
16
+ 200:
17
+ description: "Healthy"
18
+ content:
19
+ application/json:
20
+ schema:
21
+ type: "string"
22
+
23
+ /os/env:
24
+ get:
25
+ description: "Get environment variable values"
26
+ requestBody:
27
+ content:
28
+ application/json:
29
+ schema:
30
+ type: "array"
31
+ items:
32
+ type: "string"
33
+ responses:
34
+ 200:
35
+ description: "Environment variable values"
36
+ content:
37
+ application/json:
38
+ schema:
39
+ type: "array"
40
+ items:
41
+ type: "object"
42
+
43
+ /os/ls:
44
+ get:
45
+ description: "List directory filenames"
46
+ requestBody:
47
+ content:
48
+ application/json:
49
+ schema:
50
+ type: "object"
51
+ properties:
52
+ path:
53
+ type: string
54
+ extension:
55
+ type: string
56
+ nullable: true
57
+ responses:
58
+ 200:
59
+ description: "Directory filenames"
60
+ content:
61
+ application/json:
62
+ schema:
63
+ type: "array"
64
+ items:
65
+ type: "string"
66
+
67
+ /docker/container:
68
+ get:
69
+ description: "List containers and their status"
70
+ parameters:
71
+ - in: "query"
72
+ name: "all"
73
+ description: "if set to 'true', list all containers, not only running ones"
74
+ schema:
75
+ type: "boolean"
76
+ default: false
77
+ responses:
78
+ 200:
79
+ description: "List of container names with their status"
80
+ content:
81
+ application/json:
82
+ schema:
83
+ type: "array"
84
+ items:
85
+ type: "string"
86
+ /docker/container/{name}:
87
+ get:
88
+ description: "Display all information of a container"
89
+ parameters:
90
+ - in: "path"
91
+ name: "name"
92
+ description: "Container name"
93
+ required: true
94
+ schema:
95
+ type: "string"
96
+ - in: "query"
97
+ name: "all"
98
+ description: "if set to 'true', search container in all containers, not only running ones"
99
+ schema:
100
+ type: "boolean"
101
+ default: false
102
+ responses:
103
+ 200:
104
+ description: "Container information"
105
+ content:
106
+ application/json:
107
+ schema:
108
+ type: "string"
109
+ /docker/container/{name}/restart:
110
+ put:
111
+ description: "Restart a container"
112
+ parameters:
113
+ - in: "path"
114
+ name: "name"
115
+ description: "Container name"
116
+ required: true
117
+ schema:
118
+ type: "string"
119
+ requestBody:
120
+ content:
121
+ application/json:
122
+ schema:
123
+ type: "object"
124
+ nullable: true
125
+ responses:
126
+ 200:
127
+ description: ""
128
+ content:
129
+ application/json:
130
+ schema:
131
+ type: "string"
132
+ /docker/container/{name}/start:
133
+ put:
134
+ description: "Start a container"
135
+ parameters:
136
+ - in: "path"
137
+ name: "name"
138
+ description: "Container name"
139
+ required: true
140
+ schema:
141
+ type: "string"
142
+ requestBody:
143
+ content:
144
+ application/json:
145
+ schema:
146
+ type: "object"
147
+ nullable: true
148
+ responses:
149
+ 200:
150
+ description: ""
151
+ content:
152
+ application/json:
153
+ schema:
154
+ type: "string"
155
+ /docker/container/{name}/stop:
156
+ put:
157
+ description: "Stop a container"
158
+ parameters:
159
+ - in: "path"
160
+ name: "name"
161
+ description: "Container name"
162
+ required: true
163
+ schema:
164
+ type: "string"
165
+ requestBody:
166
+ content:
167
+ application/json:
168
+ schema:
169
+ type: "object"
170
+ nullable: true
171
+ responses:
172
+ 200:
173
+ description: ""
174
+ content:
175
+ application/json:
176
+ schema:
177
+ type: "string"
178
+ /docker/container/{name}/wait:
179
+ put:
180
+ description: "Wait until a container is stopped"
181
+ parameters:
182
+ - in: "path"
183
+ name: "name"
184
+ description: "Container name"
185
+ required: true
186
+ schema:
187
+ type: "string"
188
+ requestBody:
189
+ content:
190
+ application/json:
191
+ schema:
192
+ type: "object"
193
+ nullable: true
194
+ responses:
195
+ 200:
196
+ description: ""
197
+ content:
198
+ application/json:
199
+ schema:
200
+ type: "string"
201
+
202
+ /config/yaml_file:
203
+ get:
204
+ description: "Get content of a YAML file"
205
+ requestBody:
206
+ content:
207
+ application/json:
208
+ schema:
209
+ type: "object"
210
+ properties:
211
+ file_path:
212
+ type: string
213
+ responses:
214
+ 200:
215
+ description: ""
216
+ content:
217
+ application/text:
218
+ schema:
219
+ type: "string"
220
+ patch:
221
+ description: "Update a YAML file"
222
+ requestBody:
223
+ content:
224
+ application/json:
225
+ schema:
226
+ type: "object"
227
+ properties:
228
+ file_path:
229
+ type: string
230
+ yaml_string:
231
+ type: string
232
+ with_backup:
233
+ type: "boolean"
234
+ default: false
235
+ backup_extension:
236
+ type: string
237
+ default: '.bak'
238
+ responses:
239
+ 200:
240
+ description: ""
241
+ content:
242
+ application/json:
243
+ schema:
244
+ type: "string"
245
+ put:
246
+ description: "Replace a YAML file"
247
+ requestBody:
248
+ content:
249
+ application/json:
250
+ schema:
251
+ type: "object"
252
+ properties:
253
+ action:
254
+ description: "Action to perform"
255
+ type: string
256
+ enum:
257
+ - "restore"
258
+ file_path:
259
+ type: string
260
+ backup_extension:
261
+ type: string
262
+ default: '.bak'
263
+ responses:
264
+ 200:
265
+ description: ""
266
+ content:
267
+ application/json:
268
+ schema:
269
+ type: "string"
270
+
271
+ components:
272
+ securitySchemes: {}
273
+ schemas:
274
+ DockerControler:
275
+ properties: {}
276
+
@@ -0,0 +1,31 @@
1
+ #################################################
2
+ # HolAdo (Holistic Automation do)
3
+ #
4
+ # (C) Copyright 2021-2025 by Eric Klumpp
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+ #
8
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
11
+ #################################################
12
+
13
+ import connexion
14
+ from connexion.resolver import MethodViewResolver
15
+
16
+ # For debug with HolAdo sources, insert HolAdo source paths
17
+ from initialize_holado import insert_holado_source_paths # @UnresolvedImport
18
+ insert_holado_source_paths(with_test_behave=False)
19
+
20
+ # Initialize HolAdo
21
+ from holado import initialize
22
+ initialize(TSessionContext=None, use_holado_logger=True, logging_config_file_path=None,
23
+ log_level=None, log_time_in_utc=None, log_on_console=True, log_in_file=False,
24
+ config_kwargs={'application_group':'host_controller'},
25
+ garbage_collector_periodicity=None)
26
+
27
+
28
+ app = connexion.FlaskApp(__name__, pythonic_params=True)
29
+ app.add_api('openapi.yaml',
30
+ resolver=MethodViewResolver('api'), resolver_error=501,
31
+ pythonic_params=True)
@@ -0,0 +1,107 @@
1
+ #!/bin/bash
2
+
3
+ # Script to launch Host Controller as a docker image.
4
+ #
5
+ # Host Controller exposes a REST API with host services.
6
+ # It is accessible on localhost, and also on a docker network if HOLADO_NETWORK is defined.
7
+ # API is accessible on port HOLADO_HOST_CONTROLLER_HOSTPORT from localhost and port HOLADO_HOST_CONTROLLER_PORT from network.
8
+ #
9
+ # REST API specification is in file rest/openapi.yaml.
10
+ #
11
+ # REQUIREMENTS:
12
+ # Have access to any HolAdo registry.
13
+ #
14
+ # Optionally, define in .profile the following variables
15
+ # - HOLADO_HOST_CONTROLLER_HOST: host name or name of the container
16
+ # - HOLADO_HOST_CONTROLLER_HOSTPORT: REST API port to use from localhost (default: 51231)
17
+ # - HOLADO_HOST_CONTROLLER_PORT: REST API port to use from network HOLADO_NETWORK (default: 51231)
18
+ # - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/host_controller)
19
+ # - HOLADO_IMAGE_TAG: docker image tag to use (default: latest)
20
+ # - HOLADO_OUTPUT_BASEDIR: absolute path to base output directory (default: [HOME]/.holado/output)
21
+ # - HOLADO_USE_LOCALHOST: force the container network to 'host'.
22
+ # - HOLADO_NETWORK: specify on which network the docker is run.
23
+ #
24
+
25
+
26
+ WORK_DIR="$(pwd)"
27
+
28
+ if [[ -z "$HOLADO_IMAGE_REGISTRY" ]]; then
29
+ HOLADO_IMAGE_REGISTRY=holado/host_controller
30
+ fi
31
+ if [[ -z "$HOLADO_IMAGE_TAG" ]]; then
32
+ HOLADO_IMAGE_TAG=latest
33
+ fi
34
+ CONTROLLER_IMAGE=${HOLADO_IMAGE_REGISTRY}:${HOLADO_IMAGE_TAG}
35
+
36
+ # Update docker image
37
+ echo "Updating docker image ${CONTROLLER_IMAGE}..."
38
+ docker pull ${CONTROLLER_IMAGE}
39
+
40
+ # Define test output directory
41
+ if [[ ! -z "$HOLADO_OUTPUT_BASEDIR" ]]; then
42
+ OUTPUT_DIR=${HOLADO_OUTPUT_BASEDIR}
43
+ else
44
+ OUTPUT_DIR=${HOME}/.holado/output
45
+ fi
46
+ echo "Output directory: $OUTPUT_DIR"
47
+
48
+ # Define test resources directory
49
+ if [[ ! -z "$HOLADO_LOCAL_RESOURCES_BASEDIR" ]]; then
50
+ RESOURCES_DIR=${HOLADO_LOCAL_RESOURCES_BASEDIR}
51
+ else
52
+ RESOURCES_DIR=${HOME}/.holado/resources
53
+ fi
54
+ echo "Resources directory: $RESOURCES_DIR"
55
+
56
+ # Make dirs
57
+ if [ ! -d ${OUTPUT_DIR} ]; then
58
+ echo "Create output directory: ${OUTPUT_DIR}"
59
+ mkdir -p ${OUTPUT_DIR}
60
+ fi
61
+ if [ ! -d ${RESOURCES_DIR} ]; then
62
+ echo "Create resources directory: ${RESOURCES_DIR}"
63
+ mkdir -p ${RESOURCES_DIR}
64
+ fi
65
+
66
+ # Define container network
67
+ if [ "$HOLADO_USE_LOCALHOST" = True ]; then
68
+ NETWORK_DEF_COMMAND="--network=host"
69
+ else
70
+ if [[ ! -z "$HOLADO_NETWORK" ]]; then
71
+ NETWORK_DEF_COMMAND="--network $HOLADO_NETWORK"
72
+ else
73
+ NETWORK_DEF_COMMAND=""
74
+ fi
75
+ fi
76
+
77
+ # Define ports to use
78
+ if [[ -z "$HOLADO_HOST_CONTROLLER_HOSTPORT" ]]; then
79
+ HOLADO_HOST_CONTROLLER_HOSTPORT=51231
80
+ fi
81
+ if [[ -z "$HOLADO_HOST_CONTROLLER_PORT" ]]; then
82
+ HOLADO_HOST_CONTROLLER_PORT=51231
83
+ fi
84
+
85
+ # Docker run
86
+ if [[ -z "$HOLADO_HOST_CONTROLLER_HOST" ]]; then
87
+ HOLADO_HOST_CONTROLLER_HOST=holado_host_controller
88
+ fi
89
+
90
+ echo
91
+ echo "Running Host Controller..."
92
+ echo " container name: ${HOLADO_HOST_CONTROLLER_HOST}"
93
+ echo " host port: ${HOLADO_HOST_CONTROLLER_HOSTPORT}"
94
+ echo " port: ${HOLADO_HOST_CONTROLLER_PORT}"
95
+ #echo " NETWORK_DEF_COMMAND=${NETWORK_DEF_COMMAND}"
96
+ echo
97
+ docker run --rm --user root --name ${HOLADO_HOST_CONTROLLER_HOST} \
98
+ --privileged -v $(docker info --format '{{.SecurityOptions}}' | grep -q rootless && echo -n "/run/user/$(id -u ${USER})/docker.sock" || echo -n "/var/run/docker.sock"):/var/run/docker.sock \
99
+ -v "${OUTPUT_DIR}":/output \
100
+ -v "${RESOURCES_DIR}":/resources \
101
+ -e HOLADO_OUTPUT_BASEDIR=/output \
102
+ -e HOLADO_LOCAL_RESOURCES_BASEDIR=/resources \
103
+ -e HOLADO_HOST_CONTROLLER_PORT=${HOLADO_HOST_CONTROLLER_PORT} \
104
+ ${NETWORK_DEF_COMMAND} \
105
+ -p ${HOLADO_HOST_CONTROLLER_HOSTPORT}:${HOLADO_HOST_CONTROLLER_PORT} \
106
+ ${CONTROLLER_IMAGE}
107
+
@@ -0,0 +1,96 @@
1
+
2
+ #################################################
3
+ # HolAdo (Holistic Automation do)
4
+ #
5
+ # (C) Copyright 2021-2025 by Eric Klumpp
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
12
+ #################################################
13
+
14
+ import logging
15
+ from holado_rest.api.rest.rest_client import RestClient
16
+ from holado.common.handlers.undefined import undefined_argument, undefined_value
17
+ import os
18
+ from holado_core.common.tools.converters.converter import Converter
19
+ from holado_rest.api.rest.rest_manager import RestManager
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ class HostViewerClient(RestClient):
25
+
26
+ @classmethod
27
+ def new_client(cls, use_localhost=undefined_argument, **kwargs):
28
+ if 'name' not in kwargs:
29
+ kwargs['name'] = None
30
+ if 'url' not in kwargs:
31
+ if use_localhost is undefined_argument:
32
+ env_use = os.getenv("HOLADO_USE_LOCALHOST", False)
33
+ use_localhost = Converter.is_boolean(env_use) and Converter.to_boolean(env_use)
34
+
35
+ url = os.getenv("HOLADO_HOST_VIEWER_URL", undefined_value)
36
+ if url is undefined_value:
37
+ scheme = kwargs.get('scheme', undefined_value)
38
+ if scheme is undefined_value:
39
+ scheme = os.getenv("HOLADO_HOST_VIEWER_SCHEME", "http")
40
+ host = kwargs.get('host', undefined_value)
41
+ if host is undefined_value:
42
+ host = "localhost" if use_localhost else os.getenv("HOLADO_HOST_VIEWER_HOST", "holado_docker_viewer")
43
+ port = kwargs.get('port', undefined_value)
44
+ if port is undefined_value:
45
+ if use_localhost:
46
+ port = os.getenv("HOLADO_HOST_VIEWER_HOSTPORT", 51231)
47
+ else:
48
+ port = os.getenv("HOLADO_HOST_VIEWER_PORT", 51231)
49
+
50
+ if port is None:
51
+ url = f"{scheme}://{host}"
52
+ else:
53
+ url = f"{scheme}://{host}:{port}"
54
+ kwargs['url'] = url
55
+
56
+ manager = RestManager(default_client_class=HostViewerClient)
57
+ res = manager.new_client(**kwargs)
58
+
59
+ return res
60
+
61
+
62
+ def __init__(self, name, url, headers=None):
63
+ super().__init__(name, url, headers)
64
+
65
+
66
+ # Common features
67
+
68
+ def get_environment_variable_value(self, var_name):
69
+ data = [var_name]
70
+ response = self.get(f"os/env", json=data)
71
+ return self.response_result(response, status_ok=[200])
72
+
73
+ def get_directory_filenames(self, path, extension='.yml'):
74
+ data = {'path':path, 'extension':extension}
75
+ response = self.get(f"os/ls", json=data)
76
+ return self.response_result(response, status_ok=[200])
77
+
78
+
79
+ # Manage containers
80
+
81
+ def get_containers_status(self, all_=False):
82
+ if all_:
83
+ response = self.get("docker/container?all=true")
84
+ else:
85
+ response = self.get("docker/container")
86
+ return self.response_result(response, status_ok=[200,204])
87
+
88
+ def get_container_info(self, name, all_=False):
89
+ if all_:
90
+ response = self.get(f"docker/container/{name}?all=true")
91
+ else:
92
+ response = self.get(f"docker/container/{name}")
93
+ return self.response_result(response, status_ok=[200,204])
94
+
95
+
96
+