diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-04-11 22:51:34 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-04-11 22:51:34 -0700 |
commit | b2e5494ad17f6542175a815f0c2ac87c482a5137 (patch) | |
tree | 682e41ba0f90f73bc61f5f3496fe9933e2c47b90 /lib/chef | |
parent | 415c82c77489b25000ef22040168eee33950ebaf (diff) | |
download | chef-b2e5494ad17f6542175a815f0c2ac87c482a5137.tar.gz |
fix for enable/disable repo ordering
use one array, shove them in the array in order, read them out
and apply them...
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/package/yum/python_helper.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/package/yum/yum_helper.py | 27 |
2 files changed, 18 insertions, 17 deletions
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb index df21a9f091..0a09e12c3d 100644 --- a/lib/chef/provider/package/yum/python_helper.rb +++ b/lib/chef/provider/package/yum/python_helper.rb @@ -93,14 +93,14 @@ class Chef options.each_with_object({}) do |opt, h| if opt =~ /--enablerepo=(.+)/ $1.split(",").each do |repo| - h["enablerepos"] ||= [] - h["enablerepos"].push(repo) + h["repos"] ||= [] + h["repos"].push( { "enable" => repo } ) end end if opt =~ /--disablerepo=(.+)/ $1.split(",").each do |repo| - h["disablerepos"] ||= [] - h["disablerepos"].push(repo) + h["repos"] ||= [] + h["repos"].push( { "disable" => repo } ) end end end diff --git a/lib/chef/provider/package/yum/yum_helper.py b/lib/chef/provider/package/yum/yum_helper.py index 72e1177e8e..090b101316 100644 --- a/lib/chef/provider/package/yum/yum_helper.py +++ b/lib/chef/provider/package/yum/yum_helper.py @@ -83,11 +83,13 @@ def query(command): enabled_repos = base.repos.listEnabled() # Handle any repocontrols passed in with our options - if 'enablerepos' in command: - base.repos.enableRepo(*command['enablerepos']) - if 'disablerepos' in command: - base.repos.disableRepo(*command['disablerepos']) + if 'repos' in command: + for repo in command['repos']: + if 'enable' in repo: + base.repos.enableRepo(repo['enable']) + if 'disable' in repo: + base.repos.disableRepo(repo['disable']) args = { 'name': command['provides'] } do_nevra = False @@ -148,15 +150,14 @@ def query(command): outpipe.flush() # Reset any repos we were passed in enablerepo/disablerepo to the original state in enabled_repos - if 'enablerepos' in command: - for repo in command['enablerepos']: - if base.repos.getRepo(repo) not in enabled_repos: - base.repos.disableRepo(repo) - - if 'disablerepos' in command: - for repo in command['disablerepos']: - if base.repos.getRepo(repo) in enabled_repos: - base.repos.enableRepo(repo) + if 'repos' in command: + for repo in command['repos']: + if 'enable' in repo: + if base.repos.getRepo(repo['enable']) not in enabled_repos: + base.repos.disableRepo(repo['enable']) + if 'disable' in repo: + if base.repos.getRepo(repo['disable']) in enabled_repos: + base.repos.enableRepo(repo['disable']) # the design of this helper is that it should try to be 'brittle' and fail hard and exit in order # to keep process tables clean. additional error handling should probably be added to the retry loop |