holado 0.10.2__py3-none-any.whl → 0.11.1__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 (56) hide show
  1. {holado-0.10.2.dist-info → holado-0.11.1.dist-info}/METADATA +1 -1
  2. {holado-0.10.2.dist-info → holado-0.11.1.dist-info}/RECORD +28 -54
  3. holado_docker/tests/behave/steps/__init__.py +1 -1
  4. holado_helper/docker/run_holado_test_nonreg_in_docker.sh +1 -1
  5. holado_helper/docker/run_terminal_in_docker.sh +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_scenario_by_category_report_builder.py +87 -0
  9. holado_report/report/report_manager.py +5 -1
  10. holado_test/__init__.py +1 -1
  11. holado_test/{test_server → tools/test_server}/server/Dockerfile +7 -17
  12. holado_test/{test_server → tools/test_server}/server/core/server_context.py +1 -1
  13. holado_test/{test_server → tools/test_server}/server/rest/run.py +1 -1
  14. test_holado/features/Test/test_host_controller.feature +13 -0
  15. test_holado/logging.conf +1 -1
  16. holado_docker/tests/behave/steps/tools/docker_controller/client_steps.py +0 -97
  17. holado_docker/tools/docker_controller/client/rest/docker_controller_client.py +0 -143
  18. holado_docker/tools/docker_controller/server/Dockerfile +0 -70
  19. holado_docker/tools/docker_controller/server/grpc/README +0 -2
  20. holado_docker/tools/docker_controller/server/grpc/__init__.py +0 -26
  21. holado_docker/tools/docker_controller/server/grpc/proto/compile_proto.py +0 -60
  22. holado_docker/tools/docker_controller/server/grpc/proto/definitions/docker_controler.proto +0 -63
  23. holado_docker/tools/docker_controller/server/requirements.txt +0 -2
  24. holado_docker/tools/docker_controller/server/rest/README +0 -2
  25. holado_docker/tools/docker_controller/server/rest/api/__init__.py +0 -40
  26. holado_docker/tools/docker_controller/server/rest/api/config.py +0 -57
  27. holado_docker/tools/docker_controller/server/rest/api/container.py +0 -55
  28. holado_docker/tools/docker_controller/server/rest/api/os.py +0 -47
  29. holado_docker/tools/docker_controller/server/rest/openapi.yaml +0 -265
  30. holado_docker/tools/docker_controller/server/rest/run.py +0 -31
  31. holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh +0 -102
  32. holado_docker/tools/docker_viewer/client/rest/docker_viewer_client.py +0 -40
  33. holado_docker/tools/docker_viewer/docker_viewer_manager.py +0 -44
  34. holado_docker/tools/docker_viewer/server/Dockerfile +0 -70
  35. holado_docker/tools/docker_viewer/server/requirements.txt +0 -2
  36. holado_docker/tools/docker_viewer/server/rest/README +0 -2
  37. holado_docker/tools/docker_viewer/server/rest/api/__init__.py +0 -40
  38. holado_docker/tools/docker_viewer/server/rest/initialize_holado.py +0 -72
  39. holado_docker/tools/docker_viewer/server/rest/openapi.yaml +0 -58
  40. holado_docker/tools/docker_viewer/server/rest/run.py +0 -31
  41. holado_docker/tools/docker_viewer/server/run_docker_viewer_in_docker.sh +0 -101
  42. holado_test/test_server/server/rest/initialize_holado.py +0 -72
  43. test_holado/features/Test/test_docker_controller.feature +0 -13
  44. {holado-0.10.2.dist-info → holado-0.11.1.dist-info}/WHEEL +0 -0
  45. {holado-0.10.2.dist-info → holado-0.11.1.dist-info}/licenses/LICENSE +0 -0
  46. /holado_test/{test_server → tools/test_server}/client/rest/test_server_client.py +0 -0
  47. /holado_test/{test_server → tools/test_server}/server/core/server_manager.py +0 -0
  48. /holado_test/{test_server → tools/test_server}/server/requirements.txt +0 -0
  49. /holado_test/{test_server → tools/test_server}/server/rest/README +0 -0
  50. /holado_test/{test_server → tools/test_server}/server/rest/api/__init__.py +0 -0
  51. /holado_test/{test_server → tools/test_server}/server/rest/api/campaign/__init__.py +0 -0
  52. /holado_test/{test_server → tools/test_server}/server/rest/api/campaign/scenario.py +0 -0
  53. {holado_docker/tools/docker_controller → holado_test/tools/test_server}/server/rest/initialize_holado.py +0 -0
  54. /holado_test/{test_server → tools/test_server}/server/rest/logging.conf +0 -0
  55. /holado_test/{test_server → tools/test_server}/server/rest/openapi.yaml +0 -0
  56. /holado_test/{test_server → tools/test_server}/server/run_test_server_in_docker.sh +0 -0
@@ -1,143 +0,0 @@
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 default_value, undefined_argument,\
17
- undefined_value
18
- import os
19
- from holado_core.common.tools.converters.converter import Converter
20
- from holado_rest.api.rest.rest_manager import RestManager
21
-
22
- logger = logging.getLogger(__name__)
23
-
24
-
25
- class DockerControllerClient(RestClient):
26
-
27
- @classmethod
28
- def new_client(cls, use_localhost=undefined_argument, **kwargs):
29
- if 'name' not in kwargs:
30
- kwargs['name'] = None
31
- if 'url' not in kwargs:
32
- if use_localhost is undefined_argument:
33
- env_use = os.getenv("HOLADO_USE_LOCALHOST", False)
34
- use_localhost = Converter.is_boolean(env_use) and Converter.to_boolean(env_use)
35
-
36
- url = os.getenv("HOLADO_DOCKER_CONTROLLER_URL", undefined_value)
37
- if url is undefined_value:
38
- scheme = kwargs.get('scheme', undefined_value)
39
- if scheme is undefined_value:
40
- scheme = os.getenv("HOLADO_DOCKER_CONTROLLER_SCHEME", "http")
41
- host = kwargs.get('host', undefined_value)
42
- if host is undefined_value:
43
- host = "localhost" if use_localhost else os.getenv("HOLADO_DOCKER_CONTROLLER_HOST", "holado_docker_controller")
44
- port = kwargs.get('port', undefined_value)
45
- if port is undefined_value:
46
- port = os.getenv("HOLADO_DOCKER_CONTROLLER_PORT", 51231)
47
-
48
- if port is None:
49
- url = f"{scheme}://{host}"
50
- else:
51
- url = f"{scheme}://{host}:{port}"
52
- kwargs['url'] = url
53
-
54
- manager = RestManager(default_client_class=DockerControllerClient)
55
- res = manager.new_client(**kwargs)
56
-
57
- return res
58
-
59
-
60
- def __init__(self, name, url, headers=None):
61
- super().__init__(name, url, headers)
62
-
63
- # Common features
64
-
65
- def get_environment_variable_value(self, var_name):
66
- data = [var_name]
67
- response = self.get(f"os/env", json=data)
68
- return self.response_result(response, status_ok=[200])
69
-
70
- def get_directory_filenames(self, path, extension='.yml'):
71
- data = {'path':path, 'extension':extension}
72
- response = self.get(f"os/ls", json=data)
73
- return self.response_result(response, status_ok=[200])
74
-
75
-
76
- # Manage containers
77
-
78
- def get_containers_status(self, all_=False):
79
- if all_:
80
- response = self.get("container?all=true")
81
- else:
82
- response = self.get("container")
83
- return self.response_result(response, status_ok=[200,204])
84
-
85
- def get_container_info(self, name, all_=False):
86
- """Get container info
87
- @return container info if found, else None
88
- """
89
- if all_:
90
- response = self.get(f"container/{name}?all=true")
91
- else:
92
- response = self.get(f"container/{name}")
93
- return self.response_result(response, status_ok=[200,204], result_on_statuses={204:None, default_value:None})
94
-
95
- def restart_container(self, name, start_if_gone=False):
96
- response = self.put(f"container/{name}/restart")
97
- if start_if_gone and response.status_code == 410:
98
- return self.start_container(name)
99
- else:
100
- return self.response_result(response, status_ok=[200,204])
101
-
102
- def start_container(self, name):
103
- response = self.put(f"container/{name}/start")
104
- return self.response_result(response, status_ok=[200,204])
105
-
106
- def stop_container(self, name, raise_if_gone=True):
107
- response = self.put(f"container/{name}/stop")
108
- if not raise_if_gone and response.status_code == 410:
109
- return None
110
- else:
111
- return self.response_result(response, status_ok=[200,204])
112
-
113
- def wait_container(self, name, raise_if_gone=True):
114
- response = self.put(f"container/{name}/wait")
115
- if not raise_if_gone and response.status_code == 410:
116
- return None
117
- else:
118
- return self.response_result(response, status_ok=[200,204])
119
-
120
-
121
- # Manage configuration
122
-
123
- def update_yaml_file(self, file_path, text, with_backup=True, backup_extension='.ha_bak'):
124
- data = {
125
- 'file_path': file_path,
126
- 'yaml_string': text,
127
- 'with_backup': with_backup,
128
- 'backup_extension': backup_extension
129
- }
130
- response = self.patch(f"config/yaml_file", json=data)
131
- return self.response_result(response, status_ok=[200,204])
132
-
133
- def restore_yaml_file(self, file_path, backup_extension='.ha_bak'):
134
- data = {
135
- 'action': 'restore',
136
- 'file_path': file_path,
137
- 'backup_extension': backup_extension
138
- }
139
- response = self.put(f"config/yaml_file", json=data)
140
- return self.response_result(response, status_ok=[200,204])
141
-
142
-
143
-
@@ -1,70 +0,0 @@
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_controller/requirements.txt
32
- WORKDIR /code/docker_controller
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 controller sources
63
- COPY --chown=appuser ./rest /code/docker_controller
64
-
65
- # Activate permanently python venv
66
- ENV PATH=/code/env/bin:$PATH
67
-
68
- WORKDIR /code/docker_controller
69
- CMD ["sh", "-c", "uvicorn run:app --host 0.0.0.0 --port $HOLADO_DOCKER_CONTROLLER_PORT"]
70
-
@@ -1,2 +0,0 @@
1
- WARNING: The content of this folder is not working yet
2
- Use the REST version of Docker Controller that is in ../rest folder
@@ -1,26 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- #################################################
4
- # HolAdo (Holistic Automation do)
5
- #
6
- # (C) Copyright 2021-2025 by Eric Klumpp
7
- #
8
- # 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:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
-
12
- # 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.
13
- #################################################
14
-
15
- import os
16
- import sys
17
-
18
-
19
- # Add path to compiled proto files used by docker controler classes
20
- here = os.path.abspath(os.path.dirname(__file__))
21
- compiled_proto_path = os.path.normpath(os.path.join(here, "proto", "generated"))
22
- if compiled_proto_path not in sys.path:
23
- sys.path.append(compiled_proto_path)
24
-
25
-
26
-
@@ -1,60 +0,0 @@
1
- import os
2
- import sys
3
- import shutil
4
-
5
- here = os.path.abspath(os.path.dirname(__file__))
6
-
7
- holado_src_path = os.path.normpath(os.path.join(here, "..", "..", "..", ".."))
8
- holado_path = os.path.normpath(os.path.join(holado_src_path, ".."))
9
- sys.path.insert(0, holado_src_path)
10
- print(f"Inserted path: {holado_src_path}")
11
-
12
- from holado_core.common.tools.path_manager import PathManager
13
- # from holado_protobuf.ipc.protobuf.protobuf_compiler import ProtobufCompiler
14
- from holado_grpc.ipc.rpc.grpc_compiler import GRpcCompiler
15
-
16
- # def compile_protobuf_proto(remove_destination=True):
17
- # # Define protoc path
18
- # protoc_exe_path = os.path.join(holado_path, "dependencies", "protoc", "protoc-23.4-linux-x86_64", "bin", "protoc")
19
- #
20
- # # Define proto and generated paths
21
- # proto_path = os.path.join(here, "definitions")
22
- # destination_path = os.path.join(here, "generated")
23
- #
24
- # # Remove existing destination
25
- # if remove_destination and os.path.exists(destination_path) and os.path.isdir(destination_path):
26
- # shutil.rmtree(destination_path)
27
- #
28
- # protoc = ProtobufCompiler()
29
- # protoc.protoc_exe_path = protoc_exe_path
30
- #
31
- # protoc.register_proto_path(os.path.join(proto_path, "xxx"), os.path.join(destination_path, "xxx"), os.path.join(proto_path, "xxx", "yyy"))
32
- #
33
- # protoc.compile_all_proto()
34
-
35
- def compile_grpc_proto(remove_destination=True):
36
- # Define proto and generated paths
37
- proto_path = os.path.join(here, "definitions")
38
- destination_path = os.path.join(here, "generated")
39
-
40
- # Remove existing destination
41
- if remove_destination and os.path.exists(destination_path) and os.path.isdir(destination_path):
42
- if destination_path != proto_path:
43
- shutil.rmtree(destination_path)
44
- else:
45
- path_manager = PathManager()
46
- glob_pattern = os.path.join(destination_path, "*.py")
47
- path_manager.remove_paths(glob_pattern)
48
-
49
- protoc = GRpcCompiler()
50
-
51
- protoc.register_proto_path(proto_path, destination_path)
52
-
53
- protoc.compile_all_proto()
54
-
55
- if __name__ == "__main__":
56
- # compile_protobuf_proto()
57
- # compile_grpc_proto(remove_destination=False)
58
- compile_grpc_proto()
59
-
60
-
@@ -1,63 +0,0 @@
1
- syntax = "proto3";
2
-
3
- package docker_controler;
4
-
5
-
6
- // DockerControlerService represents the querying service provided by docker controler.
7
- service DockerControlerService {
8
- // Get all container names.
9
- rpc GetAllContainerNames(GetAllContainerNamesRequest) returns (GetAllContainerNamesResponse) {};
10
-
11
- // Start a container.
12
- rpc StartContainer(StartContainerRequest) returns (StartContainerResponse) {};
13
-
14
- // Stop a container.
15
- rpc StopContainer(StopContainerRequest) returns (StopContainerResponse) {};
16
-
17
- // Restart a container.
18
- rpc RestartContainer(RestartContainerRequest) returns (RestartContainerResponse) {};
19
- }
20
-
21
-
22
- // Request and Response of DockerControlerService.GetAllContainerNames.
23
- message GetAllContainerNamesRequest {
24
- }
25
-
26
- message GetAllContainerNamesResponse {
27
- // List of names of containers existing on server.
28
- repeated string container_names = 1;
29
- }
30
-
31
- // Request and Response of DockerControlerService.StartContainer.
32
- message StartContainerRequest {
33
- // Container name.
34
- string name = 1;
35
- }
36
-
37
- message StartContainerResponse {
38
- // Container status after request
39
- string container_status = 1;
40
- }
41
-
42
- // Request and Response of DockerControlerService.StopContainer.
43
- message StopContainerRequest {
44
- // Container name.
45
- string name = 1;
46
- }
47
-
48
- message StopContainerResponse {
49
- // Container status after request
50
- string container_status = 1;
51
- }
52
-
53
- // Request and Response of DockerControlerService.RestartContainer.
54
- message RestartContainerRequest {
55
- // Container name.
56
- string name = 1;
57
- }
58
-
59
- message RestartContainerResponse {
60
- // Container status after request
61
- string container_status = 1;
62
- }
63
-
@@ -1,2 +0,0 @@
1
- # HolAdo framework
2
- holado[api-connexion,docker,ssl,yaml]
@@ -1,2 +0,0 @@
1
- REST API specification is described in openapi.yaml.
2
- If Docker Controller is running, the specification can be displayed with path /ui (ex: http://127.0.0.1:8000/ui).
@@ -1,40 +0,0 @@
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
@@ -1,57 +0,0 @@
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
- from holado_yaml.yaml.yaml_manager import YAMLManager
16
-
17
- def _get_session_context():
18
- return SessionContext.instance()
19
-
20
-
21
- class YamlFileView(MethodView):
22
-
23
- def get(self, body: dict):
24
- file_path = body['file_path']
25
-
26
- with open(file_path, 'rt') as fin:
27
- res = fin.read()
28
-
29
- return res
30
-
31
- def patch(self, body: dict):
32
- file_path = body['file_path']
33
- yaml_string = body['yaml_string']
34
- with_backup = body['with_backup']
35
- backup_extension = body['backup_extension']
36
-
37
- data = YAMLManager.load_string(yaml_string)
38
- res = YAMLManager.update_file(file_path, data, with_backup=with_backup, backup_extension=backup_extension)
39
-
40
- return res
41
-
42
- def put(self, body: list):
43
- action = body['action']
44
- file_path = body['file_path']
45
- backup_extension = body['backup_extension']
46
-
47
- if action == 'restore':
48
- res = YAMLManager.restore_file(file_path, backup_extension=backup_extension)
49
- else:
50
- return f"Unmanaged action '{action}'", 400
51
-
52
- return res
53
-
54
-
55
-
56
-
57
-
@@ -1,55 +0,0 @@
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
-
@@ -1,47 +0,0 @@
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
-