azimuth-robotframework 0.1.0__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.
- Azimuth/__init__.py +1 -0
- Azimuth/cluster_types.py +36 -0
- Azimuth/clusters.py +104 -0
- Azimuth/kubernetes_app_templates.py +54 -0
- Azimuth/kubernetes_apps.py +111 -0
- Azimuth/kubernetes_cluster_templates.py +87 -0
- Azimuth/kubernetes_clusters.py +386 -0
- Azimuth/main.py +140 -0
- Azimuth/sizes.py +39 -0
- Azimuth/util.py +70 -0
- Azimuth/zenith.py +122 -0
- azimuth_robotframework-0.1.0.dist-info/LICENSE +201 -0
- azimuth_robotframework-0.1.0.dist-info/METADATA +18 -0
- azimuth_robotframework-0.1.0.dist-info/RECORD +16 -0
- azimuth_robotframework-0.1.0.dist-info/WHEEL +5 -0
- azimuth_robotframework-0.1.0.dist-info/top_level.txt +1 -0
Azimuth/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .main import Azimuth
|
Azimuth/cluster_types.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from robot.api.deco import keyword
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ClusterTypeKeywords:
|
|
7
|
+
"""
|
|
8
|
+
Keywords for interacting with cluster types.
|
|
9
|
+
"""
|
|
10
|
+
def __init__(self, ctx):
|
|
11
|
+
self._ctx = ctx
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def _resource(self):
|
|
15
|
+
return self._ctx.client.cluster_types()
|
|
16
|
+
|
|
17
|
+
@keyword
|
|
18
|
+
def list_cluster_types(self) -> t.List[t.Dict[str, t.Any]]:
|
|
19
|
+
"""
|
|
20
|
+
Lists cluster types using the active client.
|
|
21
|
+
"""
|
|
22
|
+
return list(self._resource.list())
|
|
23
|
+
|
|
24
|
+
@keyword
|
|
25
|
+
def fetch_cluster_type(self, name: str) -> t.Dict[str, t.Any]:
|
|
26
|
+
"""
|
|
27
|
+
Fetches a cluster type by name using the active client.
|
|
28
|
+
"""
|
|
29
|
+
return self._resource.fetch(name)
|
|
30
|
+
|
|
31
|
+
@keyword
|
|
32
|
+
def find_cluster_type_by_name(self, name: str) -> t.Dict[str, t.Any]:
|
|
33
|
+
"""
|
|
34
|
+
Fetches a cluster type by name using the active client.
|
|
35
|
+
"""
|
|
36
|
+
return self.fetch_cluster_type(name)
|
Azimuth/clusters.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from robot.api.deco import keyword
|
|
4
|
+
|
|
5
|
+
from . import util
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ClusterKeywords:
|
|
9
|
+
"""
|
|
10
|
+
Keywords for interacting with clusters.
|
|
11
|
+
"""
|
|
12
|
+
def __init__(self, ctx):
|
|
13
|
+
self._ctx = ctx
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def _resource(self):
|
|
17
|
+
return self._ctx.client.clusters()
|
|
18
|
+
|
|
19
|
+
@keyword
|
|
20
|
+
def list_clusters(self) -> t.List[t.Dict[str, t.Any]]:
|
|
21
|
+
"""
|
|
22
|
+
Lists clusters using the active client.
|
|
23
|
+
"""
|
|
24
|
+
return list(self._resource.list())
|
|
25
|
+
|
|
26
|
+
@keyword
|
|
27
|
+
def fetch_cluster_by_id(self, id: str) -> t.Dict[str, t.Any]:
|
|
28
|
+
"""
|
|
29
|
+
Fetches a cluster by id using the active client.
|
|
30
|
+
"""
|
|
31
|
+
return self._resource.fetch(id)
|
|
32
|
+
|
|
33
|
+
@keyword
|
|
34
|
+
def find_cluster_by_name(self, name: str) -> t.Dict[str, t.Any]:
|
|
35
|
+
"""
|
|
36
|
+
Finds a cluster by name using the active client.
|
|
37
|
+
"""
|
|
38
|
+
try:
|
|
39
|
+
return next(c for c in self._resource.list() if c.name == name)
|
|
40
|
+
except StopIteration:
|
|
41
|
+
raise ValueError(f"no cluster with name '{name}'")
|
|
42
|
+
|
|
43
|
+
@keyword
|
|
44
|
+
def create_cluster(
|
|
45
|
+
self,
|
|
46
|
+
name: str,
|
|
47
|
+
cluster_type: str,
|
|
48
|
+
**parameter_values: t.Any
|
|
49
|
+
) -> t.Dict[str, t.Any]:
|
|
50
|
+
"""
|
|
51
|
+
Creates a cluster using the active client.
|
|
52
|
+
"""
|
|
53
|
+
return self._resource.create({
|
|
54
|
+
"name": name,
|
|
55
|
+
"cluster_type" : cluster_type,
|
|
56
|
+
"parameter_values": parameter_values,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
@keyword
|
|
60
|
+
def delete_cluster(self, id: str, interval: int = 15):
|
|
61
|
+
"""
|
|
62
|
+
Deletes the specified cluster and waits for it to be deleted.
|
|
63
|
+
"""
|
|
64
|
+
util.delete_resource(self._resource, id, interval)
|
|
65
|
+
|
|
66
|
+
@keyword
|
|
67
|
+
def wait_for_cluster_status(
|
|
68
|
+
self,
|
|
69
|
+
id: str,
|
|
70
|
+
target_status: str,
|
|
71
|
+
interval: int = 15
|
|
72
|
+
) -> t.Dict[str, t.Any]:
|
|
73
|
+
"""
|
|
74
|
+
Waits for the specified cluster to reach the target status before returning it.
|
|
75
|
+
"""
|
|
76
|
+
return util.wait_for_resource_property(
|
|
77
|
+
self._resource,
|
|
78
|
+
id,
|
|
79
|
+
"status",
|
|
80
|
+
target_status,
|
|
81
|
+
{"CONFIGURING", "DELETING"},
|
|
82
|
+
interval
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
@keyword
|
|
86
|
+
def wait_for_cluster_ready(self, id: str, interval: int = 15) -> t.Dict[str, t.Any]:
|
|
87
|
+
"""
|
|
88
|
+
Waits for the cluster status to be ready before returning it.
|
|
89
|
+
"""
|
|
90
|
+
return self.wait_for_cluster_status(id, "READY", interval)
|
|
91
|
+
|
|
92
|
+
@keyword
|
|
93
|
+
def get_cluster_service_url(self, cluster: t.Dict[str, t.Any], name: str) -> str:
|
|
94
|
+
"""
|
|
95
|
+
Returns the Zenith FQDN for the specified cluster service.
|
|
96
|
+
"""
|
|
97
|
+
try:
|
|
98
|
+
return next(
|
|
99
|
+
service["fqdn"]
|
|
100
|
+
for service in cluster["services"]
|
|
101
|
+
if service["name"] == name
|
|
102
|
+
)
|
|
103
|
+
except StopIteration:
|
|
104
|
+
raise ValueError(f"no such service - {name}")
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from robot.api.deco import keyword
|
|
4
|
+
|
|
5
|
+
import jsonschema_default
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class KubernetesAppTemplateKeywords:
|
|
9
|
+
"""
|
|
10
|
+
Keywords for interacting with Kubernetes app templates.
|
|
11
|
+
"""
|
|
12
|
+
def __init__(self, ctx):
|
|
13
|
+
self._ctx = ctx
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def _resource(self):
|
|
17
|
+
return self._ctx.client.kubernetes_app_templates()
|
|
18
|
+
|
|
19
|
+
@keyword
|
|
20
|
+
def list_kubernetes_app_templates(self) -> t.List[t.Dict[str, t.Any]]:
|
|
21
|
+
"""
|
|
22
|
+
Lists available Kubernetes app templates using the active client.
|
|
23
|
+
"""
|
|
24
|
+
return list(self._resource.list())
|
|
25
|
+
|
|
26
|
+
@keyword
|
|
27
|
+
def fetch_kubernetes_app_template(self, id: str) -> t.Dict[str, t.Any]:
|
|
28
|
+
"""
|
|
29
|
+
Fetches a Kubernetes app template by id using the active client.
|
|
30
|
+
"""
|
|
31
|
+
return self._resource.fetch(id)
|
|
32
|
+
|
|
33
|
+
@keyword
|
|
34
|
+
def get_latest_version_for_kubernetes_app_template(
|
|
35
|
+
self,
|
|
36
|
+
template: t.Dict[str, t.Any]
|
|
37
|
+
) -> t.Dict[str, t.Any]:
|
|
38
|
+
"""
|
|
39
|
+
Returns the latest version for the Kubernetes app template.
|
|
40
|
+
"""
|
|
41
|
+
try:
|
|
42
|
+
return next(iter(template.versions))
|
|
43
|
+
except StopIteration:
|
|
44
|
+
raise AssertionError(f"no versions for Kubernetes app template '{template.id}'")
|
|
45
|
+
|
|
46
|
+
@keyword
|
|
47
|
+
def get_defaults_for_kubernetes_app_template_version(
|
|
48
|
+
self,
|
|
49
|
+
version: t.Dict[str, t.Any]
|
|
50
|
+
) -> t.Dict[str, t.Any]:
|
|
51
|
+
"""
|
|
52
|
+
Gets the default values for the given Kubernetes app template.
|
|
53
|
+
"""
|
|
54
|
+
return jsonschema_default.create_from(version["values_schema"])
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from robot.api.deco import keyword
|
|
4
|
+
|
|
5
|
+
from . import util
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class KubernetesAppKeywords:
|
|
9
|
+
"""
|
|
10
|
+
Keywords for interacting with Kubernetes apps.
|
|
11
|
+
"""
|
|
12
|
+
def __init__(self, ctx):
|
|
13
|
+
self._ctx = ctx
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def _resource(self):
|
|
17
|
+
return self._ctx.client.kubernetes_apps()
|
|
18
|
+
|
|
19
|
+
@keyword
|
|
20
|
+
def list_kubernetes_apps(self) -> t.List[t.Dict[str, t.Any]]:
|
|
21
|
+
"""
|
|
22
|
+
Lists Kubernetes apps using the active client.
|
|
23
|
+
"""
|
|
24
|
+
return list(self._resource.list())
|
|
25
|
+
|
|
26
|
+
@keyword
|
|
27
|
+
def fetch_kubernetes_app_by_id(self, id: str) -> t.Dict[str, t.Any]:
|
|
28
|
+
"""
|
|
29
|
+
Fetches a Kubernetes app by id using the active client.
|
|
30
|
+
"""
|
|
31
|
+
return self._resource.fetch(id)
|
|
32
|
+
|
|
33
|
+
@keyword
|
|
34
|
+
def find_kubernetes_app_by_name(self, name: str) -> t.Dict[str, t.Any]:
|
|
35
|
+
"""
|
|
36
|
+
Finds a Kubernetes app by name using the active client.
|
|
37
|
+
"""
|
|
38
|
+
try:
|
|
39
|
+
return next(c for c in self._resource.list() if c.name == name)
|
|
40
|
+
except StopIteration:
|
|
41
|
+
raise ValueError(f"no Kubernetes app with name '{name}'")
|
|
42
|
+
|
|
43
|
+
@keyword
|
|
44
|
+
def create_kubernetes_app(
|
|
45
|
+
self,
|
|
46
|
+
name: str,
|
|
47
|
+
template: str,
|
|
48
|
+
kubernetes_cluster: str,
|
|
49
|
+
values: t.Dict[str, t.Any]
|
|
50
|
+
) -> t.Dict[str, t.Any]:
|
|
51
|
+
"""
|
|
52
|
+
Creates a Kubernetes app using the active client.
|
|
53
|
+
"""
|
|
54
|
+
return self._resource.create({
|
|
55
|
+
"name": name,
|
|
56
|
+
"template": template,
|
|
57
|
+
"kubernetes_cluster": kubernetes_cluster,
|
|
58
|
+
"values": values,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
@keyword
|
|
62
|
+
def delete_kubernetes_app(self, id: str, interval: int = 15):
|
|
63
|
+
"""
|
|
64
|
+
Deletes the specified Kubernetes app and waits for it to be deleted.
|
|
65
|
+
"""
|
|
66
|
+
util.delete_resource(self._resource, id, interval)
|
|
67
|
+
|
|
68
|
+
@keyword
|
|
69
|
+
def wait_for_kubernetes_app_status(
|
|
70
|
+
self,
|
|
71
|
+
id: str,
|
|
72
|
+
target_status: str,
|
|
73
|
+
interval: int = 15
|
|
74
|
+
) -> t.Dict[str, t.Any]:
|
|
75
|
+
"""
|
|
76
|
+
Waits for the specified app to reach the target status before returning it.
|
|
77
|
+
"""
|
|
78
|
+
return util.wait_for_resource_property(
|
|
79
|
+
self._resource,
|
|
80
|
+
id,
|
|
81
|
+
"status",
|
|
82
|
+
target_status,
|
|
83
|
+
{"Pending", "Preparing", "Installing", "Upgrading", "Uninstalling", "Unknown"},
|
|
84
|
+
interval
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
@keyword
|
|
88
|
+
def wait_for_kubernetes_app_deployed(self, id: str, interval: int = 15) -> t.Dict[str, t.Any]:
|
|
89
|
+
"""
|
|
90
|
+
Waits for the app status to be deployed before returning it.
|
|
91
|
+
"""
|
|
92
|
+
return self.wait_for_kubernetes_app_status(id, "Deployed", interval)
|
|
93
|
+
|
|
94
|
+
@keyword
|
|
95
|
+
def wait_for_kubernetes_app_service_url(self, id: str, name: str, interval: int = 15) -> str:
|
|
96
|
+
"""
|
|
97
|
+
Returns the Zenith FQDN for the specified app service.
|
|
98
|
+
|
|
99
|
+
Because Helm does not know what constitutes a healthy Zenith reservation/client,
|
|
100
|
+
this may involve a wait.
|
|
101
|
+
"""
|
|
102
|
+
# We also consider the given name with the app id prefixed, as that is how the names are
|
|
103
|
+
# constructed in the Helm releases of the reference charts
|
|
104
|
+
names = {name, f"{id}-{name}"}
|
|
105
|
+
app = util.wait_for_resource(
|
|
106
|
+
self._resource,
|
|
107
|
+
id,
|
|
108
|
+
lambda app: any(s["name"] in names for s in app["services"]),
|
|
109
|
+
interval
|
|
110
|
+
)
|
|
111
|
+
return next(s["fqdn"] for s in app["services"] if s["name"] in names)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from robot.api.deco import keyword
|
|
4
|
+
|
|
5
|
+
import easysemver
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class KubernetesClusterTemplateKeywords:
|
|
9
|
+
"""
|
|
10
|
+
Keywords for interacting with Kubernetes cluster templates.
|
|
11
|
+
"""
|
|
12
|
+
def __init__(self, ctx):
|
|
13
|
+
self._ctx = ctx
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def _resource(self):
|
|
17
|
+
return self._ctx.client.kubernetes_cluster_templates()
|
|
18
|
+
|
|
19
|
+
@keyword
|
|
20
|
+
def list_kubernetes_cluster_templates(
|
|
21
|
+
self,
|
|
22
|
+
*,
|
|
23
|
+
tags: t.Optional[t.List[str]],
|
|
24
|
+
include_deprecated: bool = True
|
|
25
|
+
) -> t.List[t.Dict[str, t.Any]]:
|
|
26
|
+
"""
|
|
27
|
+
Lists available Kubernetes cluster templates using the active client.
|
|
28
|
+
"""
|
|
29
|
+
return list(
|
|
30
|
+
template
|
|
31
|
+
for template in self._resource.list()
|
|
32
|
+
if (
|
|
33
|
+
set(tags).issubset(template.tags) and
|
|
34
|
+
(include_deprecated or not template.deprecated)
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@keyword
|
|
39
|
+
def fetch_kubernetes_cluster_template(self, id: str) -> t.Dict[str, t.Any]:
|
|
40
|
+
"""
|
|
41
|
+
Fetches a Kubernetes cluster template by id using the active client.
|
|
42
|
+
"""
|
|
43
|
+
return self._resource.fetch(id)
|
|
44
|
+
|
|
45
|
+
@keyword
|
|
46
|
+
def find_kubernetes_cluster_template_by_name(self, name: str) -> t.Dict[str, t.Any]:
|
|
47
|
+
"""
|
|
48
|
+
Finds a Kubernetes cluster template by name using the active client.
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
return next(ct for ct in self._resource.list() if ct.name == name)
|
|
52
|
+
except StopIteration:
|
|
53
|
+
raise ValueError(f"no template with name '{name}'")
|
|
54
|
+
|
|
55
|
+
@keyword
|
|
56
|
+
def find_latest_kubernetes_cluster_template(
|
|
57
|
+
self,
|
|
58
|
+
*,
|
|
59
|
+
constraints: str = ">=0.0.0",
|
|
60
|
+
tags: t.Optional[t.List[str]],
|
|
61
|
+
include_deprecated: bool = False
|
|
62
|
+
) -> t.Dict[str, t.Any]:
|
|
63
|
+
"""
|
|
64
|
+
Finds the Kubernetes template with the most recent version that matches the given tags.
|
|
65
|
+
"""
|
|
66
|
+
version_range = easysemver.Range(constraints)
|
|
67
|
+
latest_version = None
|
|
68
|
+
latest_template = None
|
|
69
|
+
for template in self._resource.list():
|
|
70
|
+
# If the template is deprecated, skip it unless explicitly included
|
|
71
|
+
if not include_deprecated and template.deprecated:
|
|
72
|
+
continue
|
|
73
|
+
# All the given tags must be in the template tags
|
|
74
|
+
if not set(tags).issubset(template.tags):
|
|
75
|
+
continue
|
|
76
|
+
current_version = easysemver.Version(template.kubernetes_version)
|
|
77
|
+
# The version must match the constraints
|
|
78
|
+
if current_version not in version_range:
|
|
79
|
+
continue
|
|
80
|
+
# The version must beat the one we already have
|
|
81
|
+
if latest_version and latest_version >= current_version:
|
|
82
|
+
continue
|
|
83
|
+
latest_version = current_version
|
|
84
|
+
latest_template = template
|
|
85
|
+
if not latest_template:
|
|
86
|
+
raise ValueError("No template matching conditions")
|
|
87
|
+
return latest_template
|