holado 0.6.2__py3-none-any.whl → 0.6.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 (68) hide show
  1. holado/__init__.py +2 -2
  2. holado/common/handlers/object.py +15 -1
  3. {holado-0.6.2.dist-info → holado-0.6.4.dist-info}/METADATA +42 -1
  4. {holado-0.6.2.dist-info → holado-0.6.4.dist-info}/RECORD +66 -21
  5. holado_ais/ais/ais_messages.py +3 -1
  6. holado_docker/tools/docker_controller/server/grpc/docker_controller_client.py → holado_crypto/__init__.py +15 -20
  7. holado_crypto/crypto/transport/__init__.py +0 -0
  8. holado_crypto/crypto/transport/crc.py +40 -0
  9. holado_docker/tools/docker_controller/server/grpc/docker_controller_server.py → holado_crypto/test/behave/steps/__init__.py +2 -17
  10. holado_docker/sdk/docker/docker_client.py +26 -22
  11. holado_docker/tools/docker_controller/client/rest/docker_controller_client.py +10 -4
  12. holado_docker/tools/docker_controller/docker_controller_manager.py +5 -3
  13. holado_docker/tools/docker_controller/server/Dockerfile +9 -7
  14. holado_docker/tools/docker_controller/server/requirements.txt +1 -2
  15. holado_docker/tools/docker_controller/server/rest/README +2 -0
  16. holado_docker/tools/docker_controller/server/rest/api/__init__.py +16 -17
  17. holado_docker/tools/docker_controller/server/rest/openapi.yaml +20 -3
  18. holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh +6 -6
  19. holado_docker/tools/docker_viewer/client/rest/docker_viewer_client.py +40 -0
  20. holado_docker/tools/docker_viewer/docker_viewer_manager.py +44 -0
  21. holado_docker/tools/docker_viewer/server/Dockerfile +70 -0
  22. holado_docker/tools/docker_viewer/server/requirements.txt +2 -0
  23. holado_docker/tools/docker_viewer/server/rest/README +2 -0
  24. holado_docker/tools/docker_viewer/server/rest/api/__init__.py +40 -0
  25. holado_docker/tools/docker_viewer/server/rest/initialize_holado.py +72 -0
  26. holado_docker/tools/docker_viewer/server/rest/openapi.yaml +58 -0
  27. holado_docker/tools/docker_viewer/server/rest/run.py +28 -0
  28. holado_docker/tools/docker_viewer/server/run_docker_viewer_in_docker.sh +101 -0
  29. holado_examples/projects/server_rest/server_rest_example/initialize_holado.py +72 -0
  30. holado_examples/projects/server_rest/server_rest_example/rest_api/db.sqlite3 +0 -0
  31. holado_examples/projects/server_rest/server_rest_example/rest_api/manage.py +22 -0
  32. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/__init__.py +0 -0
  33. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/__init__.py +0 -0
  34. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/admin.py +3 -0
  35. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/apps.py +7 -0
  36. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/migrations/__init__.py +0 -0
  37. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/models.py +3 -0
  38. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/serializers.py +15 -0
  39. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/tests.py +3 -0
  40. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/application/views.py +24 -0
  41. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/asgi.py +16 -0
  42. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/settings.py +130 -0
  43. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/urls.py +31 -0
  44. holado_examples/projects/server_rest/server_rest_example/rest_api/rest_api/wsgi.py +16 -0
  45. holado_examples/projects/server_rest/server_rest_example/rest_server.py +37 -0
  46. holado_examples/scripts/script_custom_initialization.py +16 -0
  47. holado_examples/scripts/script_minimal_initialization.py +23 -0
  48. holado_examples/tests/behave/testing_solution/__main__.py +13 -0
  49. holado_examples/tests/behave/testing_solution/behave_environment.py +35 -0
  50. holado_examples/tests/behave/testing_solution/environment.py +36 -0
  51. holado_examples/tests/behave/testing_solution/features/Configuration/Actions/configure_system.feature +10 -0
  52. holado_examples/tests/behave/testing_solution/features/NonReg/example.feature +26 -0
  53. holado_examples/tests/behave/testing_solution/initialize_holado.py +62 -0
  54. holado_examples/tests/behave/testing_solution/logging.conf +102 -0
  55. holado_examples/tests/behave/testing_solution/requirements.txt +5 -0
  56. holado_examples/tests/behave/testing_solution/run_test.sh +7 -0
  57. holado_examples/tests/behave/testing_solution/run_test_nonreg.sh +6 -0
  58. holado_examples/tests/behave/testing_solution/src/common/tools/path_manager.py +40 -0
  59. holado_examples/tests/behave/testing_solution/src/config/config_manager.py +30 -0
  60. holado_examples/tests/behave/testing_solution/src/context/session_context.py +45 -0
  61. holado_examples/tests/behave/testing_solution/steps/config_steps.py +21 -0
  62. holado_examples/tests/behave/testing_solution/steps/public_steps.py +10 -0
  63. holado_multitask/multithreading/functionthreaded.py +11 -5
  64. holado_rest/api/rest/rest_client.py +13 -5
  65. holado_docker/tools/docker_controller/server/grpc/proto/generated/docker_controler_pb2.py +0 -52
  66. holado_docker/tools/docker_controller/server/grpc/proto/generated/docker_controler_pb2_grpc.py +0 -233
  67. {holado-0.6.2.dist-info → holado-0.6.4.dist-info}/WHEEL +0 -0
  68. {holado-0.6.2.dist-info → holado-0.6.4.dist-info}/licenses/LICENSE +0 -0
@@ -12,30 +12,29 @@
12
12
 
13
13
  from flask.views import MethodView
14
14
  from holado.common.context.session_context import SessionContext
15
+ import logging
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
15
20
 
16
21
  def _get_session_context():
17
22
  return SessionContext.instance()
18
23
 
19
24
  class ContainerView(MethodView):
20
25
 
21
- # def post(self, body: dict):
22
- # pass
23
- #
24
- # def put(self, container_name, body: dict):
25
- # pass
26
- #
27
- # def delete(self, container_name):
28
- # pass
29
-
30
- def get(self, name=None, limit=100):
26
+ def get(self, name=None, all_=False, limit=100):
27
+ _get_session_context().docker_client.update_containers(all_=all_)
31
28
  if name is not None:
32
- if not _get_session_context().docker_client.has_container(name):
33
- return f"Container '{name}' doesn't exist", 406
29
+ if not _get_session_context().docker_client.has_container(name, in_list=False, all_=all_, reset_if_removed=False):
30
+ if all_:
31
+ return f"Container '{name}' doesn't exist", 406
32
+ else:
33
+ return f"Container '{name}' is not running (try with '?all=true' to get information on existing but not running containers)", 406
34
34
 
35
- cont = _get_session_context().docker_client.get_container(name)
36
- cont.container.reload()
37
- res = cont.container.attrs
35
+ cont = _get_session_context().docker_client.get_container(name, all_=all_)
36
+ res = cont.information
38
37
  else:
39
- names = _get_session_context().docker_client.get_all_container_names()
40
- res = [{'name':n, 'status':_get_session_context().docker_client.get_container(n).status} for n in names]
38
+ names = _get_session_context().docker_client.get_container_names(in_list=False, all_=all_)
39
+ res = [{'name':n, 'status':_get_session_context().docker_client.get_container(n, all_=all_).status} for n in names]
41
40
  return res
@@ -12,10 +12,16 @@ paths:
12
12
  /container:
13
13
  get:
14
14
  description: "List containers and their status"
15
- parameters: []
15
+ parameters:
16
+ - in: "query"
17
+ name: "all"
18
+ description: "if set to 'true', list all containers, not only running ones"
19
+ schema:
20
+ type: "boolean"
21
+ default: false
16
22
  responses:
17
23
  200:
18
- description: ""
24
+ description: "List of container names with their status"
19
25
  content:
20
26
  application/json:
21
27
  schema:
@@ -28,12 +34,19 @@ paths:
28
34
  parameters:
29
35
  - in: "path"
30
36
  name: "name"
37
+ description: "Container name"
31
38
  required: true
32
39
  schema:
33
40
  type: "string"
41
+ - in: "query"
42
+ name: "all"
43
+ description: "if set to 'true', search container in all containers, not only running ones"
44
+ schema:
45
+ type: "boolean"
46
+ default: false
34
47
  responses:
35
48
  200:
36
- description: ""
49
+ description: "Container information"
37
50
  content:
38
51
  application/json:
39
52
  schema:
@@ -44,6 +57,7 @@ paths:
44
57
  parameters:
45
58
  - in: "path"
46
59
  name: "name"
60
+ description: "Container name"
47
61
  required: true
48
62
  schema:
49
63
  type: "string"
@@ -66,6 +80,7 @@ paths:
66
80
  parameters:
67
81
  - in: "path"
68
82
  name: "name"
83
+ description: "Container name"
69
84
  required: true
70
85
  schema:
71
86
  type: "string"
@@ -88,6 +103,7 @@ paths:
88
103
  parameters:
89
104
  - in: "path"
90
105
  name: "name"
106
+ description: "Container name"
91
107
  required: true
92
108
  schema:
93
109
  type: "string"
@@ -110,6 +126,7 @@ paths:
110
126
  parameters:
111
127
  - in: "path"
112
128
  name: "name"
129
+ description: "Container name"
113
130
  required: true
114
131
  schema:
115
132
  type: "string"
@@ -1,8 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
- # Script to launch Docker Controler as a docker image.
3
+ # Script to launch Docker Controller as a docker image.
4
4
  #
5
- # Docker Controler exposes a REST API for some docker commands.
5
+ # Docker Controller exposes a REST API for some docker commands.
6
6
  # It is accessible on localhost, and also on a docker network if HOLADO_NETWORK is defined.
7
7
  # On all networks, API is accessible on same port (HOLADO_DOCKER_CONTROLLER_PORT or 8000).
8
8
  #
@@ -13,8 +13,8 @@
13
13
  #
14
14
  # Optionally, define in .profile the following variables
15
15
  # - HOLADO_DOCKER_CONTROLLER_PORT: REST API port to use (default: 8000)
16
- # - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/docker_controler)
17
- # - HOLADO_IMAGE_TAG: docker image tag to use (default: main)
16
+ # - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/docker_controller)
17
+ # - HOLADO_IMAGE_TAG: docker image tag to use (default: latest)
18
18
  # - HOLADO_OUTPUT_BASEDIR: absolute path to base output directory (default: [HOME]/.holado/output)
19
19
  # - HOLADO_USE_LOCALHOST: force the container network to 'host'.
20
20
  # - HOLADO_NETWORK: specify on which network the docker is run.
@@ -24,10 +24,10 @@
24
24
  WORK_DIR="$(pwd)"
25
25
 
26
26
  if [[ -z "$HOLADO_IMAGE_REGISTRY" ]]; then
27
- HOLADO_IMAGE_REGISTRY=holado/docker_controler
27
+ HOLADO_IMAGE_REGISTRY=holado/docker_controller
28
28
  fi
29
29
  if [[ -z "$HOLADO_IMAGE_TAG" ]]; then
30
- HOLADO_IMAGE_TAG=main
30
+ HOLADO_IMAGE_TAG=latest
31
31
  fi
32
32
  CONTROLLER_IMAGE=${HOLADO_IMAGE_REGISTRY}:${HOLADO_IMAGE_TAG}
33
33
 
@@ -0,0 +1,40 @@
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
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ class DockerViewerClient(RestClient):
21
+
22
+ def __init__(self, name, url, headers=None):
23
+ super().__init__(name, url, headers)
24
+
25
+ def get_containers_status(self, all_=False):
26
+ if all_:
27
+ response = self.get("container?all=true")
28
+ else:
29
+ response = self.get("container")
30
+ return self.response_result(response, status_ok=[200,204])
31
+
32
+ def get_container_info(self, name, all_=False):
33
+ if all_:
34
+ response = self.get(f"container/{name}?all=true")
35
+ else:
36
+ response = self.get(f"container/{name}")
37
+ return self.response_result(response, status_ok=[200,204])
38
+
39
+
40
+
@@ -0,0 +1,44 @@
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_core.common.tools.converters.converter import Converter
16
+ import os
17
+ from holado_rest.api.rest.rest_manager import RestManager
18
+ from holado_docker.tools.docker_viewer.client.rest.docker_viewer_client import DockerViewerClient
19
+
20
+ logger = logging.getLogger(__name__)
21
+
22
+
23
+ class DockerViewerManager(object):
24
+
25
+ @classmethod
26
+ def new_client(cls, **kwargs):
27
+ if 'name' not in kwargs:
28
+ kwargs['name'] = None
29
+ if 'url' not in kwargs:
30
+ env_use = os.getenv("HOLADO_USE_LOCALHOST", False)
31
+ use_localhost = Converter.is_boolean(env_use) and Converter.to_boolean(env_use)
32
+
33
+ host = "localhost" if use_localhost else os.getenv("HOLADO_DOCKER_VIEWER_NAME", "holado_docker_viewer")
34
+ port = os.getenv("HOLADO_DOCKER_VIEWER_PORT", 8000)
35
+ kwargs['url'] = f"http://{host}:{port}"
36
+
37
+ manager = RestManager(default_client_class=DockerViewerClient)
38
+ res = manager.new_client(**kwargs)
39
+
40
+ return res
41
+
42
+
43
+
44
+
@@ -0,0 +1,70 @@
1
+ ### Build
2
+
3
+ #FROM python:3.12.9-alpine3.21 AS build
4
+ FROM python:3.12.11-alpine3.22 AS build
5
+
6
+ # Install to build python requirements
7
+ RUN apk update \
8
+ && apk --no-cache --update add build-base \
9
+ && apk --update add alpine-sdk \
10
+ && apk add libffi-dev \
11
+ && apk add postgresql-dev gcc python3-dev musl-dev \
12
+ && apk add protobuf-dev
13
+
14
+ # Add tools
15
+ RUN apk --no-cache add bash \
16
+ && apk --no-cache add nano \
17
+ && apk --no-cache add curl
18
+
19
+ # Create user
20
+ RUN addgroup appuser \
21
+ && adduser -G appuser -s /bin/bash -D appuser
22
+
23
+ # Create /code folder
24
+ RUN mkdir /code \
25
+ && chown -R appuser:appuser /code
26
+
27
+ # Switch to user appuser
28
+ USER appuser
29
+
30
+ # Create python venv and install requirements
31
+ COPY --chown=appuser ./requirements.txt /code/docker_viewer/requirements.txt
32
+ WORKDIR /code/docker_viewer
33
+ RUN python -m venv /code/env \
34
+ && source /code/env/bin/activate \
35
+ && pip install -r requirements.txt
36
+
37
+
38
+
39
+ ### Runtime
40
+
41
+ #FROM python:3.12.9-alpine3.21 AS runtime
42
+ FROM python:3.12.11-alpine3.22 AS runtime
43
+
44
+ # Install for python requirements
45
+ #RUN apk update \
46
+ # && apk --no-cache add libstdc++ \
47
+ # && apk --no-cache add postgresql-dev gcc python3-dev musl-dev
48
+
49
+ # Add tools
50
+ RUN apk --no-cache add bash \
51
+ && apk --no-cache add nano \
52
+ && apk --no-cache add curl
53
+
54
+ # Create and switch to user appuser as in build
55
+ RUN addgroup appuser \
56
+ && adduser -G appuser -s /bin/bash -D appuser
57
+ USER appuser
58
+
59
+ # Copy /code from build
60
+ COPY --chown=appuser --from=build /code /code
61
+
62
+ # Copy docker viewer sources
63
+ COPY --chown=appuser ./rest /code/docker_viewer
64
+
65
+ # Activate permanently python venv
66
+ ENV PATH=/code/env/bin:$PATH
67
+
68
+ WORKDIR /code/docker_viewer
69
+ CMD ["sh", "-c", "uvicorn run:app --host 0.0.0.0 --port $HOLADO_DOCKER_VIEWER_PORT"]
70
+
@@ -0,0 +1,2 @@
1
+ # HolAdo framework
2
+ holado[api-connexion,docker,ssl,yaml]
@@ -0,0 +1,2 @@
1
+ REST API specification is described in openapi.yaml.
2
+ If Docker Viewer is running, the specification can be displayed with path /ui (ex: http://127.0.0.1:8000/ui).
@@ -0,0 +1,40 @@
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 logging
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+
21
+ def _get_session_context():
22
+ return SessionContext.instance()
23
+
24
+ class ContainerView(MethodView):
25
+
26
+ def get(self, name=None, all_=False, limit=100):
27
+ _get_session_context().docker_client.update_containers(all_=all_)
28
+ if name is not None:
29
+ if not _get_session_context().docker_client.has_container(name, in_list=False, all_=all_, reset_if_removed=False):
30
+ if all_:
31
+ return f"Container '{name}' doesn't exist", 406
32
+ else:
33
+ return f"Container '{name}' is not running (try with '?all=true' to get information on existing but not running containers)", 406
34
+
35
+ cont = _get_session_context().docker_client.get_container(name, all_=all_)
36
+ res = cont.information
37
+ else:
38
+ names = _get_session_context().docker_client.get_container_names(in_list=False, all_=all_)
39
+ res = [{'name':n, 'status':_get_session_context().docker_client.get_container(n, all_=all_).status} for n in names]
40
+ return res
@@ -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,58 @@
1
+ openapi: "3.0.0"
2
+ info:
3
+ version: "1"
4
+ title: "Docker Viewer API"
5
+ description: |
6
+ API to process some docker actions from anywhere on the network.
7
+ In a microservice architecture, the docker viewer can be run in a docker with special privileges,
8
+ whereas all other microservices have user privileges.
9
+ For example, it is usefull to monitor containers statuses from any terminal on the network.
10
+ paths:
11
+ /container:
12
+ get:
13
+ description: "List containers and their status"
14
+ parameters:
15
+ - in: "query"
16
+ name: "all"
17
+ description: "if set to 'true', list all containers, not only running ones"
18
+ schema:
19
+ type: "boolean"
20
+ default: false
21
+ responses:
22
+ 200:
23
+ description: "List of container names with their status"
24
+ content:
25
+ application/json:
26
+ schema:
27
+ type: "array"
28
+ items:
29
+ type: "string"
30
+ /container/{name}:
31
+ get:
32
+ description: "Display all information of a container"
33
+ parameters:
34
+ - in: "path"
35
+ name: "name"
36
+ description: "Container name"
37
+ required: true
38
+ schema:
39
+ type: "string"
40
+ - in: "query"
41
+ name: "all"
42
+ description: "if set to 'true', search container in all containers, not only running ones"
43
+ schema:
44
+ type: "boolean"
45
+ default: false
46
+ responses:
47
+ 200:
48
+ description: "Container information"
49
+ content:
50
+ application/json:
51
+ schema:
52
+ type: "string"
53
+ components:
54
+ securitySchemes: {}
55
+ schemas:
56
+ DockerControler:
57
+ properties: {}
58
+
@@ -0,0 +1,28 @@
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_minimal
22
+ initialize_minimal()
23
+
24
+
25
+ app = connexion.FlaskApp(__name__, pythonic_params=True)
26
+ app.add_api('openapi.yaml',
27
+ resolver=MethodViewResolver('api'), resolver_error=501,
28
+ pythonic_params=True)
@@ -0,0 +1,101 @@
1
+ #!/bin/bash
2
+
3
+ # Script to launch Docker Viewer as a docker image.
4
+ #
5
+ # Docker Viewer exposes a REST API for some docker commands.
6
+ # It is accessible on localhost, and also on a docker network if HOLADO_NETWORK is defined.
7
+ # On all networks, API is accessible on same port (HOLADO_DOCKER_VIEWER_PORT or 8000).
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_DOCKER_VIEWER_PORT: REST API port to use (default: 8000)
16
+ # - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/docker_viewer)
17
+ # - HOLADO_IMAGE_TAG: docker image tag to use (default: latest)
18
+ # - HOLADO_OUTPUT_BASEDIR: absolute path to base output directory (default: [HOME]/.holado/output)
19
+ # - HOLADO_USE_LOCALHOST: force the container network to 'host'.
20
+ # - HOLADO_NETWORK: specify on which network the docker is run.
21
+ #
22
+
23
+
24
+ WORK_DIR="$(pwd)"
25
+
26
+ if [[ -z "$HOLADO_IMAGE_REGISTRY" ]]; then
27
+ HOLADO_IMAGE_REGISTRY=holado/docker_viewer
28
+ fi
29
+ if [[ -z "$HOLADO_IMAGE_TAG" ]]; then
30
+ HOLADO_IMAGE_TAG=latest
31
+ fi
32
+ VIEWER_IMAGE=${HOLADO_IMAGE_REGISTRY}:${HOLADO_IMAGE_TAG}
33
+
34
+ # Update docker image
35
+ echo "Updating docker image ${VIEWER_IMAGE}..."
36
+ docker pull ${VIEWER_IMAGE}
37
+
38
+ # Define test output directory
39
+ if [[ ! -z "$HOLADO_OUTPUT_BASEDIR" ]]; then
40
+ OUTPUT_DIR=${HOLADO_OUTPUT_BASEDIR}
41
+ else
42
+ OUTPUT_DIR=${HOME}/.holado/output
43
+ fi
44
+ echo "Output directory: $OUTPUT_DIR"
45
+
46
+ # Define test resources directory
47
+ if [[ ! -z "$HOLADO_LOCAL_RESOURCES_BASEDIR" ]]; then
48
+ RESOURCES_DIR=${HOLADO_LOCAL_RESOURCES_BASEDIR}
49
+ else
50
+ RESOURCES_DIR=${HOME}/.holado/resources
51
+ fi
52
+ echo "Resources directory: $RESOURCES_DIR"
53
+
54
+ # Make dirs
55
+ if [ ! -d ${OUTPUT_DIR} ]; then
56
+ echo "Create output directory: ${OUTPUT_DIR}"
57
+ mkdir -p ${OUTPUT_DIR}
58
+ fi
59
+ if [ ! -d ${RESOURCES_DIR} ]; then
60
+ echo "Create resources directory: ${RESOURCES_DIR}"
61
+ mkdir -p ${RESOURCES_DIR}
62
+ fi
63
+
64
+ # Define container network
65
+ if [ "$HOLADO_USE_LOCALHOST" = True ]; then
66
+ NETWORK_DEF_COMMAND="--network=host"
67
+ else
68
+ if [[ ! -z "$HOLADO_NETWORK" ]]; then
69
+ NETWORK_DEF_COMMAND="--network $HOLADO_NETWORK"
70
+ else
71
+ NETWORK_DEF_COMMAND=""
72
+ fi
73
+ fi
74
+
75
+ # Define port to use
76
+ if [[ -z "$HOLADO_DOCKER_VIEWER_PORT" ]]; then
77
+ HOLADO_DOCKER_VIEWER_PORT=8000
78
+ fi
79
+
80
+
81
+ # Docker run
82
+ if [[ -z "$HOLADO_DOCKER_VIEWER_NAME" ]]; then
83
+ HOLADO_DOCKER_VIEWER_NAME=holado_docker_VIEWER
84
+ fi
85
+
86
+ echo
87
+ echo "Running Docker VIEWER (docker name: ${HOLADO_DOCKER_VIEWER_NAME})..."
88
+ echo " port: ${HOLADO_DOCKER_VIEWER_PORT}"
89
+ #echo " NETWORK_DEF_COMMAND=${NETWORK_DEF_COMMAND}"
90
+ echo
91
+ docker run --rm --user root --name ${HOLADO_DOCKER_VIEWER_NAME} \
92
+ --privileged -v /var/run/docker.sock:/var/run/docker.sock \
93
+ -v "${OUTPUT_DIR}":/output \
94
+ -v "${RESOURCES_DIR}":/resources \
95
+ -e HOLADO_OUTPUT_BASEDIR=/output \
96
+ -e HOLADO_LOCAL_RESOURCES_BASEDIR=/resources \
97
+ -e HOLADO_DOCKER_VIEWER_PORT=${HOLADO_DOCKER_VIEWER_PORT} \
98
+ ${NETWORK_DEF_COMMAND} \
99
+ -p ${HOLADO_DOCKER_VIEWER_PORT}:${HOLADO_DOCKER_VIEWER_PORT} \
100
+ ${VIEWER_IMAGE}
101
+