Merge pull request #47563 from rallytime/bp-47224

Back-port #47224 to 2018.3
This commit is contained in:
Nicole Thomas 2018-05-10 12:18:06 -04:00 committed by GitHub
commit e3ee7053fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -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
@ -634,6 +636,8 @@ def scrub(zpool, stop=False, pause=False):
.. note::
Pause is only available on recent versions of ZFS.
If both ``pause`` and ``stop`` are ``True``, then ``stop`` will
win.
@ -706,6 +710,9 @@ def create(zpool, *vdevs, **kwargs):
.. versionadded:: 2018.3.0
.. warning:
This is only available on illumos and Solaris
CLI Examples:
.. code-block:: bash

View file

@ -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)