-
Notifications
You must be signed in to change notification settings - Fork 74
Storage: Add DPA resource #2697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md | ||
|
|
||
|
|
||
| from typing import Any | ||
|
|
||
| from ocp_resources.exceptions import MissingRequiredArgumentError | ||
| from ocp_resources.resource import NamespacedResource | ||
|
|
||
|
|
||
| class DataProtectionApplication(NamespacedResource): | ||
| """ | ||
| DataProtectionApplication is the Schema for the dpa API | ||
| """ | ||
|
|
||
| api_group: str = NamespacedResource.ApiGroup.OADP_OPENSHIFT_IO | ||
|
|
||
| def __init__( | ||
| self, | ||
| backup_images: bool | None = None, | ||
| backup_locations: list[Any] | None = None, | ||
| configuration: dict[str, Any] | None = None, | ||
| features: dict[str, Any] | None = None, | ||
| image_pull_policy: str | None = None, | ||
| pod_annotations: dict[str, Any] | None = None, | ||
| pod_dns_config: dict[str, Any] | None = None, | ||
| pod_dns_policy: str | None = None, | ||
| snapshot_locations: list[Any] | None = None, | ||
| unsupported_overrides: dict[str, Any] | None = None, | ||
| **kwargs: Any, | ||
| ) -> None: | ||
| r""" | ||
| Args: | ||
| backup_images (bool): backupImages is used to specify whether you want to deploy a registry | ||
| for enabling backup and restore of images | ||
|
|
||
| backup_locations (list[Any]): backupLocations defines the list of desired configuration to use for | ||
| BackupStorageLocations | ||
|
|
||
| configuration (dict[str, Any]): configuration is used to configure the data protection application's | ||
| server config | ||
|
|
||
| features (dict[str, Any]): features defines the configuration for the DPA to enable the OADP tech | ||
| preview features | ||
|
|
||
| image_pull_policy (str): which imagePullPolicy to use in all container images used by OADP. By | ||
| default, for images with sha256 or sha512 digest, OADP uses | ||
| IfNotPresent and uses Always for all other images. | ||
|
|
||
| pod_annotations (dict[str, Any]): add annotations to pods deployed by operator | ||
|
|
||
| pod_dns_config (dict[str, Any]): podDnsConfig defines the DNS parameters of a pod in addition to those | ||
| generated from DNSPolicy. | ||
| https://kubernetes.io/docs/concepts/services-networking/dns-pod- | ||
| service/#pod-dns-config | ||
|
|
||
| pod_dns_policy (str): podDnsPolicy defines how a pod's DNS will be configured. | ||
| https://kubernetes.io/docs/concepts/services-networking/dns-pod- | ||
| service/#pod-s-dns-policy | ||
|
|
||
| snapshot_locations (list[Any]): snapshotLocations defines the list of desired configuration to use for | ||
| VolumeSnapshotLocations | ||
|
|
||
| unsupported_overrides (dict[str, Any]): unsupportedOverrides can be used to override images used in | ||
| deployments. Available keys are: - veleroImageFqin - | ||
| awsPluginImageFqin - legacyAWSPluginImageFqin - | ||
| openshiftPluginImageFqin - azurePluginImageFqin - | ||
| gcpPluginImageFqin - resticRestoreImageFqin - | ||
| kubevirtPluginImageFqin - operator-type | ||
|
|
||
| """ | ||
| super().__init__(**kwargs) | ||
|
|
||
| self.backup_images = backup_images | ||
| self.backup_locations = backup_locations | ||
| self.configuration = configuration | ||
| self.features = features | ||
| self.image_pull_policy = image_pull_policy | ||
| self.pod_annotations = pod_annotations | ||
| self.pod_dns_config = pod_dns_config | ||
| self.pod_dns_policy = pod_dns_policy | ||
| self.snapshot_locations = snapshot_locations | ||
| self.unsupported_overrides = unsupported_overrides | ||
|
|
||
| def to_dict(self) -> None: | ||
|
|
||
| super().to_dict() | ||
|
|
||
| if not self.kind_dict and not self.yaml_file: | ||
| if self.configuration is None: | ||
| raise MissingRequiredArgumentError(argument="self.configuration") | ||
|
|
||
| self.res["spec"] = {} | ||
| _spec = self.res["spec"] | ||
|
|
||
| _spec["configuration"] = self.configuration | ||
|
|
||
| if self.backup_images is not None: | ||
| _spec["backupImages"] = self.backup_images | ||
|
|
||
| if self.backup_locations is not None: | ||
| _spec["backupLocations"] = self.backup_locations | ||
|
|
||
| if self.features is not None: | ||
| _spec["features"] = self.features | ||
|
|
||
| if self.image_pull_policy is not None: | ||
| _spec["imagePullPolicy"] = self.image_pull_policy | ||
|
|
||
| if self.pod_annotations is not None: | ||
| _spec["podAnnotations"] = self.pod_annotations | ||
|
|
||
| if self.pod_dns_config is not None: | ||
| _spec["podDnsConfig"] = self.pod_dns_config | ||
|
|
||
| if self.pod_dns_policy is not None: | ||
| _spec["podDnsPolicy"] = self.pod_dns_policy | ||
|
|
||
| if self.snapshot_locations is not None: | ||
| _spec["snapshotLocations"] = self.snapshot_locations | ||
|
|
||
| if self.unsupported_overrides is not None: | ||
| _spec["unsupportedOverrides"] = self.unsupported_overrides | ||
|
|
||
| # End of generated code | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import pytest | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this test added?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/RedHatQE/openshift-python-wrapper#adding-tests-for-new-resources I saw that we have tests for other new resources so assumed we adding it, but can remove tests if not required |
||
|
|
||
| from ocp_resources.data_protection_application import DataProtectionApplication | ||
|
|
||
|
|
||
| @pytest.mark.incremental | ||
| class TestDataProtectionApplication: | ||
| @pytest.fixture(scope="class") | ||
| def dataprotectionapplication(self, fake_client): | ||
| return DataProtectionApplication( | ||
| client=fake_client, | ||
| name="test-dataprotectionapplication", | ||
| namespace="default", | ||
| configuration={"test-configuration": "test-value"}, | ||
| ) | ||
|
|
||
| def test_01_create_dataprotectionapplication(self, dataprotectionapplication): | ||
| """Test creating DataProtectionApplication""" | ||
| deployed_resource = dataprotectionapplication.deploy() | ||
| assert deployed_resource | ||
| assert deployed_resource.name == "test-dataprotectionapplication" | ||
| assert dataprotectionapplication.exists | ||
|
|
||
| def test_02_get_dataprotectionapplication(self, dataprotectionapplication): | ||
| """Test getting DataProtectionApplication""" | ||
| assert dataprotectionapplication.instance | ||
| assert dataprotectionapplication.kind == "DataProtectionApplication" | ||
|
|
||
| def test_03_update_dataprotectionapplication(self, dataprotectionapplication): | ||
| """Test updating DataProtectionApplication""" | ||
| resource_dict = dataprotectionapplication.instance.to_dict() | ||
| resource_dict["metadata"]["labels"] = {"updated": "true"} | ||
| dataprotectionapplication.update(resource_dict=resource_dict) | ||
| assert dataprotectionapplication.labels["updated"] == "true" | ||
|
|
||
| def test_04_delete_dataprotectionapplication(self, dataprotectionapplication): | ||
| """Test deleting DataProtectionApplication""" | ||
| dataprotectionapplication.clean_up(wait=False) | ||
| # Verify resource no longer exists after deletion | ||
| assert not dataprotectionapplication.exists | ||
Uh oh!
There was an error while loading. Please reload this page.