summaryrefslogtreecommitdiffstats
path: root/cns-libs/cnslibs/common/utils.py
diff options
context:
space:
mode:
authorValerii Ponomarov <vponomar@redhat.com>2018-11-07 18:02:59 +0530
committerValerii Ponomarov <vponomar@redhat.com>2018-11-19 14:25:25 +0000
commit03852d4cbca85411f67a0eb34b6d467f78448bf4 (patch)
treea7e70d3cc26c1360d4c95345f39f382ab23c5af8 /cns-libs/cnslibs/common/utils.py
parente2da188e170c1b681053c9939e69b59b75b0ee4f (diff)
Fix pep8 W605 rule violation
Now, string objects, which contain backslash symbol, should be prefixed with 'r' letter which transforms it to 'raw string literal'. Info: https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior Change-Id: I8d5c1c1c022cae9d163dea2e0613c9ca24ddad08
Diffstat (limited to 'cns-libs/cnslibs/common/utils.py')
-rw-r--r--cns-libs/cnslibs/common/utils.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/cns-libs/cnslibs/common/utils.py b/cns-libs/cnslibs/common/utils.py
index 9aa38ff9..2d16c497 100644
--- a/cns-libs/cnslibs/common/utils.py
+++ b/cns-libs/cnslibs/common/utils.py
@@ -5,47 +5,10 @@ For example, not specific to OCP, Gluster, Heketi, etc.
"""
import random
-import re
import string
-from glusto.core import Glusto as g
-
from prometheus_client.parser import text_string_to_metric_families
-ONE_GB_BYTES = 1073741824.0
-
-
-def get_device_size(host, device_name):
- """Gets device size for the given device name.
-
- Args:
- host (str): Node in command will be executed.
- device_name (str): device name for which the size has to
- be calculated.
-
- Returns:
- str : returns device size in GB on success
- False otherwise
-
- Example:
- get_device_size(host, device_name)
- """
-
- cmd = "fdisk -l %s " % device_name
- ret, out, _ = g.run(host, cmd)
- if ret != 0:
- g.log.error("Failed to execute fdisk -l command "
- "on node %s" % host)
- return False
-
- regex = 'Disk\s' + device_name + '.*?,\s(\d+)\sbytes\,.*'
- match = re.search(regex, out)
- if match is None:
- g.log.error("Regex mismatch while parsing fdisk -l output")
- return False
-
- return str(int(int(match.group(1))/ONE_GB_BYTES))
-
def get_random_str(size=14):
chars = string.ascii_lowercase + string.digits