oak-cli 0.2.5__tar.gz → 0.2.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oak_cli-0.2.8/PKG-INFO +106 -0
- oak_cli-0.2.8/README.md +90 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/apps/delete.py +3 -5
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/apps/status.py +1 -3
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/main.py +5 -0
- oak_cli-0.2.8/oak_cli/args_parser/plugins/flops/create.py +16 -0
- oak_cli-0.2.8/oak_cli/args_parser/plugins/flops/main.py +25 -0
- oak_cli-0.2.8/oak_cli/args_parser/plugins/main.py +25 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/services/deployment.py +1 -3
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/services/status.py +1 -4
- oak_cli-0.2.8/oak_cli/commands/apps/main.py +81 -0
- oak_cli-0.2.8/oak_cli/commands/apps/status.py +11 -0
- oak_cli-0.2.8/oak_cli/commands/plugins/flops/flops.SLA.json +13 -0
- oak_cli-0.2.8/oak_cli/commands/plugins/flops/main.py +29 -0
- oak_cli-0.2.8/oak_cli/commands/services/__init__.py +0 -0
- oak_cli-0.2.8/oak_cli/commands/services/deployment.py +39 -0
- oak_cli-0.2.8/oak_cli/commands/services/get.py +38 -0
- oak_cli-0.2.8/oak_cli/commands/services/status.py +41 -0
- oak_cli-0.2.8/oak_cli/main.py +28 -0
- oak_cli-0.2.8/oak_cli/utils/SLAs/__init__.py +0 -0
- oak_cli-0.2.8/oak_cli/utils/__init__.py +0 -0
- oak_cli-0.2.8/oak_cli/utils/api/__init__.py +0 -0
- oak_cli-0.2.8/oak_cli/utils/api/common.py +3 -0
- oak_cli-0.2.5/oak_cli/utils/api/common.py → oak_cli-0.2.8/oak_cli/utils/api/custom_http.py +0 -5
- oak_cli-0.2.8/oak_cli/utils/api/custom_requests.py +94 -0
- oak_cli-0.2.8/oak_cli/utils/api/login.py +36 -0
- oak_cli-0.2.8/oak_cli/utils/exceptions.py +23 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/logging.py +0 -1
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/types.py +0 -2
- {oak_cli-0.2.5 → oak_cli-0.2.8}/pyproject.toml +5 -1
- oak_cli-0.2.5/PKG-INFO +0 -98
- oak_cli-0.2.5/README.md +0 -83
- oak_cli-0.2.5/oak_cli/commands/apps/main.py +0 -60
- oak_cli-0.2.5/oak_cli/commands/apps/status.py +0 -21
- oak_cli-0.2.5/oak_cli/commands/services/deployment.py +0 -30
- oak_cli-0.2.5/oak_cli/commands/services/get.py +0 -29
- oak_cli-0.2.5/oak_cli/commands/services/status.py +0 -75
- oak_cli-0.2.5/oak_cli/main.py +0 -14
- oak_cli-0.2.5/oak_cli/utils/api/login.py +0 -33
- oak_cli-0.2.5/oak_cli/utils/api/main.py +0 -108
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/__init__.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/__init__.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/apps/__init__.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/apps/create.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/apps/main.py +0 -0
- {oak_cli-0.2.5/oak_cli/args_parser/services → oak_cli-0.2.8/oak_cli/args_parser/plugins}/__init__.py +0 -0
- {oak_cli-0.2.5/oak_cli/commands/apps → oak_cli-0.2.8/oak_cli/args_parser/plugins/flops}/__init__.py +0 -0
- {oak_cli-0.2.5/oak_cli/commands → oak_cli-0.2.8/oak_cli/args_parser}/services/__init__.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/args_parser/services/main.py +0 -0
- {oak_cli-0.2.5/oak_cli/utils/SLAs → oak_cli-0.2.8/oak_cli/commands/apps}/__init__.py +0 -0
- {oak_cli-0.2.5/oak_cli/utils → oak_cli-0.2.8/oak_cli/commands/plugins}/__init__.py +0 -0
- {oak_cli-0.2.5/oak_cli/utils/api → oak_cli-0.2.8/oak_cli/commands/plugins/flops}/__init__.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/SLAs/blank_app_without_services.SLA.json +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/SLAs/common.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/SLAs/default_app_with_services.SLA.json +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/argcomplete.py +0 -0
- {oak_cli-0.2.5 → oak_cli-0.2.8}/oak_cli/utils/common.py +0 -0
oak_cli-0.2.8/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: oak_cli
|
|
3
|
+
Version: 0.2.8
|
|
4
|
+
Summary:
|
|
5
|
+
Author: Alexander Malyuk
|
|
6
|
+
Author-email: malyuk.alexander1999@gmail.com
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Dist: argcomplete (>=3.2.3,<4.0.0)
|
|
13
|
+
Requires-Dist: icecream (>=2.1.3,<3.0.0)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# [Oakestra CLI](https://github.com/oakestra/oakestra-cli)
|
|
17
|
+
|
|
18
|
+
**oakestra-cli** is a very basic command line tool for controlling your [Oakestra](https://github.com/oakestra/oakestra) setup.
|
|
19
|
+
|
|
20
|
+
It is intended to be an interface for the API as well as a development tool.
|
|
21
|
+
|
|
22
|
+
The CLI supports command (tab) autocompletion.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
The package can be called via `oak`.
|
|
26
|
+
|
|
27
|
+
Currently, it supports the creation, deletion, inspection, and (un)deployment of applications and services.
|
|
28
|
+
|
|
29
|
+
E.g. To deploy a default application with two services:
|
|
30
|
+
```
|
|
31
|
+
oak applications create default_app_with_services --deploy
|
|
32
|
+
```
|
|
33
|
+
Note: The CLI supports short command aliases. The command above can be shortened like this:
|
|
34
|
+
```
|
|
35
|
+
oak a c default_app_with_services -d
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You should see a similar output if the command was successful:
|
|
39
|
+
```bash
|
|
40
|
+
Success: Create new application based on 'default_app_with_services'
|
|
41
|
+
Success: Deploy a new instance for the service '66040243c7723114bb83b914'
|
|
42
|
+
Success: Deploy a new instance for the service '66040243c7723114bb83b919'
|
|
43
|
+
```
|
|
44
|
+
You can inspect the services like this:
|
|
45
|
+
```bash
|
|
46
|
+
oak services status
|
|
47
|
+
```
|
|
48
|
+
Or like this: `oak s s`
|
|
49
|
+
|
|
50
|
+
Service status output:
|
|
51
|
+
```yaml
|
|
52
|
+
All current services: '2'
|
|
53
|
+
Service '0':
|
|
54
|
+
- microservice -
|
|
55
|
+
id: '66040243c7723114bb83b914'
|
|
56
|
+
name: 'curl'
|
|
57
|
+
ns: 'test'
|
|
58
|
+
parent app: 'clientsrvr: 660402439df62d60bb95452b'
|
|
59
|
+
- resources -
|
|
60
|
+
memory: '100'
|
|
61
|
+
vcpus: '1'
|
|
62
|
+
- container -
|
|
63
|
+
image: 'docker.io/curlimages/curl:7.82.0'
|
|
64
|
+
- networking -
|
|
65
|
+
port: '9080'
|
|
66
|
+
- instances -
|
|
67
|
+
instances: '1'
|
|
68
|
+
Service '1':
|
|
69
|
+
- microservice -
|
|
70
|
+
id: '66040243c7723114bb83b919'
|
|
71
|
+
name: 'nginx'
|
|
72
|
+
ns: 'test'
|
|
73
|
+
parent app: 'clientsrvr: 660402439df62d60bb95452b'
|
|
74
|
+
- resources -
|
|
75
|
+
memory: '100'
|
|
76
|
+
vcpus: '1'
|
|
77
|
+
- container -
|
|
78
|
+
image: 'docker.io/library/nginx:latest'
|
|
79
|
+
- networking -
|
|
80
|
+
port: '6080:60/tcp'
|
|
81
|
+
- instances -
|
|
82
|
+
instances: '1'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For a more detailed explanation try out the CLI and use the `-h` flag.
|
|
86
|
+
|
|
87
|
+
## [Installation](https://pypi.org/project/oak-cli/)
|
|
88
|
+
```
|
|
89
|
+
pip install oak-cli
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
# For CLI Contributors/Developers
|
|
93
|
+
For local development with "hot-reload" functionality simply install the package via poetry.
|
|
94
|
+
|
|
95
|
+
## Useful commands
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
poetry install
|
|
99
|
+
```
|
|
100
|
+
```bash
|
|
101
|
+
poetry build
|
|
102
|
+
```
|
|
103
|
+
```
|
|
104
|
+
twine upload dist/*
|
|
105
|
+
```
|
|
106
|
+
|
oak_cli-0.2.8/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# [Oakestra CLI](https://github.com/oakestra/oakestra-cli)
|
|
2
|
+
|
|
3
|
+
**oakestra-cli** is a very basic command line tool for controlling your [Oakestra](https://github.com/oakestra/oakestra) setup.
|
|
4
|
+
|
|
5
|
+
It is intended to be an interface for the API as well as a development tool.
|
|
6
|
+
|
|
7
|
+
The CLI supports command (tab) autocompletion.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
The package can be called via `oak`.
|
|
11
|
+
|
|
12
|
+
Currently, it supports the creation, deletion, inspection, and (un)deployment of applications and services.
|
|
13
|
+
|
|
14
|
+
E.g. To deploy a default application with two services:
|
|
15
|
+
```
|
|
16
|
+
oak applications create default_app_with_services --deploy
|
|
17
|
+
```
|
|
18
|
+
Note: The CLI supports short command aliases. The command above can be shortened like this:
|
|
19
|
+
```
|
|
20
|
+
oak a c default_app_with_services -d
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
You should see a similar output if the command was successful:
|
|
24
|
+
```bash
|
|
25
|
+
Success: Create new application based on 'default_app_with_services'
|
|
26
|
+
Success: Deploy a new instance for the service '66040243c7723114bb83b914'
|
|
27
|
+
Success: Deploy a new instance for the service '66040243c7723114bb83b919'
|
|
28
|
+
```
|
|
29
|
+
You can inspect the services like this:
|
|
30
|
+
```bash
|
|
31
|
+
oak services status
|
|
32
|
+
```
|
|
33
|
+
Or like this: `oak s s`
|
|
34
|
+
|
|
35
|
+
Service status output:
|
|
36
|
+
```yaml
|
|
37
|
+
All current services: '2'
|
|
38
|
+
Service '0':
|
|
39
|
+
- microservice -
|
|
40
|
+
id: '66040243c7723114bb83b914'
|
|
41
|
+
name: 'curl'
|
|
42
|
+
ns: 'test'
|
|
43
|
+
parent app: 'clientsrvr: 660402439df62d60bb95452b'
|
|
44
|
+
- resources -
|
|
45
|
+
memory: '100'
|
|
46
|
+
vcpus: '1'
|
|
47
|
+
- container -
|
|
48
|
+
image: 'docker.io/curlimages/curl:7.82.0'
|
|
49
|
+
- networking -
|
|
50
|
+
port: '9080'
|
|
51
|
+
- instances -
|
|
52
|
+
instances: '1'
|
|
53
|
+
Service '1':
|
|
54
|
+
- microservice -
|
|
55
|
+
id: '66040243c7723114bb83b919'
|
|
56
|
+
name: 'nginx'
|
|
57
|
+
ns: 'test'
|
|
58
|
+
parent app: 'clientsrvr: 660402439df62d60bb95452b'
|
|
59
|
+
- resources -
|
|
60
|
+
memory: '100'
|
|
61
|
+
vcpus: '1'
|
|
62
|
+
- container -
|
|
63
|
+
image: 'docker.io/library/nginx:latest'
|
|
64
|
+
- networking -
|
|
65
|
+
port: '6080:60/tcp'
|
|
66
|
+
- instances -
|
|
67
|
+
instances: '1'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
For a more detailed explanation try out the CLI and use the `-h` flag.
|
|
71
|
+
|
|
72
|
+
## [Installation](https://pypi.org/project/oak-cli/)
|
|
73
|
+
```
|
|
74
|
+
pip install oak-cli
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
# For CLI Contributors/Developers
|
|
78
|
+
For local development with "hot-reload" functionality simply install the package via poetry.
|
|
79
|
+
|
|
80
|
+
## Useful commands
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
poetry install
|
|
84
|
+
```
|
|
85
|
+
```bash
|
|
86
|
+
poetry build
|
|
87
|
+
```
|
|
88
|
+
```
|
|
89
|
+
twine upload dist/*
|
|
90
|
+
```
|
|
@@ -14,7 +14,7 @@ _DELETION_HELP_TEXT = "deletes one or all applications" + _APP_ID_HELP_TEXT
|
|
|
14
14
|
def prepare_applications_deletion_argparser(
|
|
15
15
|
applications_subparsers: Subparsers,
|
|
16
16
|
) -> None:
|
|
17
|
-
def
|
|
17
|
+
def aux_delete_applications(args: Any):
|
|
18
18
|
if args.all:
|
|
19
19
|
delete_all_applications()
|
|
20
20
|
else:
|
|
@@ -30,7 +30,5 @@ def prepare_applications_deletion_argparser(
|
|
|
30
30
|
applications_deletion_parser.add_argument(
|
|
31
31
|
"-a", "--all", action="store_true", help="delete all applications"
|
|
32
32
|
)
|
|
33
|
-
applications_deletion_parser.add_argument(
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
applications_deletion_parser.set_defaults(func=aux_delete_appliacations)
|
|
33
|
+
applications_deletion_parser.add_argument("app_id", nargs="?", type=str, help=_APP_ID_HELP_TEXT)
|
|
34
|
+
applications_deletion_parser.set_defaults(func=aux_delete_applications)
|
|
@@ -13,6 +13,4 @@ def prepare_applications_display_argparser(applications_subparsers: Subparsers)
|
|
|
13
13
|
description=HELP_TEXT,
|
|
14
14
|
formatter_class=argparse.RawTextHelpFormatter,
|
|
15
15
|
)
|
|
16
|
-
applications_status_parser.set_defaults(
|
|
17
|
-
func=lambda _: display_current_applications()
|
|
18
|
-
)
|
|
16
|
+
applications_status_parser.set_defaults(func=lambda _: display_current_applications())
|
|
@@ -5,6 +5,9 @@ import argparse
|
|
|
5
5
|
import argcomplete
|
|
6
6
|
|
|
7
7
|
from oak_cli.args_parser.apps.main import prepare_applications_argparsers
|
|
8
|
+
|
|
9
|
+
# from oak_cli.args_parser.docker.main import prepare_docker_argparsers
|
|
10
|
+
from oak_cli.args_parser.plugins.main import prepare_plugins_argparsers
|
|
8
11
|
from oak_cli.args_parser.services.main import prepare_services_argparsers
|
|
9
12
|
|
|
10
13
|
|
|
@@ -19,6 +22,8 @@ def parse_arguments_and_execute() -> None:
|
|
|
19
22
|
|
|
20
23
|
prepare_applications_argparsers(subparsers)
|
|
21
24
|
prepare_services_argparsers(subparsers)
|
|
25
|
+
prepare_plugins_argparsers(subparsers)
|
|
26
|
+
# prepare_docker_argparsers(subparsers)
|
|
22
27
|
|
|
23
28
|
argcomplete.autocomplete(parser)
|
|
24
29
|
args = parser.parse_args()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
from oak_cli.commands.plugins.flops.main import create_new_fl_service
|
|
4
|
+
from oak_cli.utils.types import Subparsers
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def prepare_flops_create_argparser(flops_subparser: Subparsers) -> None:
|
|
8
|
+
HELP_TEXT = "creates a new FLOps process - i.e. triggers the init FLOps API"
|
|
9
|
+
flops_create_parser = flops_subparser.add_parser(
|
|
10
|
+
"create",
|
|
11
|
+
aliases=["c"],
|
|
12
|
+
help=HELP_TEXT,
|
|
13
|
+
description=HELP_TEXT,
|
|
14
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
15
|
+
)
|
|
16
|
+
flops_create_parser.set_defaults(func=lambda _: create_new_fl_service())
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from oak_cli.args_parser.plugins.flops.create import prepare_flops_create_argparser
|
|
5
|
+
from oak_cli.utils.types import Subparsers
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def prepare_flops_argparsers(subparsers: Subparsers) -> None:
|
|
9
|
+
flops_parser = subparsers.add_parser(
|
|
10
|
+
"flops",
|
|
11
|
+
aliases=["fl"],
|
|
12
|
+
help="command for FLOps related activities",
|
|
13
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
def flops_parser_print_help(_: Any) -> None:
|
|
17
|
+
flops_parser.print_help()
|
|
18
|
+
|
|
19
|
+
flops_parser.set_defaults(func=flops_parser_print_help)
|
|
20
|
+
|
|
21
|
+
flops_subparser = flops_parser.add_subparsers(
|
|
22
|
+
dest="FLOps commands",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
prepare_flops_create_argparser(flops_subparser)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from oak_cli.args_parser.plugins.flops.main import prepare_flops_argparsers
|
|
5
|
+
from oak_cli.utils.types import Subparsers
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def prepare_plugins_argparsers(subparsers: Subparsers) -> None:
|
|
9
|
+
plugins_parser = subparsers.add_parser(
|
|
10
|
+
"plugins",
|
|
11
|
+
aliases=["p"],
|
|
12
|
+
help="command for plugin related activities",
|
|
13
|
+
formatter_class=argparse.RawTextHelpFormatter,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
def plugins_parser_print_help(_: Any) -> None:
|
|
17
|
+
plugins_parser.print_help()
|
|
18
|
+
|
|
19
|
+
plugins_parser.set_defaults(func=plugins_parser_print_help)
|
|
20
|
+
|
|
21
|
+
plugins_subparsers = plugins_parser.add_subparsers(
|
|
22
|
+
dest="plugins commands",
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
prepare_flops_argparsers(plugins_subparsers)
|
|
@@ -19,9 +19,7 @@ def prepare_services_deployment_argparser(services_subparsers: Subparsers) -> No
|
|
|
19
19
|
formatter_class=argparse.RawTextHelpFormatter,
|
|
20
20
|
)
|
|
21
21
|
services_deployment_parser.add_argument("service_id", type=str)
|
|
22
|
-
services_deployment_parser.set_defaults(
|
|
23
|
-
func=lambda args: deploy_new_instance(args.service_id)
|
|
24
|
-
)
|
|
22
|
+
services_deployment_parser.set_defaults(func=lambda args: deploy_new_instance(args.service_id))
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
def prepare_services_undeployment_argparser(services_subparsers: Subparsers) -> None:
|
|
@@ -2,10 +2,7 @@ import argparse
|
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
4
|
from oak_cli.commands.services.get import get_single_service
|
|
5
|
-
from oak_cli.commands.services.status import
|
|
6
|
-
display_all_current_services,
|
|
7
|
-
display_single_service,
|
|
8
|
-
)
|
|
5
|
+
from oak_cli.commands.services.status import display_all_current_services, display_single_service
|
|
9
6
|
from oak_cli.utils.types import Subparsers
|
|
10
7
|
|
|
11
8
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import json
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
import oak_cli.utils.api.custom_requests as custom_requests
|
|
6
|
+
from oak_cli.utils.api.common import SYSTEM_MANAGER_URL
|
|
7
|
+
from oak_cli.utils.api.custom_http import HttpMethod
|
|
8
|
+
from oak_cli.utils.logging import logger
|
|
9
|
+
from oak_cli.utils.SLAs.common import get_SLAs_path
|
|
10
|
+
from oak_cli.utils.types import Application, ApplicationId
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_application(app_id: ApplicationId) -> Application:
|
|
14
|
+
return custom_requests.CustomRequest(
|
|
15
|
+
custom_requests.RequestCore(
|
|
16
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
17
|
+
api_endpoint=f"/api/application/{app_id}",
|
|
18
|
+
),
|
|
19
|
+
custom_requests.RequestAuxiliaries(
|
|
20
|
+
what_should_happen=f"Get application '{app_id}'",
|
|
21
|
+
),
|
|
22
|
+
).execute()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_applications() -> List[Application]:
|
|
26
|
+
apps = custom_requests.CustomRequest(
|
|
27
|
+
custom_requests.RequestCore(
|
|
28
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
29
|
+
api_endpoint="/api/applications",
|
|
30
|
+
),
|
|
31
|
+
custom_requests.RequestAuxiliaries(
|
|
32
|
+
what_should_happen="Get all applications",
|
|
33
|
+
),
|
|
34
|
+
).execute()
|
|
35
|
+
if not apps:
|
|
36
|
+
logger.info("No applications exist yet")
|
|
37
|
+
return apps
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def send_sla(sla_enum: enum) -> List[Application]:
|
|
41
|
+
sla_file_name = f"{sla_enum}.SLA.json"
|
|
42
|
+
SLA = ""
|
|
43
|
+
with open(get_SLAs_path() / sla_file_name, "r") as f:
|
|
44
|
+
SLA = json.load(f)
|
|
45
|
+
sla_apps = SLA["applications"]
|
|
46
|
+
sla_app_names = [app["application_name"] for app in sla_apps]
|
|
47
|
+
# Note: The API endpoint returns all user apps and not just the newly posted ones.
|
|
48
|
+
all_user_apps = custom_requests.CustomRequest(
|
|
49
|
+
custom_requests.RequestCore(
|
|
50
|
+
http_method=HttpMethod.POST,
|
|
51
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
52
|
+
api_endpoint="/api/application",
|
|
53
|
+
data=SLA,
|
|
54
|
+
),
|
|
55
|
+
custom_requests.RequestAuxiliaries(
|
|
56
|
+
what_should_happen=f"Create new application based on '{sla_enum}'",
|
|
57
|
+
show_msg_on_success=True,
|
|
58
|
+
),
|
|
59
|
+
).execute()
|
|
60
|
+
|
|
61
|
+
newly_added_apps = [app for app in all_user_apps if (app["application_name"] in sla_app_names)]
|
|
62
|
+
return newly_added_apps
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def delete_application(app_id: ApplicationId) -> None:
|
|
66
|
+
custom_requests.CustomRequest(
|
|
67
|
+
custom_requests.RequestCore(
|
|
68
|
+
http_method=HttpMethod.DELETE,
|
|
69
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
70
|
+
api_endpoint=f"/api/application/{app_id}",
|
|
71
|
+
),
|
|
72
|
+
custom_requests.RequestAuxiliaries(
|
|
73
|
+
what_should_happen=f"Delete application '{app_id}'",
|
|
74
|
+
show_msg_on_success=True,
|
|
75
|
+
),
|
|
76
|
+
).execute()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def delete_all_applications() -> None:
|
|
80
|
+
for app in get_applications():
|
|
81
|
+
delete_application(app["applicationID"])
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from icecream import ic
|
|
2
|
+
|
|
3
|
+
from oak_cli.commands.apps.main import get_applications
|
|
4
|
+
|
|
5
|
+
ic.configureOutput(prefix="")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def display_current_applications() -> None:
|
|
9
|
+
current_applications = get_applications()
|
|
10
|
+
for i, application in enumerate(current_applications):
|
|
11
|
+
ic(i, application)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import pathlib
|
|
4
|
+
|
|
5
|
+
import oak_cli.utils.api.custom_requests as custom_requests
|
|
6
|
+
from oak_cli.utils.api.custom_http import HttpMethod
|
|
7
|
+
|
|
8
|
+
ROOT_FL_MANAGER_URL = f"http://{os.environ.get('SYSTEM_MANAGER_URL')}:5072"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_new_fl_service() -> None:
|
|
12
|
+
sla_file_name = "flops.SLA.json"
|
|
13
|
+
current_file_path = pathlib.Path(__file__).resolve()
|
|
14
|
+
sla_file_path = current_file_path.parent / sla_file_name
|
|
15
|
+
with open(sla_file_path, "r") as f:
|
|
16
|
+
SLA = json.load(f)
|
|
17
|
+
|
|
18
|
+
custom_requests.CustomRequest(
|
|
19
|
+
custom_requests.RequestCore(
|
|
20
|
+
http_method=HttpMethod.POST,
|
|
21
|
+
base_url=ROOT_FL_MANAGER_URL,
|
|
22
|
+
api_endpoint="/api/flops",
|
|
23
|
+
data=SLA,
|
|
24
|
+
),
|
|
25
|
+
custom_requests.RequestAuxiliaries(
|
|
26
|
+
what_should_happen="Init new FLOps processes",
|
|
27
|
+
show_msg_on_success=True,
|
|
28
|
+
),
|
|
29
|
+
).execute()
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import oak_cli.utils.api.custom_requests as custom_requests
|
|
2
|
+
from oak_cli.commands.services.get import get_single_service
|
|
3
|
+
from oak_cli.utils.api.common import SYSTEM_MANAGER_URL
|
|
4
|
+
from oak_cli.utils.api.custom_http import HttpMethod
|
|
5
|
+
from oak_cli.utils.types import Id, ServiceId
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def deploy_new_instance(service_id: ServiceId) -> None:
|
|
9
|
+
custom_requests.CustomRequest(
|
|
10
|
+
custom_requests.RequestCore(
|
|
11
|
+
http_method=HttpMethod.POST,
|
|
12
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
13
|
+
api_endpoint=f"/api/service/{service_id}/instance",
|
|
14
|
+
),
|
|
15
|
+
custom_requests.RequestAuxiliaries(
|
|
16
|
+
what_should_happen=f"Deploy a new instance for the service '{service_id}'",
|
|
17
|
+
show_msg_on_success=True,
|
|
18
|
+
),
|
|
19
|
+
).execute()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def undeploy_instance(service_id: ServiceId, instance_id: Id = None) -> None:
|
|
23
|
+
custom_requests.CustomRequest(
|
|
24
|
+
custom_requests.RequestCore(
|
|
25
|
+
http_method=HttpMethod.DELETE,
|
|
26
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
27
|
+
api_endpoint=f"/api/service/{service_id}/instance/{instance_id or 0}",
|
|
28
|
+
),
|
|
29
|
+
custom_requests.RequestAuxiliaries(
|
|
30
|
+
what_should_happen=f"Undeploy instance '{instance_id or 0}' for service '{service_id}'",
|
|
31
|
+
show_msg_on_success=True,
|
|
32
|
+
),
|
|
33
|
+
).execute()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def undeploy_all_instances_of_service(service_id: ServiceId) -> None:
|
|
37
|
+
service = get_single_service(service_id)
|
|
38
|
+
for instance in service["instance_list"]:
|
|
39
|
+
undeploy_instance(service_id, instance["instance_number"])
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
import oak_cli.utils.api.custom_requests as custom_requests
|
|
4
|
+
from oak_cli.utils.api.common import SYSTEM_MANAGER_URL
|
|
5
|
+
from oak_cli.utils.logging import logger
|
|
6
|
+
from oak_cli.utils.types import Service, ServiceId
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_single_service(service_id: ServiceId) -> Service:
|
|
10
|
+
return custom_requests.CustomRequest(
|
|
11
|
+
custom_requests.RequestCore(
|
|
12
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
13
|
+
api_endpoint=f"/api/service/{service_id}",
|
|
14
|
+
),
|
|
15
|
+
custom_requests.RequestAuxiliaries(
|
|
16
|
+
what_should_happen=f"Get single service '{service_id}'",
|
|
17
|
+
),
|
|
18
|
+
).execute()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_all_services(app_id: ServiceId = None) -> List[Service]:
|
|
22
|
+
what_should_happen = "Get all services"
|
|
23
|
+
if app_id:
|
|
24
|
+
what_should_happen += f" of app '{app_id}'"
|
|
25
|
+
|
|
26
|
+
services = custom_requests.CustomRequest(
|
|
27
|
+
custom_requests.RequestCore(
|
|
28
|
+
base_url=SYSTEM_MANAGER_URL,
|
|
29
|
+
api_endpoint=f"/api/services/{app_id or ''}",
|
|
30
|
+
),
|
|
31
|
+
custom_requests.RequestAuxiliaries(
|
|
32
|
+
what_should_happen=what_should_happen,
|
|
33
|
+
),
|
|
34
|
+
).execute()
|
|
35
|
+
|
|
36
|
+
if not services:
|
|
37
|
+
logger.info("No applications exist yet")
|
|
38
|
+
return services
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from icecream import ic
|
|
2
|
+
|
|
3
|
+
from oak_cli.commands.services.get import get_all_services
|
|
4
|
+
from oak_cli.utils.types import ApplicationId, Service
|
|
5
|
+
|
|
6
|
+
ic.configureOutput(prefix="")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def display_single_service(service: Service, verbose: bool = False) -> None:
|
|
10
|
+
if verbose:
|
|
11
|
+
for instance in service["instance_list"]:
|
|
12
|
+
instance["cpu_history"] = "..."
|
|
13
|
+
instance["memory_history"] = "..."
|
|
14
|
+
instance["logs"] = "..."
|
|
15
|
+
else:
|
|
16
|
+
mask = [
|
|
17
|
+
"addresses",
|
|
18
|
+
"app_name",
|
|
19
|
+
"app_ns",
|
|
20
|
+
"applicationID",
|
|
21
|
+
"service_name",
|
|
22
|
+
"service_ns",
|
|
23
|
+
"service_ns",
|
|
24
|
+
"one_shot",
|
|
25
|
+
"microserviceID",
|
|
26
|
+
"cmd",
|
|
27
|
+
"code",
|
|
28
|
+
"image",
|
|
29
|
+
]
|
|
30
|
+
service = {key: service[key] for key in mask if key in service}
|
|
31
|
+
ic(service)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def display_all_current_services(
|
|
35
|
+
verbose: bool = False,
|
|
36
|
+
app_id: ApplicationId = None,
|
|
37
|
+
) -> None:
|
|
38
|
+
all_current_services = get_all_services(app_id)
|
|
39
|
+
for i, service in enumerate(all_current_services):
|
|
40
|
+
ic(i)
|
|
41
|
+
display_single_service(service, verbose)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
3
|
+
|
|
4
|
+
from oak_cli.args_parser.main import parse_arguments_and_execute
|
|
5
|
+
from oak_cli.utils.argcomplete import handle_argcomplete
|
|
6
|
+
from oak_cli.utils.exceptions import OakCliException
|
|
7
|
+
from oak_cli.utils.logging import logger
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
handle_argcomplete()
|
|
12
|
+
# Potential Future Work:
|
|
13
|
+
# This implementation uses argparse & argcomplete for user friendly CLI behavior.
|
|
14
|
+
# However especially argparse comes with a lot of additional boilerplate code.
|
|
15
|
+
# It might be useful to look into more modern solutions for python CLI's like
|
|
16
|
+
# https://github.com/pallets/click
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
parse_arguments_and_execute()
|
|
20
|
+
except OakCliException as e:
|
|
21
|
+
logger.fatal(f"{e.msg}, {e.http_status}")
|
|
22
|
+
except Exception as e:
|
|
23
|
+
err_msg = f"Unexpected error occured: {e}"
|
|
24
|
+
logger.fatal(err_msg)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|