From d6837d77c7a410585a13a430b3a53ab91c19faad Mon Sep 17 00:00:00 2001 From: Bruno Teixeira Date: Wed, 12 Sep 2018 23:09:59 +0100 Subject: [PATCH 1/2] trim mods after comma split --- salt/client/ssh/wrapper/state.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/client/ssh/wrapper/state.py b/salt/client/ssh/wrapper/state.py index b4272e4b55b4..0ee97e216b73 100644 --- a/salt/client/ssh/wrapper/state.py +++ b/salt/client/ssh/wrapper/state.py @@ -182,7 +182,7 @@ def sls(mods, saltenv='base', test=None, exclude=None, **kwargs): __context__['fileclient']) st_.push_active() if isinstance(mods, six.string_types): - mods = mods.split(',') + mods = [item.strip() for item in mods.split(',')] high_data, errors = st_.render_highstate({saltenv: mods}) if exclude: if isinstance(exclude, six.string_types): @@ -923,7 +923,7 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs): return err if isinstance(mods, six.string_types): - split_mods = mods.split(',') + split_mods = [item.strip() for item in mods.split(',')] st_.push_active() high_, errors = st_.render_highstate({opts['saltenv']: split_mods}) errors += st_.state.verify_high(high_) @@ -981,7 +981,7 @@ def show_sls(mods, saltenv='base', test=None, **kwargs): __context__['fileclient']) st_.push_active() if isinstance(mods, six.string_types): - mods = mods.split(',') + mods = [item.strip() for item in mods.split(',')] high_data, errors = st_.render_highstate({saltenv: mods}) high_data, ext_errors = st_.state.reconcile_extend(high_data) errors += ext_errors @@ -1026,7 +1026,7 @@ def show_low_sls(mods, saltenv='base', test=None, **kwargs): __context__['fileclient']) st_.push_active() if isinstance(mods, six.string_types): - mods = mods.split(',') + mods = [item.strip() for item in mods.split(',')] high_data, errors = st_.render_highstate({saltenv: mods}) high_data, ext_errors = st_.state.reconcile_extend(high_data) errors += ext_errors From 7be3adaac235a2b84320ca0522c1ecd79b91beb3 Mon Sep 17 00:00:00 2001 From: Bruno Teixeira Date: Wed, 3 Oct 2018 21:57:53 +0100 Subject: [PATCH 2/2] moved mods split to method. --- salt/client/ssh/wrapper/state.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/salt/client/ssh/wrapper/state.py b/salt/client/ssh/wrapper/state.py index 0ee97e216b73..3f1cead4b169 100644 --- a/salt/client/ssh/wrapper/state.py +++ b/salt/client/ssh/wrapper/state.py @@ -167,6 +167,16 @@ def _cleanup_slsmod_high_data(high_data): stateconf_data['slsmod'] = None +def _parse_mods(mods): + ''' + Parse modules. + ''' + if isinstance(mods, six.string_types): + mods = [item.strip() for item in mods.split(',') if item.strip()] + + return mods + + def sls(mods, saltenv='base', test=None, exclude=None, **kwargs): ''' Create the seed file for a state.sls run @@ -181,8 +191,7 @@ def sls(mods, saltenv='base', test=None, exclude=None, **kwargs): __salt__, __context__['fileclient']) st_.push_active() - if isinstance(mods, six.string_types): - mods = [item.strip() for item in mods.split(',')] + mods = _parse_mods(mods) high_data, errors = st_.render_highstate({saltenv: mods}) if exclude: if isinstance(exclude, six.string_types): @@ -922,8 +931,7 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs): err += __pillar__['_errors'] return err - if isinstance(mods, six.string_types): - split_mods = [item.strip() for item in mods.split(',')] + split_mods = _parse_mods(mods) st_.push_active() high_, errors = st_.render_highstate({opts['saltenv']: split_mods}) errors += st_.state.verify_high(high_) @@ -980,8 +988,7 @@ def show_sls(mods, saltenv='base', test=None, **kwargs): __salt__, __context__['fileclient']) st_.push_active() - if isinstance(mods, six.string_types): - mods = [item.strip() for item in mods.split(',')] + mods = _parse_mods(mods) high_data, errors = st_.render_highstate({saltenv: mods}) high_data, ext_errors = st_.state.reconcile_extend(high_data) errors += ext_errors @@ -1025,8 +1032,7 @@ def show_low_sls(mods, saltenv='base', test=None, **kwargs): __salt__, __context__['fileclient']) st_.push_active() - if isinstance(mods, six.string_types): - mods = [item.strip() for item in mods.split(',')] + mods = _parse_mods(mods) high_data, errors = st_.render_highstate({saltenv: mods}) high_data, ext_errors = st_.state.reconcile_extend(high_data) errors += ext_errors