From f8fffbb6c4aa8d6f9fcea570381dbbc2c6553216 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sat, 26 Jan 2013 19:28:34 -0600 Subject: [PATCH] Check "version" kwarg after parse_targets --- salt/modules/yumpkg.py | 18 +++++++++--------- salt/modules/yumpkg5.py | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 4ee2a46202..1ad3a94cc6 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -326,15 +326,6 @@ def install(name=None, {'': {'old': '', 'new': ''}} ''' - # This allows modules to specify the version in a kwarg, like the other - # package modules - if kwargs.get('version'): - if pkgs is None and sources is None: - name = '{0}-{1}'.format(name, kwargs.get('version')) - else: - log.warning('"version" parameter will be ignored for muliple ' - 'package targets') - # Catch both boolean input from state and string input from CLI if refresh is True or str(refresh).lower() == 'true': refresh_db() @@ -355,6 +346,15 @@ def install(name=None, disablerepo = kwargs.get('disablerepo', '') enablerepo = kwargs.get('enablerepo', '') repo = kwargs.get('repo', '') + version = kwargs.get('version') + + if version: + if pkgs is None and sources is None: + # Allow "version" to work for single package target + pkg_params = {name: version} + else: + log.warning('"version" parameter will be ignored for muliple ' + 'package targets') # Support old "repo" argument if not fromrepo and repo: diff --git a/salt/modules/yumpkg5.py b/salt/modules/yumpkg5.py index f69966eaa0..457844cea9 100644 --- a/salt/modules/yumpkg5.py +++ b/salt/modules/yumpkg5.py @@ -252,15 +252,6 @@ def install(name=None, {'': {'old': '', 'new': ''}} ''' - # This allows modules to specify the version in a kwarg, like the other - # package modules - if kwargs.get('version'): - if pkgs is None and sources is None: - name = '{0}-{1}'.format(name, kwargs.get('version')) - else: - log.warning('"version" parameter will be ignored for muliple ' - 'package targets') - # Catch both boolean input from state and string input from CLI if refresh is True or str(refresh).lower() == 'true': refresh_db() @@ -275,6 +266,15 @@ def install(name=None, disablerepo = kwargs.get('disablerepo', '') enablerepo = kwargs.get('enablerepo', '') repo = kwargs.get('repo', '') + version = kwargs.get('version') + + if version: + if pkgs is None and sources is None: + # Allow "version" to work for single package target + pkg_params = {name: version} + else: + log.warning('"version" parameter will be ignored for muliple ' + 'package targets') # Support old "repo" argument if not fromrepo and repo: @@ -292,7 +292,7 @@ def install(name=None, log.info('Enabling repo "{0}"'.format(enablerepo)) repo_arg += '--enablerepo="{0}" '.format(enablerepo) - if pkg_type == 'repository' and pkgs: + if pkg_type == 'repository': targets = [] for param, version in pkg_params.iteritems(): if version is None: