blob: db8d934f2665dad3e5208e34e71c27dacfee3539 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
"""MSB k8s plugin module."""
from onapsdk.configuration import settings
from onapsdk.k8s import Definition, Profile
from onaptests.steps.base import BaseStep
from onaptests.steps.cloud.cloud_region_create import CloudRegionCreateStep
from onaptests.steps.cloud.k8s_connectivity_info_create import K8SConnectivityInfoStep
class CreateDefinitionStep(BaseStep):
"""Create definition step initialization."""
def __init__(self) -> None:
"""Initialize step.
Substeps:
- CloudRegionCreateStep,
- K8SConnectivityInfoStep.
"""
super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
self.add_step(CloudRegionCreateStep())
self.add_step(K8SConnectivityInfoStep())
self.definition: Definition = None
@property
def description(self) -> str:
"""Step description."""
return "Create K8S definition."
@property
def component(self) -> str:
"""Component name."""
return "K8S plugin"
@BaseStep.store_state
def execute(self) -> None:
"""Create definition."""
super().execute()
with open(settings.MSB_K8S_DEFINITION_ATRIFACT_FILE_PATH, "rb") as definition_file:
self.definition = Definition.create(rb_name=settings.MSB_K8S_RB_NAME,
rb_version=settings.MSB_K8S_RB_VERSION)
self.definition.upload_artifact(definition_file.read())
class CreateProfileStep(BaseStep):
"""Create profile step."""
def __init__(self) -> None:
"""Initialize step.
Substeps:
- CreateDefinitionStep.
"""
super().__init__(cleanup=BaseStep.HAS_NO_CLEANUP)
self.add_step(CreateDefinitionStep())
self.profile: Profile = None
@property
def description(self) -> str:
"""Step description."""
return "Create K8S profile."
@property
def component(self) -> str:
"""Component name."""
return "K8S plugin"
@BaseStep.store_state
def execute(self) -> None:
"""Create profile."""
super().execute()
definition: Definition = Definition.get_definition_by_name_version(
rb_name=settings.MSB_K8S_RB_NAME,
rb_version=settings.MSB_K8S_RB_VERSION)
with open(settings.MSB_K8S_PROFILE_ARTIFACT_FILE_PATH, "rb") as profile_file:
self.profile = definition.create_profile(
profile_name=settings.MSB_K8S_PROFILE_NAME,
namespace=settings.K8S_ADDITIONAL_RESOURCES_NAMESPACE,
kubernetes_version=settings.K8S_VERSION)
self.profile.upload_artifact(profile_file.read())
|