diff options
| author | Apeksha D Khakharia <akhakhar@redhat.com> | 2018-03-05 18:03:10 +0530 |
|---|---|---|
| committer | Apeksha D Khakharia <akhakhar@redhat.com> | 2018-05-08 15:14:32 +0530 |
| commit | a0926b0e17f21547910f6db8ecd086a81565d935 (patch) | |
| tree | 8915554e3c70acc4a989d2f60c12efca4b6cb1ac /cns-libs | |
| parent | 55e396a9ed1ae935bf7ca77bf1e230b5e7c4dea5 (diff) | |
CNS: adding testcase and library for volnameprefix
Change-Id: I84968bcfe19aa8af73f185be178079a8373915b3
Signed-off-by: Apeksha D Khakharia <akhakhar@redhat.com>
Diffstat (limited to 'cns-libs')
| -rw-r--r-- | cns-libs/cnslibs/common/dynamic_provisioning.py | 3 | ||||
| -rw-r--r-- | cns-libs/cnslibs/common/heketi_ops.py | 49 |
2 files changed, 51 insertions, 1 deletions
diff --git a/cns-libs/cnslibs/common/dynamic_provisioning.py b/cns-libs/cnslibs/common/dynamic_provisioning.py index fea44b4b..7c1d0168 100644 --- a/cns-libs/cnslibs/common/dynamic_provisioning.py +++ b/cns-libs/cnslibs/common/dynamic_provisioning.py @@ -159,6 +159,7 @@ def create_storage_class_file(hostname, sc_name, resturl, restsecretnamespace:str ex: restsecretnamespace:"storage-project" restsecretname:str ex: restsecretname:"heketi-secret" + volumenameprefix:str ex: "dept_qe" Returns: bool: True if successful, otherwise False @@ -173,7 +174,7 @@ def create_storage_class_file(hostname, sc_name, resturl, for key in ('secretnamespace', 'restuser', 'secretname', 'restauthenabled', 'restsecretnamespace', 'restsecretname', 'hacount', 'clusterids', - 'chapauthenabled'): + 'chapauthenabled', 'volumenameprefix'): if kwargs.get(key): data['parameters'][key] = kwargs.get(key) diff --git a/cns-libs/cnslibs/common/heketi_ops.py b/cns-libs/cnslibs/common/heketi_ops.py index f2473d66..8e36d331 100644 --- a/cns-libs/cnslibs/common/heketi_ops.py +++ b/cns-libs/cnslibs/common/heketi_ops.py @@ -2154,3 +2154,52 @@ def heketi_blockvolume_list(heketi_client_node, heketi_server_url, mode='cli', except: g.log.error("Failed to do blockvolume list using heketi") return False + + +def verify_volume_name_prefix(hostname, prefix, namespace, pvc_name, + heketi_server_url, **kwargs): + ''' + This function checks if heketi voluem is present with + volname prefix + Args: + hostname (str): hostname on which we want + to check the heketi vol + prefix (str): volnameprefix given in storageclass + namespace (str): namespace + pvc_name (str): name of the pvc + heketi_server_url (str): Heketi server url + + Kwargs: + mode (str): Mode in which heketi command will be executed. + It can be cli|url. Defaults to cli. + **kwargs + The keys, values in kwargs are: + - json : (bool) + - secret : (str)|None + - user : (str)|None + + Returns: + bool: True if volume found, + Fasle otherwise. + ''' + (heketi_server_url, + json_arg, admin_key, user) = _set_heketi_global_flags(heketi_server_url, + **kwargs) + + heketi_vol_name_prefix = "%s_%s_%s_" % (prefix, namespace, + pvc_name) + cmd = ("heketi-cli -s %s volume list %s %s %s | grep %s" % ( + heketi_server_url, json_arg, admin_key, user, + heketi_vol_name_prefix)) + ret, out, err = g.run(hostname, cmd, "root") + if ret != 0: + if not out: + g.log.error("no heketi volume with volnameprefix - %s" % ( + heketi_vol_name_prefix)) + else: + g.log.error("failed to execute cmd %s" % cmd) + return False + output = out.strip() + g.log.info("heketi volume with volnameprefix present %s" % ( + output)) + return True |
