diff options
author | Krishnaram Karthick Ramdoss <kramdoss@redhat.com> | 2018-05-10 10:27:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.host.prod.eng.bos.redhat.com> | 2018-05-10 10:27:11 +0000 |
commit | 695e5f44ab03db37248e8e920ee6071e24536d2f (patch) | |
tree | d31a0d747ccfcecf7c353a77aa35e3765030e102 /cns-libs | |
parent | 45d805083fcdef96d4898e604b0c8533bb509ff9 (diff) | |
parent | a0926b0e17f21547910f6db8ecd086a81565d935 (diff) |
Merge "CNS: adding testcase and library for volnameprefix"
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 |