openshift-python-wrapper 4.11.61__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.
- ocp_resources/__init__.py +0 -0
- ocp_resources/api_service.py +9 -0
- ocp_resources/backup.py +52 -0
- ocp_resources/benchmark.py +92 -0
- ocp_resources/catalog_source.py +63 -0
- ocp_resources/catalog_source_config.py +86 -0
- ocp_resources/cdi.py +13 -0
- ocp_resources/cdi_config.py +52 -0
- ocp_resources/chaos_engine.py +30 -0
- ocp_resources/chaos_result.py +11 -0
- ocp_resources/cluster_operator.py +5 -0
- ocp_resources/cluster_role.py +70 -0
- ocp_resources/cluster_role_binding.py +36 -0
- ocp_resources/cluster_service_version.py +8 -0
- ocp_resources/cluster_version.py +5 -0
- ocp_resources/configmap.py +37 -0
- ocp_resources/console_cli_download.py +9 -0
- ocp_resources/console_plugin.py +9 -0
- ocp_resources/console_quick_start.py +9 -0
- ocp_resources/constants.py +26 -0
- ocp_resources/csidriver.py +9 -0
- ocp_resources/custom_resource_definition.py +5 -0
- ocp_resources/daemonset.py +61 -0
- ocp_resources/data_import_cron.py +100 -0
- ocp_resources/data_source.py +59 -0
- ocp_resources/datavolume.py +275 -0
- ocp_resources/deployment.py +65 -0
- ocp_resources/destination_rule.py +11 -0
- ocp_resources/event.py +114 -0
- ocp_resources/forklift_controller.py +10 -0
- ocp_resources/gateway.py +11 -0
- ocp_resources/hook.py +52 -0
- ocp_resources/host.py +64 -0
- ocp_resources/hostpath_provisioner.py +50 -0
- ocp_resources/hyperconverged.py +43 -0
- ocp_resources/image.py +9 -0
- ocp_resources/image_content_source_policy.py +9 -0
- ocp_resources/image_stream.py +48 -0
- ocp_resources/imagestreamtag.py +9 -0
- ocp_resources/infrastructure.py +18 -0
- ocp_resources/installplan.py +8 -0
- ocp_resources/job.py +65 -0
- ocp_resources/kube_descheduler.py +65 -0
- ocp_resources/kubevirt.py +5 -0
- ocp_resources/kubevirt_common_templates_bundle.py +5 -0
- ocp_resources/kubevirt_metrics_aggregation.py +5 -0
- ocp_resources/kubevirt_node_labeller_bundle.py +5 -0
- ocp_resources/kubevirt_template_validaotr.py +5 -0
- ocp_resources/logger.py +76 -0
- ocp_resources/machine.py +50 -0
- ocp_resources/machine_config.py +5 -0
- ocp_resources/machine_config_pool.py +9 -0
- ocp_resources/machine_health_check.py +76 -0
- ocp_resources/machine_set.py +189 -0
- ocp_resources/migration.py +63 -0
- ocp_resources/migration_policy.py +66 -0
- ocp_resources/mtv.py +171 -0
- ocp_resources/mutating_webhook_config.py +9 -0
- ocp_resources/namespace.py +40 -0
- ocp_resources/network.py +5 -0
- ocp_resources/network_addons_config.py +9 -0
- ocp_resources/network_attachment_definition.py +24 -0
- ocp_resources/network_map.py +64 -0
- ocp_resources/network_policy.py +9 -0
- ocp_resources/nmstate.py +9 -0
- ocp_resources/node.py +41 -0
- ocp_resources/node_health_check.py +10 -0
- ocp_resources/node_maintenance.py +40 -0
- ocp_resources/node_network_configuration_enactment.py +20 -0
- ocp_resources/node_network_configuration_policy.py +472 -0
- ocp_resources/node_network_state.py +121 -0
- ocp_resources/oauth.py +9 -0
- ocp_resources/operator_condition.py +5 -0
- ocp_resources/operator_group.py +37 -0
- ocp_resources/operator_hub.py +5 -0
- ocp_resources/operator_source.py +50 -0
- ocp_resources/package_manifest.py +5 -0
- ocp_resources/peer_authentication.py +18 -0
- ocp_resources/persistent_volume.py +27 -0
- ocp_resources/persistent_volume_claim.py +103 -0
- ocp_resources/plan.py +143 -0
- ocp_resources/pod.py +175 -0
- ocp_resources/pod_disruption_budget.py +53 -0
- ocp_resources/priority_class.py +48 -0
- ocp_resources/project.py +60 -0
- ocp_resources/prometheus.py +9 -0
- ocp_resources/prometheus_rule.py +9 -0
- ocp_resources/provider.py +59 -0
- ocp_resources/replicaset.py +11 -0
- ocp_resources/resource.py +1383 -0
- ocp_resources/restore.py +52 -0
- ocp_resources/role.py +11 -0
- ocp_resources/role_binding.py +67 -0
- ocp_resources/route.py +76 -0
- ocp_resources/secret.py +75 -0
- ocp_resources/security_context_constraints.py +9 -0
- ocp_resources/service.py +16 -0
- ocp_resources/service_account.py +9 -0
- ocp_resources/service_mesh_control_plane.py +11 -0
- ocp_resources/service_mesh_member_roll.py +14 -0
- ocp_resources/service_monitor.py +9 -0
- ocp_resources/sriov_network.py +54 -0
- ocp_resources/sriov_network_node_policy.py +67 -0
- ocp_resources/sriov_network_node_state.py +44 -0
- ocp_resources/ssp.py +9 -0
- ocp_resources/storage_class.py +47 -0
- ocp_resources/storage_map.py +67 -0
- ocp_resources/storage_profile.py +7 -0
- ocp_resources/subscription.py +66 -0
- ocp_resources/tekton_tasks.py +9 -0
- ocp_resources/template.py +74 -0
- ocp_resources/upload_token_request.py +39 -0
- ocp_resources/utils.py +278 -0
- ocp_resources/validating_webhook_config.py +9 -0
- ocp_resources/virtual_machine.py +177 -0
- ocp_resources/virtual_machine_Instance_replica_set.py +9 -0
- ocp_resources/virtual_machine_cluster_flavor.py +5 -0
- ocp_resources/virtual_machine_flavor.py +5 -0
- ocp_resources/virtual_machine_import.py +307 -0
- ocp_resources/virtual_machine_instance.py +322 -0
- ocp_resources/virtual_machine_instance_migration.py +36 -0
- ocp_resources/virtual_machine_instance_preset.py +9 -0
- ocp_resources/virtual_machine_restore.py +99 -0
- ocp_resources/virtual_machine_snapshot.py +96 -0
- ocp_resources/virtual_service.py +11 -0
- ocp_resources/vm_import_config.py +9 -0
- ocp_resources/volume_snapshot.py +9 -0
- ocp_resources/volume_snapshot_class.py +9 -0
- openshift_python_wrapper-4.11.61.dist-info/LICENSE +201 -0
- openshift_python_wrapper-4.11.61.dist-info/METADATA +188 -0
- openshift_python_wrapper-4.11.61.dist-info/RECORD +132 -0
- openshift_python_wrapper-4.11.61.dist-info/WHEEL +4 -0
|
File without changes
|
ocp_resources/backup.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ocp_resources.resource import NamespacedResource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Backup(NamespacedResource):
|
|
7
|
+
"""
|
|
8
|
+
Backup object.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
api_group = NamespacedResource.ApiGroup.VELERO_IO
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
name=None,
|
|
16
|
+
namespace=None,
|
|
17
|
+
included_namespaces=None,
|
|
18
|
+
client=None,
|
|
19
|
+
teardown=False,
|
|
20
|
+
privileged_client=None,
|
|
21
|
+
yaml_file=None,
|
|
22
|
+
excluded_resources=None,
|
|
23
|
+
**kwargs,
|
|
24
|
+
):
|
|
25
|
+
if not included_namespaces:
|
|
26
|
+
raise ValueError("included_namespaces can't be None")
|
|
27
|
+
|
|
28
|
+
super().__init__(
|
|
29
|
+
name=name,
|
|
30
|
+
namespace=namespace,
|
|
31
|
+
client=client,
|
|
32
|
+
teardown=teardown,
|
|
33
|
+
privileged_client=privileged_client,
|
|
34
|
+
yaml_file=yaml_file,
|
|
35
|
+
**kwargs,
|
|
36
|
+
)
|
|
37
|
+
self.included_namespaces = included_namespaces
|
|
38
|
+
self.excluded_resources = excluded_resources
|
|
39
|
+
|
|
40
|
+
def to_dict(self):
|
|
41
|
+
super().to_dict()
|
|
42
|
+
if not self.yaml_file:
|
|
43
|
+
self.res.update(
|
|
44
|
+
{
|
|
45
|
+
"spec": {
|
|
46
|
+
"includedNamespaces": self.included_namespaces,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if self.excluded_resources:
|
|
52
|
+
self.res["spec"]["excludedResources"] = self.excluded_resources
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from ocp_resources.constants import NOT_FOUND_ERROR_EXCEPTION_DICT
|
|
2
|
+
from ocp_resources.resource import NamespacedResource
|
|
3
|
+
from ocp_resources.utils import TimeoutSampler
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Benchmark(NamespacedResource):
|
|
7
|
+
"""
|
|
8
|
+
Benchmark resource
|
|
9
|
+
Defined by https://github.com/cloud-bulldozer/benchmark-operator
|
|
10
|
+
|
|
11
|
+
The benchmark-operator monitors a namespace for `Benchmark` resources.
|
|
12
|
+
When a new `Benchmark` is created, the benchmark-operator creates and starts the pods or VMs necessary,
|
|
13
|
+
and triggers the benchmark run.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
api_group = NamespacedResource.ApiGroup.RIPSAW_CLOUDBULLDOZER_IO
|
|
17
|
+
|
|
18
|
+
class Status:
|
|
19
|
+
NONE = None # None state is valid for newly created benchmark resources
|
|
20
|
+
|
|
21
|
+
class Workload:
|
|
22
|
+
class Kind:
|
|
23
|
+
VM = "vm"
|
|
24
|
+
POD = "pod"
|
|
25
|
+
|
|
26
|
+
def _wait_for_instance_key(self, parent, key):
|
|
27
|
+
"""
|
|
28
|
+
Wait for key to exist in parent attribute of instance
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
parent (str): An attribute of self.instance that should contain key
|
|
32
|
+
key (str): A dictionary entry within parent
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
str or None: Value of key if found, otherwise None
|
|
36
|
+
"""
|
|
37
|
+
samples = TimeoutSampler(
|
|
38
|
+
wait_timeout=30,
|
|
39
|
+
sleep=1,
|
|
40
|
+
func=lambda: getattr(self.instance, parent, None),
|
|
41
|
+
exceptions_dict=NOT_FOUND_ERROR_EXCEPTION_DICT,
|
|
42
|
+
)
|
|
43
|
+
for sample in samples:
|
|
44
|
+
if sample:
|
|
45
|
+
return sample.get(key)
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def uuid(self):
|
|
49
|
+
"""
|
|
50
|
+
Returns:
|
|
51
|
+
str: UUID string from resource instance
|
|
52
|
+
"""
|
|
53
|
+
return self._wait_for_instance_key(parent="status", key="uuid")
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def suuid(self):
|
|
57
|
+
"""
|
|
58
|
+
Returns:
|
|
59
|
+
str: (short)UUID string from resource instance
|
|
60
|
+
"""
|
|
61
|
+
return self._wait_for_instance_key(parent="status", key="suuid")
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def workload_kind(self):
|
|
65
|
+
"""
|
|
66
|
+
Retrieve the value of spec.workload.args.kind
|
|
67
|
+
|
|
68
|
+
Not all Benchmarks have a 'kind' defined, this was added for vms. The default is 'pod'
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
str: Value representing workload kind
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
return self.workload_arg(arg="kind", default="pod")
|
|
75
|
+
|
|
76
|
+
def workload_arg(self, arg, default=None):
|
|
77
|
+
"""
|
|
78
|
+
Retrieve the value of spec.workload.args[arg]
|
|
79
|
+
|
|
80
|
+
To provide a similar usage as .get(), a default can be defined if needed.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
arg (str): Argument to retrieve from spec.workload.args
|
|
84
|
+
default (any): Default value to return if arg is not found in workload args
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
any: Value of workload arg or 'default' if does not exist
|
|
88
|
+
"""
|
|
89
|
+
workload = self._wait_for_instance_key(parent="spec", key="workload")
|
|
90
|
+
if workload:
|
|
91
|
+
return workload.get("args", {}).get(arg, default)
|
|
92
|
+
return default
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from ocp_resources.constants import TIMEOUT_4MINUTES
|
|
2
|
+
from ocp_resources.resource import NamespacedResource
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CatalogSource(NamespacedResource):
|
|
6
|
+
api_group = NamespacedResource.ApiGroup.OPERATORS_COREOS_COM
|
|
7
|
+
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
name=None,
|
|
11
|
+
namespace=None,
|
|
12
|
+
client=None,
|
|
13
|
+
source_type=None,
|
|
14
|
+
image=None,
|
|
15
|
+
display_name=None,
|
|
16
|
+
publisher=None,
|
|
17
|
+
teardown=True,
|
|
18
|
+
yaml_file=None,
|
|
19
|
+
delete_timeout=TIMEOUT_4MINUTES,
|
|
20
|
+
update_strategy_registry_poll_interval=None,
|
|
21
|
+
**kwargs,
|
|
22
|
+
):
|
|
23
|
+
super().__init__(
|
|
24
|
+
name=name,
|
|
25
|
+
namespace=namespace,
|
|
26
|
+
client=client,
|
|
27
|
+
teardown=teardown,
|
|
28
|
+
yaml_file=yaml_file,
|
|
29
|
+
delete_timeout=delete_timeout,
|
|
30
|
+
**kwargs,
|
|
31
|
+
)
|
|
32
|
+
self.source_type = source_type
|
|
33
|
+
self.image = image
|
|
34
|
+
self.display_name = display_name
|
|
35
|
+
self.publisher = publisher
|
|
36
|
+
self.update_strategy_registry_poll_interval = (
|
|
37
|
+
update_strategy_registry_poll_interval
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def to_dict(self):
|
|
41
|
+
super().to_dict()
|
|
42
|
+
if not self.yaml_file:
|
|
43
|
+
self.res.update(
|
|
44
|
+
{
|
|
45
|
+
"spec": {
|
|
46
|
+
"sourceType": self.source_type,
|
|
47
|
+
"image": self.image,
|
|
48
|
+
"displayName": self.display_name,
|
|
49
|
+
"publisher": self.publisher,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if self.update_strategy_registry_poll_interval:
|
|
55
|
+
self.res["spec"].update(
|
|
56
|
+
{
|
|
57
|
+
"updateStrategy": {
|
|
58
|
+
"registryPoll": {
|
|
59
|
+
"interval": self.update_strategy_registry_poll_interval,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
|
|
2
|
+
from ocp_resources.resource import NamespacedResource
|
|
3
|
+
from ocp_resources.utils import TimeoutExpiredError, TimeoutSampler
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CatalogSourceConfig(NamespacedResource):
|
|
7
|
+
api_group = NamespacedResource.ApiGroup.OPERATORS_COREOS_COM
|
|
8
|
+
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
name=None,
|
|
12
|
+
namespace=None,
|
|
13
|
+
source=None,
|
|
14
|
+
target_namespace=None,
|
|
15
|
+
packages=None,
|
|
16
|
+
cs_display_name=None,
|
|
17
|
+
cs_publisher=None,
|
|
18
|
+
client=None,
|
|
19
|
+
teardown=True,
|
|
20
|
+
yaml_file=None,
|
|
21
|
+
delete_timeout=TIMEOUT_4MINUTES,
|
|
22
|
+
**kwargs,
|
|
23
|
+
):
|
|
24
|
+
super().__init__(
|
|
25
|
+
name=name,
|
|
26
|
+
namespace=namespace,
|
|
27
|
+
client=client,
|
|
28
|
+
teardown=teardown,
|
|
29
|
+
yaml_file=yaml_file,
|
|
30
|
+
delete_timeout=delete_timeout,
|
|
31
|
+
**kwargs,
|
|
32
|
+
)
|
|
33
|
+
self.source = source
|
|
34
|
+
self.target_namespace = target_namespace
|
|
35
|
+
self.packages = packages
|
|
36
|
+
self.cs_display_name = cs_display_name
|
|
37
|
+
self.cs_publisher = cs_publisher
|
|
38
|
+
|
|
39
|
+
def to_dict(self):
|
|
40
|
+
super().to_dict()
|
|
41
|
+
if not self.yaml_file:
|
|
42
|
+
self.res.update(
|
|
43
|
+
{
|
|
44
|
+
"spec": {
|
|
45
|
+
"source": self.source,
|
|
46
|
+
"targetNamespace": self.target_namespace,
|
|
47
|
+
"packages": self.packages,
|
|
48
|
+
"csDisplayName": self.cs_display_name,
|
|
49
|
+
"csPublisher": self.cs_publisher,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def wait_for_csc_status(self, status, timeout=120):
|
|
55
|
+
"""
|
|
56
|
+
Wait for CatalogSourceConfig to reach requested status.
|
|
57
|
+
CatalogSourceConfig Status is found under currentPhase.phase.
|
|
58
|
+
Example phase: {'message': 'The object has been successfully reconciled', 'name': 'Succeeded'}
|
|
59
|
+
|
|
60
|
+
Raises:
|
|
61
|
+
TimeoutExpiredError: If CatalogSourceConfig in not in desire status.
|
|
62
|
+
"""
|
|
63
|
+
samples = TimeoutSampler(
|
|
64
|
+
wait_timeout=timeout,
|
|
65
|
+
sleep=1,
|
|
66
|
+
exceptions_dict=PROTOCOL_ERROR_EXCEPTION_DICT,
|
|
67
|
+
func=self.api.get,
|
|
68
|
+
field_selector=f"metadata.name=={self.name}",
|
|
69
|
+
namespace=self.namespace,
|
|
70
|
+
)
|
|
71
|
+
current_status = None
|
|
72
|
+
try:
|
|
73
|
+
for sample in samples:
|
|
74
|
+
if sample.items:
|
|
75
|
+
sample_status = sample.items[0].status
|
|
76
|
+
if sample_status:
|
|
77
|
+
current_status = sample_status.currentPhase.phase["name"]
|
|
78
|
+
if current_status == status:
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
except TimeoutExpiredError:
|
|
82
|
+
if current_status:
|
|
83
|
+
self.logger.error(
|
|
84
|
+
f"Status of {self.kind} {self.name} is {current_status}"
|
|
85
|
+
)
|
|
86
|
+
raise
|
ocp_resources/cdi.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
|
|
4
|
+
from ocp_resources.resource import Resource
|
|
5
|
+
from ocp_resources.utils import TimeoutSampler
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CDIConfig(Resource):
|
|
9
|
+
"""
|
|
10
|
+
CDIConfig object.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
api_group = Resource.ApiGroup.CDI_KUBEVIRT_IO
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def scratch_space_storage_class_from_spec(self):
|
|
17
|
+
return self.instance.spec.scratchSpaceStorageClass
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def scratch_space_storage_class_from_status(self):
|
|
21
|
+
return self.instance.status.scratchSpaceStorageClass
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def upload_proxy_url(self):
|
|
25
|
+
return self.instance.status.uploadProxyURL
|
|
26
|
+
|
|
27
|
+
def wait_until_upload_url_changed(self, uploadproxy_url, timeout=TIMEOUT_4MINUTES):
|
|
28
|
+
"""
|
|
29
|
+
Wait until upload proxy url is changed
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
timeout (int): Time to wait for CDI Config.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
bool: True if url is equal to uploadProxyURL.
|
|
36
|
+
"""
|
|
37
|
+
self.logger.info(
|
|
38
|
+
f"Wait for {self.kind} {self.name} to ensure current URL == uploadProxyURL"
|
|
39
|
+
)
|
|
40
|
+
samples = TimeoutSampler(
|
|
41
|
+
wait_timeout=timeout,
|
|
42
|
+
sleep=1,
|
|
43
|
+
exceptions_dict=PROTOCOL_ERROR_EXCEPTION_DICT,
|
|
44
|
+
func=self.api.get,
|
|
45
|
+
field_selector=f"metadata.name=={self.name}",
|
|
46
|
+
)
|
|
47
|
+
for sample in samples:
|
|
48
|
+
if sample.items:
|
|
49
|
+
status = sample.items[0].status
|
|
50
|
+
current_url = status.uploadProxyURL
|
|
51
|
+
if current_url == uploadproxy_url:
|
|
52
|
+
return
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ocp_resources.resource import NamespacedResource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ChaosEngine(NamespacedResource):
|
|
7
|
+
api_group = NamespacedResource.ApiGroup.LITMUS_IO
|
|
8
|
+
|
|
9
|
+
class EngineStatus:
|
|
10
|
+
INITIALIZED = "initialized"
|
|
11
|
+
COMPLETED = "completed"
|
|
12
|
+
STOPPED = "stopped"
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def engine_status(self):
|
|
16
|
+
return self.instance.status["engineStatus"]
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def experiments_status(self):
|
|
20
|
+
experiments = self.instance.status["experiments"]
|
|
21
|
+
ret_value = {}
|
|
22
|
+
for experiment in experiments:
|
|
23
|
+
exp = {"verdict": experiment["verdict"], "status": experiment["status"]}
|
|
24
|
+
ret_value[experiment["name"]] = exp
|
|
25
|
+
return ret_value
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def success(self):
|
|
29
|
+
exps = self.experiments_status
|
|
30
|
+
return all(exp["verdict"] == "Pass" for exp in exps.values())
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from ocp_resources.constants import TIMEOUT_4MINUTES
|
|
3
|
+
from ocp_resources.resource import Resource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ClusterRole(Resource):
|
|
7
|
+
"""
|
|
8
|
+
ClusterRole object
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
api_group = Resource.ApiGroup.RBAC_AUTHORIZATION_K8S_IO
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
name=None,
|
|
16
|
+
client=None,
|
|
17
|
+
api_groups=None,
|
|
18
|
+
permissions_to_resources=None,
|
|
19
|
+
verbs=None,
|
|
20
|
+
teardown=True,
|
|
21
|
+
yaml_file=None,
|
|
22
|
+
delete_timeout=TIMEOUT_4MINUTES,
|
|
23
|
+
**kwargs,
|
|
24
|
+
):
|
|
25
|
+
super().__init__(
|
|
26
|
+
client=client,
|
|
27
|
+
name=name,
|
|
28
|
+
teardown=teardown,
|
|
29
|
+
yaml_file=yaml_file,
|
|
30
|
+
delete_timeout=delete_timeout,
|
|
31
|
+
**kwargs,
|
|
32
|
+
)
|
|
33
|
+
self.api_groups = api_groups
|
|
34
|
+
self.permissions_to_resources = permissions_to_resources
|
|
35
|
+
self.verbs = verbs
|
|
36
|
+
self.desired_state = {"rules": []}
|
|
37
|
+
|
|
38
|
+
def to_dict(self):
|
|
39
|
+
if not self.res:
|
|
40
|
+
super().to_dict()
|
|
41
|
+
|
|
42
|
+
if not self.yaml_file and self.permissions_to_resources:
|
|
43
|
+
self.add_rule(
|
|
44
|
+
api_groups=self.api_groups,
|
|
45
|
+
permissions_to_resources=self.permissions_to_resources,
|
|
46
|
+
verbs=self.verbs,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def add_rule(
|
|
50
|
+
self,
|
|
51
|
+
api_groups=None,
|
|
52
|
+
permissions_to_resources=None,
|
|
53
|
+
verbs=None,
|
|
54
|
+
):
|
|
55
|
+
if not self.res:
|
|
56
|
+
super().to_dict()
|
|
57
|
+
|
|
58
|
+
rule = {}
|
|
59
|
+
if api_groups:
|
|
60
|
+
rule["apiGroups"] = api_groups
|
|
61
|
+
if permissions_to_resources:
|
|
62
|
+
rule["resources"] = permissions_to_resources
|
|
63
|
+
if verbs:
|
|
64
|
+
rule["verbs"] = verbs
|
|
65
|
+
if rule:
|
|
66
|
+
self._set_rule(rule=rule)
|
|
67
|
+
|
|
68
|
+
def _set_rule(self, rule):
|
|
69
|
+
self.desired_state["rules"].append(rule)
|
|
70
|
+
self.res["rules"] = self.desired_state["rules"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from ocp_resources.cluster_role import ClusterRole
|
|
4
|
+
from ocp_resources.resource import Resource
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ClusterRoleBinding(Resource):
|
|
8
|
+
"""
|
|
9
|
+
ClusterRoleBinding object.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
api_group = Resource.ApiGroup.RBAC_AUTHORIZATION_K8S_IO
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
name=None,
|
|
17
|
+
cluster_role=None,
|
|
18
|
+
subjects=None,
|
|
19
|
+
**kwargs,
|
|
20
|
+
):
|
|
21
|
+
super().__init__(name=name, **kwargs)
|
|
22
|
+
self.cluster_role = cluster_role
|
|
23
|
+
self.subjects = subjects
|
|
24
|
+
|
|
25
|
+
def to_dict(self):
|
|
26
|
+
super().to_dict()
|
|
27
|
+
if not self.yaml_file:
|
|
28
|
+
self.res.setdefault("roleRef", {})
|
|
29
|
+
self.res["roleRef"] = {
|
|
30
|
+
"apiGroup": self.api_group,
|
|
31
|
+
"kind": ClusterRole.kind,
|
|
32
|
+
"name": self.cluster_role,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if self.subjects:
|
|
36
|
+
self.res.setdefault("subjects", self.subjects)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from ocp_resources.constants import TIMEOUT_4MINUTES
|
|
2
|
+
from ocp_resources.resource import NamespacedResource
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ConfigMap(NamespacedResource):
|
|
6
|
+
"""
|
|
7
|
+
Configmap object
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
api_version = NamespacedResource.ApiVersion.V1
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
name=None,
|
|
15
|
+
namespace=None,
|
|
16
|
+
data=None,
|
|
17
|
+
teardown=True,
|
|
18
|
+
client=None,
|
|
19
|
+
yaml_file=None,
|
|
20
|
+
delete_timeout=TIMEOUT_4MINUTES,
|
|
21
|
+
**kwargs,
|
|
22
|
+
):
|
|
23
|
+
super().__init__(
|
|
24
|
+
name=name,
|
|
25
|
+
namespace=namespace,
|
|
26
|
+
client=client,
|
|
27
|
+
teardown=teardown,
|
|
28
|
+
yaml_file=yaml_file,
|
|
29
|
+
delete_timeout=delete_timeout,
|
|
30
|
+
**kwargs,
|
|
31
|
+
)
|
|
32
|
+
self.data = data
|
|
33
|
+
|
|
34
|
+
def to_dict(self):
|
|
35
|
+
super().to_dict()
|
|
36
|
+
if not self.yaml_file and self.data:
|
|
37
|
+
self.res.setdefault("data", {}).update(self.data)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from kubernetes.dynamic.exceptions import ForbiddenError
|
|
2
|
+
from openshift.dynamic.exceptions import (
|
|
3
|
+
InternalServerError,
|
|
4
|
+
NotFoundError,
|
|
5
|
+
ServerTimeoutError,
|
|
6
|
+
)
|
|
7
|
+
from urllib3.exceptions import MaxRetryError, ProtocolError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
DEFAULT_CLUSTER_RETRY_EXCEPTIONS = {
|
|
11
|
+
MaxRetryError: [],
|
|
12
|
+
ConnectionAbortedError: [],
|
|
13
|
+
ConnectionResetError: [],
|
|
14
|
+
InternalServerError: [
|
|
15
|
+
"etcdserver: leader changed",
|
|
16
|
+
"etcdserver: request timed out",
|
|
17
|
+
"Internal error occurred: failed calling webhook",
|
|
18
|
+
"rpc error:",
|
|
19
|
+
],
|
|
20
|
+
ServerTimeoutError: [],
|
|
21
|
+
ForbiddenError: ["context deadline exceeded"],
|
|
22
|
+
}
|
|
23
|
+
PROTOCOL_ERROR_EXCEPTION_DICT = {ProtocolError: []}
|
|
24
|
+
NOT_FOUND_ERROR_EXCEPTION_DICT = {NotFoundError: []}
|
|
25
|
+
TIMEOUT_4MINUTES = 240
|
|
26
|
+
TIMEOUT_1MINUTE = 60
|