summaryrefslogtreecommitdiffstats
path: root/src/spdk/ocf/tests/functional/pyocf/ocf.py
blob: b24d8265f51c687aa68ccfa2050b34ddbacb4806 (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
#
# Copyright(c) 2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
from ctypes import c_void_p, cdll
import inspect
import os


class OcfLib:
    __lib__ = None

    @classmethod
    def getInstance(cls):
        if cls.__lib__ is None:
            lib = cdll.LoadLibrary(
                os.path.join(
                    os.path.dirname(inspect.getfile(inspect.currentframe())),
                    "libocf.so",
                )
            )
            lib.ocf_volume_get_uuid.restype = c_void_p
            lib.ocf_volume_get_uuid.argtypes = [c_void_p]

            lib.ocf_core_get_front_volume.restype = c_void_p
            lib.ocf_core_get_front_volume.argtypes = [c_void_p]

            cls.__lib__ = lib

        return cls.__lib__