mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
FIX #38671 - zpool.get should support older zfs version
This commit is contained in:
parent
23705b12cb
commit
1d191445a7
@ -470,14 +470,13 @@ def get(zpool, prop=None, show_source=False, parsable=True):
|
||||
|
||||
'''
|
||||
ret = OrderedDict()
|
||||
value_properties = ['property', 'value', 'source']
|
||||
value_properties = ['name', 'property', 'value', 'source']
|
||||
|
||||
## collect get output
|
||||
res = __salt__['cmd.run_all'](
|
||||
__utils__['zfs.zpool_command'](
|
||||
command='get',
|
||||
flags=['-H'],
|
||||
opts={'-o': ','.join(value_properties)},
|
||||
property_name=prop if prop else 'all',
|
||||
target=zpool,
|
||||
),
|
||||
@ -503,6 +502,9 @@ def get(zpool, prop=None, show_source=False, parsable=True):
|
||||
[x for x in line.strip().split('\t') if x not in ['']],
|
||||
)))
|
||||
|
||||
# NOTE: older zfs does not have -o, fall back to manually stipping the name field
|
||||
del prop_data['name']
|
||||
|
||||
# NOTE: normalize values
|
||||
if parsable:
|
||||
# NOTE: raw numbers and pythonic types
|
||||
|
@ -223,7 +223,7 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin):
|
||||
Tests successful return of get function
|
||||
'''
|
||||
ret = {}
|
||||
ret['stdout'] = "size\t1.81T\t-\n"
|
||||
ret['stdout'] = "mypool\tsize\t1.81T\t-\n"
|
||||
ret['stderr'] = ""
|
||||
ret['retcode'] = 0
|
||||
mock_cmd = MagicMock(return_value=ret)
|
||||
@ -238,7 +238,7 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin):
|
||||
Tests successful return of get function with parsable output
|
||||
'''
|
||||
ret = {}
|
||||
ret['stdout'] = "size\t1.81T\t-\n"
|
||||
ret['stdout'] = "mypool\tsize\t1.81T\t-\n"
|
||||
ret['stderr'] = ""
|
||||
ret['retcode'] = 0
|
||||
mock_cmd = MagicMock(return_value=ret)
|
||||
@ -253,7 +253,7 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin):
|
||||
Tests successful return of get function with a string with whitespaces
|
||||
'''
|
||||
ret = {}
|
||||
ret['stdout'] = "comment\tmy testing pool\t-\n"
|
||||
ret['stdout'] = "mypool\tcomment\tmy testing pool\t-\n"
|
||||
ret['stderr'] = ""
|
||||
ret['retcode'] = 0
|
||||
mock_cmd = MagicMock(return_value=ret)
|
||||
|
Loading…
Reference in New Issue
Block a user