.. versionadded:: 2016.3.0

    Enables all supported features on the given pool

    zpool : string
        Optional storage pool, applies to all otherwize

    version : int
        Version to upgrade to, if unspecified upgrade to the highest possible

    .. warning::
        Once this is done, the pool will no longer be accessible on systems that do not
        support feature flags. See zpool-features(5) for details on compatibility with
        systems that support feature flags, but do not support all features enabled on the pool.

    CLI Example:

    .. code-block:: bash

        salt '*' zpool.upgrade myzpool

def upgrade(zpool=None, version=None):
    '''
    .. versionadded:: 2016.3.0

    Enables all supported features on the given pool

    zpool : string
        Optional storage pool, applies to all otherwize

    version : int
        Version to upgrade to, if unspecified upgrade to the highest possible

    .. warning::
        Once this is done, the pool will no longer be accessible on systems that do not
        support feature flags. See zpool-features(5) for details on compatibility with
        systems that support feature flags, but do not support all features enabled on the pool.

    CLI Example:

    .. code-block:: bash

        salt '*' zpool.upgrade myzpool

    '''
    ## Configure pool
    # NOTE: initialize the defaults
    flags = []
    opts = {}

    # NOTE: set extra config
    if version:
        opts['-V'] = version
    if not zpool:
        flags.append('-a')

    ## Upgrade pool
    res = __salt__['cmd.run_all'](
        __utils__['zfs.zpool_command'](
            command='upgrade',
            flags=flags,
            opts=opts,
            target=zpool,
        ),
        python_shell=False,
    )

    return __utils__['zfs.parse_command_result'](res, 'upgraded')