@@ -1257,8 +1257,7 @@ def sls(mods, test=None, exclude=None, queue=False, **kwargs):
1257
1257
return st_ .state .call_high (high_ , orchestration_jid )
1258
1258
os .umask (umask )
1259
1259
1260
- if isinstance (mods , six .string_types ):
1261
- mods = mods .split (',' )
1260
+ mods = salt .utils .args .split_input (mods )
1262
1261
1263
1262
st_ .push_active ()
1264
1263
try :
@@ -1269,8 +1268,7 @@ def sls(mods, test=None, exclude=None, queue=False, **kwargs):
1269
1268
return errors
1270
1269
1271
1270
if exclude :
1272
- if isinstance (exclude , six .string_types ):
1273
- exclude = exclude .split (',' )
1271
+ exclude = salt .utils .args .split_input (exclude )
1274
1272
if '__exclude__' in high_ :
1275
1273
high_ ['__exclude__' ].extend (exclude )
1276
1274
else :
@@ -1665,8 +1663,7 @@ def sls_id(id_, mods, test=None, queue=False, **kwargs):
1665
1663
__context__ ['retcode' ] = 5
1666
1664
return ['Pillar failed to render with the following messages:' ] + errors
1667
1665
1668
- if isinstance (mods , six .string_types ):
1669
- split_mods = mods .split (',' )
1666
+ split_mods = salt .utils .args .split_input (mods )
1670
1667
st_ .push_active ()
1671
1668
try :
1672
1669
high_ , errors = st_ .render_highstate ({opts ['saltenv' ]: split_mods })
@@ -1774,8 +1771,7 @@ def show_low_sls(mods, test=None, queue=False, **kwargs):
1774
1771
__context__ ['retcode' ] = 5
1775
1772
raise CommandExecutionError ('Pillar failed to render' , info = errors )
1776
1773
1777
- if isinstance (mods , six .string_types ):
1778
- mods = mods .split (',' )
1774
+ mods = salt .utils .args .split_input (mods )
1779
1775
st_ .push_active ()
1780
1776
try :
1781
1777
high_ , errors = st_ .render_highstate ({opts ['saltenv' ]: mods })
@@ -1863,8 +1859,7 @@ def show_sls(mods, test=None, queue=False, **kwargs):
1863
1859
__context__ ['retcode' ] = 5
1864
1860
raise CommandExecutionError ('Pillar failed to render' , info = errors )
1865
1861
1866
- if isinstance (mods , six .string_types ):
1867
- mods = mods .split (',' )
1862
+ mods = salt .utils .args .split_input (mods )
1868
1863
st_ .push_active ()
1869
1864
try :
1870
1865
high_ , errors = st_ .render_highstate ({opts ['saltenv' ]: mods })
@@ -1880,6 +1875,56 @@ def show_sls(mods, test=None, queue=False, **kwargs):
1880
1875
return high_
1881
1876
1882
1877
1878
+ def sls_exists (mods , test = None , queue = False , ** kwargs ):
1879
+ '''
1880
+ Tests for the existance the of a specific SLS or list of SLS files on the
1881
+ master. Similar to :py:func:`state.show_sls <salt.modules.state.show_sls>`,
1882
+ rather than returning state details, returns True or False. The default
1883
+ environment is ``base``, use ``saltenv`` to specify a different environment.
1884
+
1885
+ .. versionadded:: Fluorine
1886
+
1887
+ saltenv
1888
+ Specify a salt fileserver environment from which to look for the SLS files
1889
+ specified in the ``mods`` argument
1890
+
1891
+ CLI Example:
1892
+
1893
+ .. code-block:: bash
1894
+
1895
+ salt '*' state.sls_exists core,edit.vim saltenv=dev
1896
+ '''
1897
+ return isinstance (
1898
+ show_sls (mods , test = test , queue = queue , ** kwargs ),
1899
+ dict
1900
+ )
1901
+
1902
+
1903
+ def id_exists (ids , mods , test = None , queue = False , ** kwargs ):
1904
+ '''
1905
+ Tests for the existence of a specific ID or list of IDs within the
1906
+ specified SLS file(s). Similar to :py:func:`state.sls_exists
1907
+ <salt.modules.state.sls_exists>`, returns True or False. The default
1908
+ environment is base``, use ``saltenv`` to specify a different environment.
1909
+
1910
+ .. versionadded:: Fluorine
1911
+
1912
+ saltenv
1913
+ Specify a salt fileserver environment from which to look for the SLS files
1914
+ specified in the ``mods`` argument
1915
+
1916
+ CLI Example:
1917
+
1918
+ .. code-block:: bash
1919
+
1920
+ salt '*' state.id_exists create_myfile,update_template filestate saltenv=dev
1921
+ '''
1922
+ ids = salt .utils .args .split_input (ids )
1923
+ ids = set (ids )
1924
+ sls_ids = set (x ['__id__' ] for x in show_low_sls (mods , test = test , queue = queue , ** kwargs ))
1925
+ return ids .issubset (sls_ids )
1926
+
1927
+
1883
1928
def show_top (queue = False , ** kwargs ):
1884
1929
'''
1885
1930
Return the top data that the minion will use for a highstate
@@ -2116,8 +2161,7 @@ def disable(states):
2116
2161
'msg' : ''
2117
2162
}
2118
2163
2119
- if isinstance (states , six .string_types ):
2120
- states = states .split (',' )
2164
+ states = salt .utils .args .split_input (states )
2121
2165
2122
2166
msg = []
2123
2167
_disabled = __salt__ ['grains.get' ]('state_runs_disabled' )
@@ -2168,8 +2212,7 @@ def enable(states):
2168
2212
'msg' : ''
2169
2213
}
2170
2214
2171
- if isinstance (states , six .string_types ):
2172
- states = states .split (',' )
2215
+ states = salt .utils .args .split_input (states )
2173
2216
log .debug ('states %s' , states )
2174
2217
2175
2218
msg = []
0 commit comments