From d65425453d215ad64e2bf31b66a3b613c6e7f879 Mon Sep 17 00:00:00 2001 From: Vladislav Kuzmin Date: Mon, 19 Aug 2013 15:37:56 +0400 Subject: [PATCH] Remove unused methods from cinder.utils These methods were left over from the split from Nova and are unused still. Remove methods: is_valid_ipv4() make_dev_path() convert_to_list_dict() partition_dict() subset_dict() Change-Id: Icb36aa6a2d1f607c440a2d524d3480de23d1cb7a --- cinder/utils.py | 58 ------------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/cinder/utils.py b/cinder/utils.py index 8942c273d..4822dae29 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -730,18 +730,6 @@ def flatten_dict(dict_, flattened=None): return flattened -def partition_dict(dict_, keys): - """Return two dicts, one with `keys` the other with everything else.""" - intersection = {} - difference = {} - for key, value in dict_.iteritems(): - if key in keys: - intersection[key] = value - else: - difference[key] = value - return intersection, difference - - def map_dict_keys(dict_, key_map): """Return a dict in which the dictionaries keys are mapped to new keys.""" mapped = {} @@ -751,12 +739,6 @@ def map_dict_keys(dict_, key_map): return mapped -def subset_dict(dict_, keys): - """Return a dict that only contains a subset of keys.""" - subset = partition_dict(dict_, keys)[0] - return subset - - def check_isinstance(obj, cls): """Checks that obj is of type cls, and lets PyLint infer types.""" if isinstance(obj, cls): @@ -775,22 +757,6 @@ def is_valid_boolstr(val): val == '1' or val == '0') -def is_valid_ipv4(address): - """valid the address strictly as per format xxx.xxx.xxx.xxx. - where xxx is a value between 0 and 255. - """ - parts = address.split(".") - if len(parts) != 4: - return False - for item in parts: - try: - if not 0 <= int(item) <= 255: - return False - except ValueError: - return False - return True - - def monkey_patch(): """If the CONF.monkey_patch set as True, this function patches a decorator @@ -834,15 +800,6 @@ def monkey_patch(): decorator("%s.%s" % (module, key), func)) -def convert_to_list_dict(lst, label): - """Convert a value or list into a list of dicts""" - if not lst: - return None - if not isinstance(lst, list): - lst = [lst] - return [{label: x} for x in lst] - - def timefunc(func): """Decorator that logs how long a particular function took to execute""" @functools.wraps(func) @@ -877,21 +834,6 @@ def logging_error(message): LOG.exception(message) -def make_dev_path(dev, partition=None, base='/dev'): - """Return a path to a particular device. - - >>> make_dev_path('xvdc') - /dev/xvdc - - >>> make_dev_path('xvdc', 1) - /dev/xvdc1 - """ - path = os.path.join(base, dev) - if partition: - path += str(partition) - return path - - def total_seconds(td): """Local total_seconds implementation for compatibility with python 2.6""" if hasattr(td, 'total_seconds'): -- 2.45.2