Beispiel #1
0
def default_storageclasses(request, teardown_factory_session):
    """
    Returns dictionary with storageclasses. Keys represent reclaim policy of
    storageclass. There are two storageclasses for each key. First is RBD based
    and the second one is CephFS based. Storageclasses with Retain Reclaim
    Policy are created from default storageclasses.
    """
    scs = {
        constants.RECLAIM_POLICY_DELETE: [],
        constants.RECLAIM_POLICY_RETAIN: []
    }

    # TODO(fbalak): Use proper constants after
    # https://github.com/red-hat-storage/ocs-ci/issues/1056
    # is resolved
    for sc_name in ('ocs-storagecluster-ceph-rbd',
                    'ocs-storagecluster-cephfs'):
        sc = OCS(kind=constants.STORAGECLASS, metadata={'name': sc_name})
        sc.reload()
        scs[constants.RECLAIM_POLICY_DELETE].append(sc)
        sc.data['reclaimPolicy'] = constants.RECLAIM_POLICY_RETAIN
        sc.data['metadata']['name'] += '-retain'
        sc._name = sc.data['metadata']['name']
        sc.create()
        teardown_factory_session(sc)
        scs[constants.RECLAIM_POLICY_RETAIN].append(sc)
    return scs
Beispiel #2
0
    def backed_pv_obj(self):
        """
        Returns the backed PV object of pvc_name in namespace

        Returns:
            OCS: An OCS instance for PV
        """
        self.reload()
        data = dict()
        data["api_version"] = self.api_version
        data["kind"] = "PersistentVolume"
        data["metadata"] = {"name": self.backed_pv, "namespace": self.namespace}
        pv_obj = OCS(**data)
        pv_obj.reload()
        return pv_obj
Beispiel #3
0
    def backed_pv_obj(self):
        """
        Returns the backed PV object of pvc_name in namespace

        Returns:
            OCS: An OCS instance for PV
        """
        self.reload()
        data = dict()
        data['api_version'] = self.api_version
        data['kind'] = 'PersistentVolume'
        data['metadata'] = {
            'name': self.backed_pv, 'namespace': self.namespace
        }
        pv_obj = OCS(**data)
        pv_obj.reload()
        return pv_obj
Beispiel #4
0
    def reclaim_policy(self):
        """
        Returns the reclaim policy of pvc in namespace

        Returns:
            str: Reclaim policy Reclaim or Delete
        """

        data = dict()
        data['api_version'] = self.api_version
        data['kind'] = 'StorageClass'
        data['metadata'] = {
            'name': self.backed_sc, 'namespace': self.namespace
        }
        sc_obj = OCS(**data)
        sc_obj.reload()
        return sc_obj.get().get('reclaimPolicy')