From 8491638d8c712db3cd33af2a68ec31bb41712d30 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Mon, 25 Feb 2019 16:25:53 -0500 Subject: [PATCH] Convert the driver_options to a dictionary This patch converts the cinder interface driver_options to a dictionary so it can be pickled between processes. This patch also calls query.get() prior to join() so we don't run into a deadlock. Change-Id: I67fa8b9b2733440b8e8a373a8f89a0834144ea7e --- cinderlib/cinderlib.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cinderlib/cinderlib.py b/cinderlib/cinderlib.py index 0009b45..3e71429 100644 --- a/cinderlib/cinderlib.py +++ b/cinderlib/cinderlib.py @@ -393,6 +393,15 @@ class Backend(object): @staticmethod def list_supported_drivers(): """Returns dictionary with driver classes names as keys.""" + + def convert_oslo_config(oslo_options): + options = [] + for opt in oslo_options: + tmp_dict = {k: str(v) for k, v in vars(opt).items() + if not k.startswith('_')} + options.append(tmp_dict) + return options + def list_drivers(queue): cwd = os.getcwd() # Go to the parent directory directory where Cinder is installed @@ -403,6 +412,9 @@ class Backend(object): # Drivers contain class instances which are not serializable for driver in mapping.values(): driver.pop('cls', None) + if 'driver_options' in driver: + driver['driver_options'] = convert_oslo_config( + driver['driver_options']) finally: os.chdir(cwd) queue.put(mapping) @@ -412,8 +424,8 @@ class Backend(object): queue = multiprocessing.Queue() p = multiprocessing.Process(target=list_drivers, args=(queue,)) p.start() - p.join() result = queue.get() + p.join() return result