holado 0.11.2__py3-none-any.whl → 0.11.3__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 (37) hide show
  1. {holado-0.11.2.dist-info → holado-0.11.3.dist-info}/METADATA +2 -2
  2. {holado-0.11.2.dist-info → holado-0.11.3.dist-info}/RECORD +37 -4
  3. holado_tools/__init__.py +38 -0
  4. holado_tools/scripts/execute_persisted_post_processes/execute_persisted_post_processes.py +36 -0
  5. holado_tools/scripts/execute_persisted_post_processes/execute_persisted_post_processes.sh +6 -0
  6. holado_tools/scripts/execute_persisted_post_processes/initialize_holado.py +62 -0
  7. holado_tools/tests/behave/steps/__init__.py +16 -0
  8. holado_tools/tests/behave/steps/tools/host_controller/client_steps.py +97 -0
  9. holado_tools/tools/host_controller/client/rest/host_controller_client.py +146 -0
  10. holado_tools/tools/host_controller/server/Dockerfile +60 -0
  11. holado_tools/tools/host_controller/server/grpc/README +2 -0
  12. holado_tools/tools/host_controller/server/grpc/__init__.py +26 -0
  13. holado_tools/tools/host_controller/server/grpc/proto/compile_proto.py +60 -0
  14. holado_tools/tools/host_controller/server/grpc/proto/definitions/docker_controler.proto +63 -0
  15. holado_tools/tools/host_controller/server/requirements.txt +2 -0
  16. holado_tools/tools/host_controller/server/rest/README +2 -0
  17. holado_tools/tools/host_controller/server/rest/api/__init__.py +24 -0
  18. holado_tools/tools/host_controller/server/rest/api/config.py +57 -0
  19. holado_tools/tools/host_controller/server/rest/api/docker/__init__.py +40 -0
  20. holado_tools/tools/host_controller/server/rest/api/docker/container.py +55 -0
  21. holado_tools/tools/host_controller/server/rest/api/os.py +47 -0
  22. holado_tools/tools/host_controller/server/rest/initialize_holado.py +72 -0
  23. holado_tools/tools/host_controller/server/rest/openapi.yaml +265 -0
  24. holado_tools/tools/host_controller/server/rest/run.py +31 -0
  25. holado_tools/tools/host_controller/server/run_host_controller_in_docker.sh +107 -0
  26. holado_tools/tools/host_viewer/client/rest/host_viewer_client.py +96 -0
  27. holado_tools/tools/host_viewer/server/Dockerfile +60 -0
  28. holado_tools/tools/host_viewer/server/requirements.txt +2 -0
  29. holado_tools/tools/host_viewer/server/rest/README +2 -0
  30. holado_tools/tools/host_viewer/server/rest/api/__init__.py +22 -0
  31. holado_tools/tools/host_viewer/server/rest/api/docker/__init__.py +40 -0
  32. holado_tools/tools/host_viewer/server/rest/initialize_holado.py +72 -0
  33. holado_tools/tools/host_viewer/server/rest/openapi.yaml +102 -0
  34. holado_tools/tools/host_viewer/server/rest/run.py +31 -0
  35. holado_tools/tools/host_viewer/server/run_host_viewer_in_docker.sh +107 -0
  36. {holado-0.11.2.dist-info → holado-0.11.3.dist-info}/WHEEL +0 -0
  37. {holado-0.11.2.dist-info → holado-0.11.3.dist-info}/licenses/LICENSE +0 -0
@@ -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
+
@@ -0,0 +1,60 @@
1
+ ### Build
2
+
3
+ #FROM python:3.12.9-alpine3.21 AS build
4
+ #FROM python:3.12.11-alpine3.22 AS build
5
+ FROM python:3.12.12-alpine3.22 AS build
6
+
7
+ # Install to build python requirements
8
+ RUN apk update \
9
+ && apk --no-cache --update add build-base \
10
+ && apk --update add alpine-sdk \
11
+ && apk add libffi-dev
12
+
13
+ # Create user
14
+ RUN addgroup appuser \
15
+ && adduser -G appuser -s /bin/bash -D appuser
16
+
17
+ # Create /code folder
18
+ RUN mkdir /code \
19
+ && chown -R appuser:appuser /code
20
+
21
+ # Switch to user appuser
22
+ USER appuser
23
+
24
+ # Create python venv and install requirements
25
+ COPY --chown=appuser ./requirements.txt /code/host_viewer/requirements.txt
26
+ WORKDIR /code/host_viewer
27
+ RUN python -m venv /code/env \
28
+ && source /code/env/bin/activate \
29
+ && pip install --no-cache-dir -r requirements.txt
30
+
31
+
32
+
33
+ ### Runtime
34
+
35
+ #FROM python:3.12.9-alpine3.21 AS runtime
36
+ #FROM python:3.12.11-alpine3.22 AS runtime
37
+ FROM python:3.12.12-alpine3.22 AS runtime
38
+
39
+ # Add tools
40
+ RUN apk --no-cache add bash \
41
+ && apk --no-cache add nano \
42
+ && apk --no-cache add curl
43
+
44
+ # Create and switch to user appuser as in build
45
+ RUN addgroup appuser \
46
+ && adduser -G appuser -s /bin/bash -D appuser
47
+ USER appuser
48
+
49
+ # Copy /code from build
50
+ COPY --chown=appuser --from=build /code /code
51
+
52
+ # Copy host viewer sources
53
+ COPY --chown=appuser ./rest /code/host_viewer
54
+
55
+ # Activate permanently python venv
56
+ ENV PATH=/code/env/bin:$PATH
57
+
58
+ WORKDIR /code/host_viewer
59
+ CMD ["sh", "-c", "uvicorn run:app --host 0.0.0.0 --port $HOLADO_HOST_VIEWER_PORT"]
60
+
@@ -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,22 @@
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
+ # def _get_session_context():
21
+ # return SessionContext.instance()
22
+
@@ -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,102 @@
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
+ /os/env:
12
+ get:
13
+ description: "Get environment variable values"
14
+ requestBody:
15
+ content:
16
+ application/json:
17
+ schema:
18
+ type: "array"
19
+ items:
20
+ type: "string"
21
+ responses:
22
+ 200:
23
+ description: "Environment variable values"
24
+ content:
25
+ application/json:
26
+ schema:
27
+ type: "array"
28
+ items:
29
+ type: "object"
30
+
31
+ /os/ls:
32
+ get:
33
+ description: "List directory filenames"
34
+ requestBody:
35
+ content:
36
+ application/json:
37
+ schema:
38
+ type: "object"
39
+ properties:
40
+ path:
41
+ type: string
42
+ extension:
43
+ type: string
44
+ nullable: true
45
+ responses:
46
+ 200:
47
+ description: "Directory filenames"
48
+ content:
49
+ application/json:
50
+ schema:
51
+ type: "array"
52
+ items:
53
+ type: "string"
54
+
55
+ /docker/container:
56
+ get:
57
+ description: "List containers and their status"
58
+ parameters:
59
+ - in: "query"
60
+ name: "all"
61
+ description: "if set to 'true', list all containers, not only running ones"
62
+ schema:
63
+ type: "boolean"
64
+ default: false
65
+ responses:
66
+ 200:
67
+ description: "List of container names with their status"
68
+ content:
69
+ application/json:
70
+ schema:
71
+ type: "array"
72
+ items:
73
+ type: "string"
74
+ /docker/container/{name}:
75
+ get:
76
+ description: "Display all information of a container"
77
+ parameters:
78
+ - in: "path"
79
+ name: "name"
80
+ description: "Container name"
81
+ required: true
82
+ schema:
83
+ type: "string"
84
+ - in: "query"
85
+ name: "all"
86
+ description: "if set to 'true', search container in all containers, not only running ones"
87
+ schema:
88
+ type: "boolean"
89
+ default: false
90
+ responses:
91
+ 200:
92
+ description: "Container information"
93
+ content:
94
+ application/json:
95
+ schema:
96
+ type: "string"
97
+ components:
98
+ securitySchemes: {}
99
+ schemas:
100
+ DockerControler:
101
+ properties: {}
102
+
@@ -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':'docker_viewer'},
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 Viewer as a docker image.
4
+ #
5
+ # Host Viewer 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_VIEWER_HOSTPORT from localhost and port HOLADO_HOST_VIEWER_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_VIEWER_HOST: host name or name of the container
16
+ # - HOLADO_HOST_VIEWER_HOSTPORT: REST API port to use from localhost (default: 51231)
17
+ # - HOLADO_HOST_VIEWER_PORT: REST API port to use from network HOLADO_NETWORK (default: 51231)
18
+ # - HOLADO_IMAGE_REGISTRY: docker image registry to use (default: holado/host_viewer)
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_viewer
30
+ fi
31
+ if [[ -z "$HOLADO_IMAGE_TAG" ]]; then
32
+ HOLADO_IMAGE_TAG=latest
33
+ fi
34
+ VIEWER_IMAGE=${HOLADO_IMAGE_REGISTRY}:${HOLADO_IMAGE_TAG}
35
+
36
+ # Update docker image
37
+ echo "Updating docker image ${VIEWER_IMAGE}..."
38
+ docker pull ${VIEWER_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_VIEWER_HOSTPORT" ]]; then
79
+ HOLADO_HOST_VIEWER_HOSTPORT=51231
80
+ fi
81
+ if [[ -z "$HOLADO_HOST_VIEWER_PORT" ]]; then
82
+ HOLADO_HOST_VIEWER_PORT=51231
83
+ fi
84
+
85
+ # Docker run
86
+ if [[ -z "$HOLADO_HOST_VIEWER_NAME" ]]; then
87
+ HOLADO_HOST_VIEWER_NAME=holado_host_viewer
88
+ fi
89
+
90
+ echo
91
+ echo "Running Host Viewer..."
92
+ echo " docker name: ${HOLADO_HOST_VIEWER_HOST}"
93
+ echo " host port: ${HOLADO_HOST_VIEWER_HOSTPORT}"
94
+ echo " port: ${HOLADO_HOST_VIEWER_PORT}"
95
+ #echo " NETWORK_DEF_COMMAND=${NETWORK_DEF_COMMAND}"
96
+ echo
97
+ docker run --rm --user root --name ${HOLADO_HOST_VIEWER_NAME} \
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_VIEWER_PORT=${HOLADO_HOST_VIEWER_PORT} \
104
+ ${NETWORK_DEF_COMMAND} \
105
+ -p ${HOLADO_HOST_VIEWER_PORT}:${HOLADO_HOST_VIEWER_PORT} \
106
+ ${VIEWER_IMAGE}
107
+