Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1713626: Option disable_system_repos didn't work with DNF; ENT-1350 #2090

Merged
merged 1 commit into from May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions etc-conf/plugin/subscription-manager.conf
@@ -1,6 +1,6 @@
[main]
enabled=1

# Setting disable_system_repos to 1, disables all system repositories
# (= repositories which are not mangaged by subscription-manager will NOT be used)
# When following option is set to 1, then all repositories defined outside redhat.repo will be disabled
# every time subscription-manager plugin is triggered by dnf or yum
disable_system_repos=0
29 changes: 29 additions & 0 deletions src/dnf-plugins/subscription-manager.py
Expand Up @@ -16,6 +16,7 @@
#

import os
import six

from subscription_manager import injection as inj
from subscription_manager.action_client import ProfileActionClient
Expand All @@ -31,6 +32,11 @@
from dnfpluginscore import _, logger
import dnf

if six.PY3:
from configparser import ConfigParser
else:
from ConfigParser import ConfigParser

expired_warning = _("""
*** WARNING ***
The subscription for following product(s) has expired:
Expand Down Expand Up @@ -77,6 +83,29 @@ def _config(self):
except Exception as e:
logger.error(str(e))

def config(self):
super(SubscriptionManager, self).config()
config_path = self.base.conf.pluginconfpath[0]

default_config_file = os.path.join(config_path, self.name + ".conf")

if os.path.isfile(default_config_file):
plugin_config = ConfigParser()
plugin_config.read(default_config_file)

if plugin_config.has_option('main', 'disable_system_repos'):
disable_system_repos = plugin_config.get('main', 'disable_system_repos')
if disable_system_repos:
disable_count = 0
for repo in self.base.repos.iter_enabled():
if os.path.basename(repo.repofile) != 'redhat.repo':
repo.disable()
disable_count += 1
print(_('subscription-manager plugin disabled %d system repositories with respect of configuration in /etc/dnf/plugins/subscription-manager.conf') % (
disable_count))
else:
logger.debug('Configuration file %s does not exist.' % default_config_file)

def _update(self, cache_only):
""" update entitlement certificates """
logger.info(_('Updating Subscription Management repositories.'))
Expand Down