Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ocp_resources/storage_class.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from kubernetes.dynamic.exceptions import ResourceNotFoundError

from ocp_resources.resource import Resource
from ocp_resources.storage_profile import StorageProfile


class StorageClass(Resource):
Expand All @@ -13,6 +15,9 @@ class StorageClass(Resource):
class Types:
"""
These are names of StorageClass instances when you run `oc get sc`

API:
https://kubernetes.io/docs/concepts/storage/storage-classes/
"""

LOCAL_BLOCK = "local-block"
Expand Down Expand Up @@ -101,3 +106,14 @@ def to_dict(self):
self.res.update({"allowedTopologies": self.allowed_topologies})
if self.mount_options:
self.res.update({"mountOptions": self.mount_options})

@property
def storage_profile(self):
try:
return StorageProfile(
client=self.client,
name=self.name,
)
except ResourceNotFoundError:
self.logger.error(f" storageProfile is not found for {self.name} storageClass")
raise
29 changes: 29 additions & 0 deletions ocp_resources/storage_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,33 @@


class StorageProfile(Resource):
"""
StorageProfile Object

Doc:
https://github.com/kubevirt/containerized-data-importer/blob/main/doc/storageprofile.md
"""

api_group = Resource.ApiGroup.CDI_KUBEVIRT_IO

@property
def claim_property_sets(self):
return self.instance.status.get("claimPropertySets")

def first_claim_property_set_access_modes(self):
return self.claim_property_sets[0].get("volumeMode") if self.claim_property_sets else None

def first_claim_property_set_volume_mode(self):
return self.claim_property_sets[0].get("volumeMode") if self.claim_property_sets else None

@property
def clone_strategy(self):
return self.instance.status.get("cloneStrategy")

@property
def data_import_cron_source_format(self):
return self.instance.status.get("dataImportCronSourceFormat")

@property
def snapshotclass(self):
return self.instance.status.get("snapshotClass")