From 57024a8461a5834fb3f4fd48f02460c7a0e4643a Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 20 Mar 2013 21:09:15 -0500 Subject: [PATCH] Rename pkg.available_version to pkg.latest_version See https://github.com/saltstack/salt/issues/4163#issuecomment-15211619 All refs have been updated, and each pkg provider now has available_version as a function reference pointing to latest_version. Sphinx docs also updated so that the available_version function reference is hidden in the docs. --- doc/ref/modules/all/salt.modules.apt.rst | 3 ++- doc/ref/modules/all/salt.modules.brew.rst | 1 + doc/ref/modules/all/salt.modules.ebuild.rst | 3 ++- doc/ref/modules/all/salt.modules.freebsdpkg.rst | 3 ++- doc/ref/modules/all/salt.modules.openbsdpkg.rst | 3 ++- doc/ref/modules/all/salt.modules.pacman.rst | 3 ++- doc/ref/modules/all/salt.modules.pkgng.rst | 3 ++- doc/ref/modules/all/salt.modules.pkgutil.rst | 3 ++- doc/ref/modules/all/salt.modules.solarispkg.rst | 3 ++- doc/ref/modules/all/salt.modules.win_pkg.rst | 1 + doc/ref/modules/all/salt.modules.yumpkg.rst | 1 + doc/ref/modules/all/salt.modules.yumpkg5.rst | 3 ++- doc/ref/modules/all/salt.modules.zypper.rst | 2 +- doc/topics/development/package_providers.rst | 8 ++++---- salt/modules/apt.py | 13 ++++++++----- salt/modules/brew.py | 9 ++++++--- salt/modules/ebuild.py | 11 +++++++---- salt/modules/freebsdpkg.py | 9 ++++++--- salt/modules/openbsdpkg.py | 7 +++++-- salt/modules/pacman.py | 11 +++++++---- salt/modules/pkgng.py | 7 +++++-- salt/modules/pkgutil.py | 7 +++++-- salt/modules/solarispkg.py | 11 +++++++---- salt/modules/win_pkg.py | 9 ++++++--- salt/modules/yumpkg.py | 13 ++++++++----- salt/modules/yumpkg5.py | 13 ++++++++----- salt/modules/zypper.py | 11 +++++++---- salt/states/pkg.py | 6 +++--- 28 files changed, 114 insertions(+), 63 deletions(-) diff --git a/doc/ref/modules/all/salt.modules.apt.rst b/doc/ref/modules/all/salt.modules.apt.rst index a6dfdd4313..bd014031e6 100644 --- a/doc/ref/modules/all/salt.modules.apt.rst +++ b/doc/ref/modules/all/salt.modules.apt.rst @@ -3,4 +3,5 @@ salt.modules.apt ================ .. automodule:: salt.modules.apt - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.brew.rst b/doc/ref/modules/all/salt.modules.brew.rst index 2feeca0eb3..47447bc6fd 100644 --- a/doc/ref/modules/all/salt.modules.brew.rst +++ b/doc/ref/modules/all/salt.modules.brew.rst @@ -4,3 +4,4 @@ salt.modules.brew .. automodule:: salt.modules.brew :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.ebuild.rst b/doc/ref/modules/all/salt.modules.ebuild.rst index 6a8eb300e4..268f7d13b2 100644 --- a/doc/ref/modules/all/salt.modules.ebuild.rst +++ b/doc/ref/modules/all/salt.modules.ebuild.rst @@ -3,4 +3,5 @@ salt.modules.ebuild =================== .. automodule:: salt.modules.ebuild - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.freebsdpkg.rst b/doc/ref/modules/all/salt.modules.freebsdpkg.rst index dae3690adc..9c84aaedd4 100644 --- a/doc/ref/modules/all/salt.modules.freebsdpkg.rst +++ b/doc/ref/modules/all/salt.modules.freebsdpkg.rst @@ -3,4 +3,5 @@ salt.modules.freebsdpkg ======================= .. automodule:: salt.modules.freebsdpkg - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.openbsdpkg.rst b/doc/ref/modules/all/salt.modules.openbsdpkg.rst index 573664bb4f..c2238e0716 100644 --- a/doc/ref/modules/all/salt.modules.openbsdpkg.rst +++ b/doc/ref/modules/all/salt.modules.openbsdpkg.rst @@ -3,4 +3,5 @@ salt.modules.openbsdpkg ======================= .. automodule:: salt.modules.openbsdpkg - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.pacman.rst b/doc/ref/modules/all/salt.modules.pacman.rst index eaba6e7caf..e4bb036ae4 100644 --- a/doc/ref/modules/all/salt.modules.pacman.rst +++ b/doc/ref/modules/all/salt.modules.pacman.rst @@ -3,4 +3,5 @@ salt.modules.pacman =================== .. automodule:: salt.modules.pacman - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.pkgng.rst b/doc/ref/modules/all/salt.modules.pkgng.rst index 0c1357b2a7..19cc8de63c 100644 --- a/doc/ref/modules/all/salt.modules.pkgng.rst +++ b/doc/ref/modules/all/salt.modules.pkgng.rst @@ -3,4 +3,5 @@ salt.modules.pkgng ================== .. automodule:: salt.modules.pkgng - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.pkgutil.rst b/doc/ref/modules/all/salt.modules.pkgutil.rst index 65087101f8..156b00c2e2 100644 --- a/doc/ref/modules/all/salt.modules.pkgutil.rst +++ b/doc/ref/modules/all/salt.modules.pkgutil.rst @@ -3,4 +3,5 @@ salt.modules.pkgutil ==================== .. automodule:: salt.modules.pkgutil - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.solarispkg.rst b/doc/ref/modules/all/salt.modules.solarispkg.rst index 10d8c30577..0a0043d3ec 100644 --- a/doc/ref/modules/all/salt.modules.solarispkg.rst +++ b/doc/ref/modules/all/salt.modules.solarispkg.rst @@ -3,4 +3,5 @@ salt.modules.solarispkg ======================= .. automodule:: salt.modules.solarispkg - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.win_pkg.rst b/doc/ref/modules/all/salt.modules.win_pkg.rst index 5fa01dcab2..c615e37725 100644 --- a/doc/ref/modules/all/salt.modules.win_pkg.rst +++ b/doc/ref/modules/all/salt.modules.win_pkg.rst @@ -4,3 +4,4 @@ salt.modules.win_pkg .. automodule:: salt.modules.win_pkg :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.yumpkg.rst b/doc/ref/modules/all/salt.modules.yumpkg.rst index fe052e5fa3..79bd278ce0 100644 --- a/doc/ref/modules/all/salt.modules.yumpkg.rst +++ b/doc/ref/modules/all/salt.modules.yumpkg.rst @@ -9,3 +9,4 @@ salt.modules.yumpkg .. automodule:: salt.modules.yumpkg :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.yumpkg5.rst b/doc/ref/modules/all/salt.modules.yumpkg5.rst index 03b7c1308f..210f7e1c5c 100644 --- a/doc/ref/modules/all/salt.modules.yumpkg5.rst +++ b/doc/ref/modules/all/salt.modules.yumpkg5.rst @@ -3,4 +3,5 @@ salt.modules.yumpkg5 ==================== .. automodule:: salt.modules.yumpkg5 - :members: \ No newline at end of file + :members: + :exclude-members: available_version diff --git a/doc/ref/modules/all/salt.modules.zypper.rst b/doc/ref/modules/all/salt.modules.zypper.rst index fdb1582f5f..1a79096730 100644 --- a/doc/ref/modules/all/salt.modules.zypper.rst +++ b/doc/ref/modules/all/salt.modules.zypper.rst @@ -4,4 +4,4 @@ salt.modules.zypper .. automodule:: salt.modules.zypper :members: - :exclude-members: list_updates + :exclude-members: list_updates, available_version diff --git a/doc/topics/development/package_providers.rst b/doc/topics/development/package_providers.rst index edae00c8d0..82ebba1a76 100644 --- a/doc/topics/development/package_providers.rst +++ b/doc/topics/development/package_providers.rst @@ -45,8 +45,8 @@ data: 'bar': '5.6.7-8'} -available_version -^^^^^^^^^^^^^^^^^ +latest_version +^^^^^^^^^^^^^^ Accepts an arbitrary number of arguments. Each argument is a package name. The return value for a package will be an empty string if the package is not found @@ -69,7 +69,7 @@ still work, to preserve backwards compatibility with older versions of Salt. version ^^^^^^^ -Like ``available_version``, accepts an arbitrary number of arguments and +Like ``latest_version``, accepts an arbitrary number of arguments and returns a string if a single package name was passed, or a dict of name/value pairs if more than one was passed. The only difference is that the return values are the currently-installed versions of whatever packages are passed. If @@ -83,7 +83,7 @@ Deprecated and destined to be removed. For now, should just do the following: .. code-block:: python - return __salt__['pkg.available_version'](name) != '' + return __salt__['pkg.latest_version'](name) != '' install diff --git a/salt/modules/apt.py b/salt/modules/apt.py index 8847c186ca..982de9d051 100644 --- a/salt/modules/apt.py +++ b/salt/modules/apt.py @@ -103,7 +103,7 @@ def _get_repo(**kwargs): return '' -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -116,9 +116,9 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version fromrepo=unstable - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version fromrepo=unstable + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -156,6 +156,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def version(*names, **kwargs): ''' @@ -573,7 +576,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def perform_cmp(pkg1='', pkg2=''): diff --git a/salt/modules/brew.py b/salt/modules/brew.py index 3bd933f377..690fa28a91 100644 --- a/salt/modules/brew.py +++ b/salt/modules/brew.py @@ -56,7 +56,7 @@ def version(*names, **kwargs): return __salt__['pkg_resource.version'](*names, **kwargs) -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation @@ -66,8 +66,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version + salt '*' pkg.latest_version + salt '*' pkg.latest_version ''' if len(names) <= 1: return '' @@ -77,6 +77,9 @@ def available_version(*names, **kwargs): ret[name] = '' return ret +# available_version is being deprecated +available_version = latest_version + def remove(pkgs, **kwargs): ''' diff --git a/salt/modules/ebuild.py b/salt/modules/ebuild.py index 4a16f9220e..49dbe0fde9 100644 --- a/salt/modules/ebuild.py +++ b/salt/modules/ebuild.py @@ -59,7 +59,7 @@ def _cpv_to_version(cpv): return str(cpv[len(_cpv_to_name(cpv) + '-'):]) -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -70,8 +70,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -90,6 +90,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def _get_upgradable(): ''' @@ -142,7 +145,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def version(*names, **kwargs): diff --git a/salt/modules/freebsdpkg.py b/salt/modules/freebsdpkg.py index e2a18db07f..f418bd23d9 100644 --- a/salt/modules/freebsdpkg.py +++ b/salt/modules/freebsdpkg.py @@ -48,7 +48,7 @@ def search(pkg_name): return {"Results": res} -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -59,8 +59,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... ''' ret = {} @@ -106,6 +106,9 @@ def available_version(*names, **kwargs): return ret +# available_version is being deprecated +available_version = latest_version + def version(*names, **kwargs): ''' diff --git a/salt/modules/openbsdpkg.py b/salt/modules/openbsdpkg.py index 541fd0a29e..3bac1cd1f1 100644 --- a/salt/modules/openbsdpkg.py +++ b/salt/modules/openbsdpkg.py @@ -81,13 +81,13 @@ def list_pkgs(versions_as_list=False): return _format_pkgs(_get_pkgs(), versions_as_list=versions_as_list) -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' The available version of the package in the repository CLI Example:: - salt '*' pkg.available_version + salt '*' pkg.latest_version ''' ret = {} # Initialize the dict with empty strings @@ -104,6 +104,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def version(*names, **kwargs): ''' diff --git a/salt/modules/pacman.py b/salt/modules/pacman.py index 9c5cb0f054..cdf7ad2929 100644 --- a/salt/modules/pacman.py +++ b/salt/modules/pacman.py @@ -28,7 +28,7 @@ def _list_removed(old, new): return pkgs -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -39,8 +39,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -67,6 +67,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' @@ -76,7 +79,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def list_upgrades(): diff --git a/salt/modules/pkgng.py b/salt/modules/pkgng.py index 6279c71e10..540fa66c2b 100644 --- a/salt/modules/pkgng.py +++ b/salt/modules/pkgng.py @@ -56,19 +56,22 @@ def version(): return __salt__['cmd.run'](cmd) -def available_version(pkg_name, **kwargs): +def latest_version(pkg_name, **kwargs): ''' The available version of the package in the repository CLI Example:: - salt '*' pkgng.available_version + salt '*' pkgng.latest_version ''' cmd = 'pkg info {0}'.format(pkg_name) out = __salt__['cmd.run'](cmd).split() return out[0] +# available_version is being deprecated +available_version = latest_version + def update_package_site(new_url): ''' diff --git a/salt/modules/pkgutil.py b/salt/modules/pkgutil.py index 873a77524e..84582ec667 100644 --- a/salt/modules/pkgutil.py +++ b/salt/modules/pkgutil.py @@ -153,13 +153,13 @@ def version(*names, **kwargs): return __salt__['pkg_resource.version'](*names, **kwargs) -def available_version(name, **kwargs): +def latest_version(name, **kwargs): ''' The available version of the package in the repository CLI Example:: - salt '*' pkgutil.available_version CSWpython + salt '*' pkgutil.latest_version CSWpython ''' cmd = '/opt/csw/bin/pkgutil -a --parse {0}'.format(name) namever = __salt__['cmd.run_stdout'](cmd).split()[2].strip() @@ -167,6 +167,9 @@ def available_version(name, **kwargs): return namever return '' +# available_version is being deprecated +available_version = latest_version + def install(name, refresh=False, version=None, **kwargs): ''' diff --git a/salt/modules/solarispkg.py b/salt/modules/solarispkg.py index 698006b5c6..78b7651d2f 100644 --- a/salt/modules/solarispkg.py +++ b/salt/modules/solarispkg.py @@ -102,7 +102,7 @@ def list_pkgs(versions_as_list=False): return ret -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -113,8 +113,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... NOTE: As package repositories are not presently supported for Solaris pkgadd, this function will always return an empty string for a given @@ -131,6 +131,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' @@ -140,7 +143,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def version(*names, **kwargs): diff --git a/salt/modules/win_pkg.py b/salt/modules/win_pkg.py index 97f663ea1e..bacd61af4e 100644 --- a/salt/modules/win_pkg.py +++ b/salt/modules/win_pkg.py @@ -47,7 +47,7 @@ def _list_removed(old, new): return pkgs -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -58,8 +58,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... ''' if len(names) == 0: @@ -95,6 +95,9 @@ def available_version(*names, **kwargs): ret[name] = candidate return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index b94f6a51bd..253f764a5c 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -162,7 +162,7 @@ def _set_repo_options(yumbase, **kwargs): return e -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -175,9 +175,9 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version fromrepo=epel-testing - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version fromrepo=epel-testing + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -210,6 +210,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' @@ -219,7 +222,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def version(*names, **kwargs): diff --git a/salt/modules/yumpkg5.py b/salt/modules/yumpkg5.py index 6ade865452..7dca5bc694 100644 --- a/salt/modules/yumpkg5.py +++ b/salt/modules/yumpkg5.py @@ -92,7 +92,7 @@ def _get_repo_options(**kwargs): return repo_arg -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -105,9 +105,9 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version fromrepo=epel-testing - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version fromrepo=epel-testing + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -127,6 +127,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' @@ -136,7 +139,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def version(*names, **kwargs): diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 04e663095b..46994ea1b5 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -65,7 +65,7 @@ def list_upgrades(refresh=True): list_updates = list_upgrades -def available_version(*names, **kwargs): +def latest_version(*names, **kwargs): ''' Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of @@ -76,8 +76,8 @@ def available_version(*names, **kwargs): CLI Example:: - salt '*' pkg.available_version - salt '*' pkg.available_version ... + salt '*' pkg.latest_version + salt '*' pkg.latest_version ... ''' if len(names) == 0: return '' @@ -91,6 +91,9 @@ def available_version(*names, **kwargs): return ret[names[0]] return ret +# available_version is being deprecated +available_version = latest_version + def upgrade_available(name): ''' @@ -100,7 +103,7 @@ def upgrade_available(name): salt '*' pkg.upgrade_available ''' - return available_version(name) != '' + return latest_version(name) != '' def version(*names, **kwargs): diff --git a/salt/states/pkg.py b/salt/states/pkg.py index 9cd5069f45..95ec036de6 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -466,9 +466,9 @@ def latest( desired_pkgs = [name] cur = __salt__['pkg.version'](*desired_pkgs) - avail = __salt__['pkg.available_version'](*desired_pkgs, - fromrepo=fromrepo, - **kwargs) + avail = __salt__['pkg.latest_version'](*desired_pkgs, + fromrepo=fromrepo, + **kwargs) # Repack the cur/avail data if only a single package is being checked if isinstance(cur, basestring):