Exemplo n.º 1
0
def posttrans_hook(conduit):
    """
    Update product ID certificates.
    """
    # register rpm name for yum history recording
    # yum on 5.7 doesn't have this method, so check for it
    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")

    try:
        init_dep_injection()
    except ImportError as e:
        conduit.error(3, str(e))
        return

    logutil.init_logger_for_yum()
    # If a tool (it's, e.g., Anaconda and Mock) manages a chroot via
    # 'yum --installroot', we must update certificates in that directory.
    chroot(conduit.getConf().installroot)
    try:
        pm = YumProductManager(conduit._base)
        pm.update_all()
        conduit.info(3, 'Installed products updated.')
    except Exception as e:
        conduit.error(3, str(e))
Exemplo n.º 2
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._done = False
        init_dep_injection()

        facts = inj.require(inj.FACTS)
        backend = managergui.Backend()

        self._registergui = registergui.RegisterScreen(backend, facts,
                                                       callbacks=[self.finished])
        self._action_area = self.builder.get_object("RHSMSpokeWindow-action_area1")
        self._register_box = self._registergui.dialog_vbox6

        # FIXME: close_window handling is kind of a mess. Standlone subman gui,
        # the firstboot screens, and initial-setup need it to do different
        # things. Potentially a 'Im done with this window now' signal, with
        # each attaching different handlers.
        self._registergui.close_window_callback = self._close_window_callback

        # we have a ref to _register_box, but need to remove it from
        # the regustergui.window (a GtkDialog), and add it to the main
        # box in the action area of our initial-setup screen.
        self._registergui.window.remove(self._register_box)
        self._action_area.pack_end(self._register_box, True, True, 0)
        self._action_area.show()
        self._register_box.show_all()
        self._registergui.initialize()
Exemplo n.º 3
0
    def ListInstalledProducts(self,
                              filter_string,
                              proxy_options,
                              locale,
                              sender=None):

        # We reinitialize dependency injection here for following reason. When new product
        # certificate is installed (or existing is removed), then this change is not propagated to
        # CertSorter and other caches. Calling installed_products.list(filter_string) without
        # reinitialization of dependency injection would return old (cached) list of installed
        # products.
        init_dep_injection()

        filter_string = dbus_utils.dbus_to_python(filter_string,
                                                  expected_type=str)
        proxy_options = dbus_utils.dbus_to_python(proxy_options,
                                                  expected_type=dict)
        locale = dbus_utils.dbus_to_python(locale, expected_type=str)

        Locale.set(locale)

        cp = self.build_uep(proxy_options, proxy_only=True)

        installed_products = InstalledProducts(cp)

        try:
            response = installed_products.list(filter_string)
        except Exception as err:
            raise dbus.DBusException(str(err))

        return json.dumps(response)
Exemplo n.º 4
0
def posttrans_hook(conduit):
    """
    Update product ID certificates.
    """
    # register rpm name for yum history recording
    # yum on 5.7 doesn't have this method, so check for it
    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")

    try:
        init_dep_injection()
    except ImportError as e:
        conduit.error(3, str(e))
        return

    logutil.init_logger_for_yum()
    # If a tool (it's, e.g., Anaconda and Mock) manages a chroot via
    # 'yum --installroot', we must update certificates in that directory.
    chroot(conduit.getConf().installroot)
    try:
        pm = YumProductManager(conduit._base)
        pm.update_all()
        conduit.info(3, 'Installed products updated.')
    except Exception as e:
        conduit.error(3, str(e))
Exemplo n.º 5
0
    def ListInstalledProducts(self, filter_string, proxy_options, locale, sender=None):

        # We reinitialize dependency injection here for following reason. When new product
        # certificate is installed (or existing is removed), then this change is not propagated to
        # CertSorter and other caches. Calling installed_products.list(filter_string) without
        # reinitialization of dependency injection would return old (cached) list of installed
        # products.
        init_dep_injection()

        filter_string = dbus_utils.dbus_to_python(filter_string, expected_type=str)
        proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict)
        locale = dbus_utils.dbus_to_python(locale, expected_type=str)

        Locale.set(locale)

        cp = self.build_uep(proxy_options, proxy_only=True)

        installed_products = InstalledProducts(cp)

        try:
            response = installed_products.list(filter_string)
        except Exception as err:
            raise dbus.DBusException(str(err))

        return json.dumps(response)
Exemplo n.º 6
0
def postconfig_hook(conduit):
    """ update """
    # register rpm name for yum history recording"
    # yum on 5.7 doesn't have this method, so check for it

    from subscription_manager import logutil
    logutil.init_logger_for_yum()

    from subscription_manager.injectioninit import init_dep_injection
    init_dep_injection()

    # If a tool (it's, e.g., Mock) manages a chroot via 'yum --installroot',
    # we must update entitlements in that directory.
    chroot(conduit.getConf().installroot)

    cfg = config.initConfig()
    cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")
    try:
        update(conduit, cache_only)
        warnOrGiveUsageMessage(conduit)
        warnExpired(conduit)
    except Exception, e:
        conduit.error(2, str(e))
Exemplo n.º 7
0
    def func_wrapper(*args, **kwargs):
        global injected
        if not injected:
            logutil.init_logger()

            from subscription_manager.injectioninit import init_dep_injection
            init_dep_injection()
            injected = True
        return func(*args, **kwargs)
Exemplo n.º 8
0
    def func_wrapper(*args, **kwargs):
        global injected
        if not injected:
            logutil.init_logger()

            from subscription_manager.injectioninit import init_dep_injection
            init_dep_injection()
            injected = True
        return func(*args, **kwargs)
def config_hook(conduit):
    """
    This is the first hook of this yum plugin that is triggered by yum. So we do initialization
    of all stuff that is necessary by other hooks
    :param conduit: Reference on conduit object used by yum plugin API
    :return: None
    """
    logutil.init_logger_for_yum()
    init_dep_injection()

    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")
Exemplo n.º 10
0
    def run(self):
        try:
            init_dep_injection()
        except ImportError as e:
            logger.error(str(e))
            return

        command = packageprofilelib.PackageProfileActionCommand()
        report = command.perform(force_upload=self.opts.force_upload)

        if report._status == 0:
            print(_("No updates performed. See /var/log/rhsm/rhsm.log for more information."))
        else:
            print(report)
Exemplo n.º 11
0
def posttrans_hook(conduit):
    """
    Update product ID certificates.
    """
    # register rpm name for yum history recording
    # yum on 5.7 doesn't have this method, so check for it
    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")

    try:
        init_dep_injection()
    except ImportError, e:
        conduit.error(3, str(e))
        return
Exemplo n.º 12
0
def posttrans_hook(conduit):
    """
    Update product ID certificates.
    """
    # register rpm name for yum history recording
    # yum on 5.7 doesn't have this method, so check for it
    if hasattr(conduit, "registerPackageName"):
        conduit.registerPackageName("subscription-manager")

    try:
        init_dep_injection()
    except ImportError, e:
        conduit.error(3, str(e))
        return
Exemplo n.º 13
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._done = False

        init_dep_injection()

        facts = inj.require(inj.FACTS)

        backend = managergui.Backend()
        self.info = registergui.RegisterInfo()
        self.info.connect('notify::register-status',
                          self._on_register_status_change)
        self._status = self.info.get_property('register-status')

        self.register_widget = registergui.RegisterWidget(
            backend, facts, reg_info=self.info, parent_window=self.main_window)

        self.register_box = self.builder.get_object("register_box")
        self.button_box = self.builder.get_object('navigation_button_box')
        self.proceed_button = self.builder.get_object('proceed_button')
        self.back_button = self.builder.get_object('back_button')

        self.register_box.pack_start(self.register_widget.register_widget,
                                     True, True, 0)

        # Hook up the nav buttons in the gui
        # TODO: add a 'start over'?
        self.proceed_button.connect('clicked',
                                    self._on_register_button_clicked)
        self.back_button.connect('clicked', self._on_back_button_clicked)

        # initial-setup will likely
        self.register_widget.connect('finished', self._on_finished)
        self.register_widget.connect('register-finished',
                                     self._on_register_finished)
        self.register_widget.connect('register-error', self._on_register_error)
        self.register_widget.connect('register-message',
                                     self._on_register_message)

        # update the 'next/register button on page change'
        self.register_widget.connect('notify::register-button-label',
                                     self._on_register_button_label_change)

        self.register_widget.connect('notify::screen-ready',
                                     self._on_register_screen_ready_change)

        self.register_box.show_all()
        self.register_widget.initialize()
        self.back_button.set_sensitive(False)
def main():
    from subscription_manager.plugins import PluginManager
    from subscription_manager import injectioninit
    from subscription_manager.plugins import UpdateContentConduit
    from subscription_manager.model.ent_cert import EntitlementDirEntitlementSource
    from subscription_manager.content_action_client import ContentPluginActionReport

    plugin_manager = PluginManager()
    plugin_class = plugin_manager.get_plugins()['container_content.ContainerContentPlugin']
    plugin = plugin_class()
    injectioninit.init_dep_injection()
    ent_source = EntitlementDirEntitlementSource()
    reports = ContentPluginActionReport()
    conduit = UpdateContentConduit(plugin_class, reports=reports, ent_source=ent_source)
    plugin.update_content_hook(conduit)
Exemplo n.º 15
0
    def run(self):
        try:
            init_dep_injection()
        except ImportError as e:
            logger.error(str(e))
            return

        command = packageprofilelib.PackageProfileActionCommand()
        report = command.perform(force_upload=self.opts.force_upload)

        if report._status == 0:
            print(
                _("No updates performed. See /var/log/rhsm/rhsm.log for more information."
                  ))
        else:
            print(report)
Exemplo n.º 16
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._done = False

        init_dep_injection()

        backend = managergui.Backend()
        self.info = registergui.RegisterInfo()
        self.info.connect('notify::register-status', self._on_register_status_change)
        self._status = self.info.get_property('register-status')

        self.register_widget = registergui.RegisterWidget(
            backend,
            reg_info=self.info,
            parent_window=self.main_window
        )

        self.register_box = self.builder.get_object("register_box")
        self.button_box = self.builder.get_object('navigation_button_box')
        self.proceed_button = self.builder.get_object('proceed_button')
        self.back_button = self.builder.get_object('back_button')

        self.register_box.pack_start(self.register_widget.register_widget,
                                     True, True, 0)

        # Hook up the nav buttons in the gui
        # TODO: add a 'start over'?
        self.proceed_button.connect('clicked', self._on_register_button_clicked)
        self.back_button.connect('clicked', self._on_back_button_clicked)

        # initial-setup will likely
        self.register_widget.connect('finished', self._on_finished)
        self.register_widget.connect('register-finished', self._on_register_finished)
        self.register_widget.connect('register-error', self._on_register_error)
        self.register_widget.connect('register-message', self._on_register_message)

        # update the 'next/register button on page change'
        self.register_widget.connect('notify::register-button-label',
                                       self._on_register_button_label_change)

        self.register_widget.connect('notify::screen-ready',
                                     self._on_register_screen_ready_change)

        self.register_box.show_all()
        self.register_widget.initialize()
        self.back_button.set_sensitive(False)
Exemplo n.º 17
0
def main():
    from subscription_manager.plugins import PluginManager
    from subscription_manager import injectioninit
    from subscription_manager.plugins import UpdateContentConduit
    from subscription_manager.model.ent_cert import EntitlementDirEntitlementSource
    from subscription_manager.content_action_client import ContentPluginActionReport

    plugin_manager = PluginManager()
    plugin_class = plugin_manager.get_plugins(
    )["container_content.ContainerContentPlugin"]
    plugin = plugin_class()
    injectioninit.init_dep_injection()
    ent_source = EntitlementDirEntitlementSource()
    reports = ContentPluginActionReport()
    conduit = UpdateContentConduit(plugin_class,
                                   reports=reports,
                                   ent_source=ent_source)
    plugin.update_content_hook(conduit)
    def config(self):
        """ update """
        logutil.init_logger_for_yum()

        init_dep_injection()

        chroot(self.base.conf.installroot)

        cfg = config.initConfig()
        cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

        try:
            if os.getuid() == 0:
                self._update(cache_only)
                self._warnOrGiveUsageMessage()
            else:
                logger.info(_('Not root, Subscription Management repositories not updated'))
            self._warnExpired()
        except Exception as e:
            logger.error(str(e))
Exemplo n.º 19
0
    def config(self):
        """ update """
        logutil.init_logger_for_yum()

        init_dep_injection()

        chroot(self.base.conf.installroot)

        cfg = config.initConfig()
        cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

        try:
            if os.getuid() == 0:
                self._update(cache_only)
                self._warnOrGiveUsageMessage()
            else:
                logger.info(_('Not root, Subscription Management repositories not updated'))
            self._warnExpired()
        except Exception as e:
            logger.error(str(e))
Exemplo n.º 20
0
    def _config(self):
        """ update """
        logutil.init_logger_for_yum()

        init_dep_injection()

        chroot(self.base.conf.installroot)

        cfg = config.get_config_parser()
        cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

        try:
            if os.getuid() == 0:
                # Try to update entitlement certificates and redhat.repo file
                self._update(cache_only)
            else:
                logger.info(_('Not root, Subscription Management repositories not updated'))
            self._warn_or_give_usage_message()
            self._warn_expired()
        except Exception as e:
            log.error(str(e))
Exemplo n.º 21
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._done = False

        init_dep_injection()

        facts = inj.require(inj.FACTS)

        backend = managergui.Backend()
        self.info = registergui.RegisterInfo()

        self.register_widget = registergui.RegisterWidget(
            backend, facts, reg_info=self.info, parent_window=self.main_window
        )

        self.register_box = self.builder.get_object("register_box")
        self.button_box = self.builder.get_object("navigation_button_box")
        self.proceed_button = self.builder.get_object("proceed_button")
        self.back_button = self.builder.get_object("back_button")

        self.register_box.pack_start(self.register_widget.register_widget, True, True, 0)

        # Hook up the nav buttons in the gui
        # TODO: add a 'start over'?
        self.proceed_button.connect("clicked", self._on_register_button_clicked)
        self.back_button.connect("clicked", self._on_back_button_clicked)

        # initial-setup will likely
        self.register_widget.connect("finished", self._on_finished)
        self.register_widget.connect("register-finished", self._on_register_finished)
        self.register_widget.connect("register-error", self._on_register_error)
        self.register_widget.connect("register-message", self._on_register_message)

        # update the 'next/register button on page change'
        self.register_widget.connect("notify::register-button-label", self._on_register_button_label_change)

        self.register_widget.connect("notify::screen-ready", self._on_register_screen_ready_change)

        self.register_box.show_all()
        self.register_widget.initialize()
Exemplo n.º 22
0
    def transaction(self):
        """
        Update product ID certificates.
        """
        if len(self.base.transaction) == 0:
            # nothing to update after empty transaction
            return

        try:
            init_dep_injection()
        except ImportError as e:
            logger.error(str(e))
            return

        logutil.init_logger_for_yum()
        chroot(self.base.conf.installroot)
        try:
            pm = DnfProductManager(self.base)
            pm.update_all()
            logger.info(_('Installed products updated.'))
        except Exception as e:
            logger.error(str(e))
def config_hook(conduit):
    """ update """
    # register rpm name for yum history recording"
    # yum on 5.7 doesn't have this method, so check for it

    from subscription_manager import logutil
    logutil.init_logger_for_yum()

    from subscription_manager.injectioninit import init_dep_injection
    init_dep_injection()

    cfg = config.initConfig()
    cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")
    try:
        update(conduit, cache_only)
        warnOrGiveUsageMessage(conduit)
        warnExpired(conduit)
    except Exception, e:
        conduit.error(2, str(e))
Exemplo n.º 24
0
    def transaction(self):
        """
        Update product ID certificates.
        """
        if len(self.base.transaction) == 0:
            # nothing to update after empty transaction
            return

        try:
            init_dep_injection()
        except ImportError as e:
            logger.error(str(e))
            return

        logutil.init_logger_for_yum()
        chroot(self.base.conf.installroot)
        try:
            pm = DnfProductManager(self.base)
            pm.update_all(self._enabled_repos)
            logger.info(_('Installed products updated.'))
        except Exception as e:
            logger.error(str(e))
def config_hook(conduit):
    """ update """
    # register rpm name for yum history recording"
    # yum on 5.7 doesn't have this method, so check for it

    from subscription_manager import logutil
    logutil.init_logger_for_yum()

    from subscription_manager.injectioninit import init_dep_injection
    init_dep_injection()

    cfg = config.initConfig()
    cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))

    if hasattr(conduit, 'registerPackageName'):
        conduit.registerPackageName("subscription-manager")
    try:
        update(conduit, cache_only)
        warnOrGiveUsageMessage(conduit)
        warnExpired(conduit)
    except Exception, e:
        conduit.error(2, str(e))
Exemplo n.º 26
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._done = False
        init_dep_injection()

        facts = inj.require(inj.FACTS)

        backend = managergui.Backend()

        self.register_widget = registergui.RegisterWidget(backend, facts,
                                                          parent_window=self.main_window)

        self.register_box = self.builder.get_object("register_box")
        self.button_box = self.builder.get_object('navigation_button_box')
        self.proceed_button = self.builder.get_object('proceed_button')
        self.cancel_button = self.builder.get_object('cancel_button')

        self.register_box.pack_start(self.register_widget.register_widget,
                                     True, True, 0)

        # Hook up the nav buttons in the gui
        # TODO: add a 'start over'?
        self.proceed_button.connect('clicked', self._on_register_button_clicked)
        self.cancel_button.connect('clicked', self.cancel)

        # initial-setup will likely
        self.register_widget.connect('finished', self.finished)
        self.register_widget.connect('register-finished', self.register_finished)
        self.register_widget.connect('register-error', self._on_register_error)

        # update the 'next/register button on page change'
        self.register_widget.connect('notify::register-button-label',
                                       self._on_register_button_label_change)

        self.register_box.show_all()
        self.register_widget.initialize()
Exemplo n.º 27
0
    sys.setdefaultencoding('utf-8')

import signal
import logging
import dbus.mainloop.glib

from subscription_manager import logutil
import subscription_manager.injection as inj

from rhsm import connection, config

from subscription_manager import ga_loader
ga_loader.init_ga()

from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()

from subscription_manager import action_client
from subscription_manager import managerlib
from subscription_manager.identity import ConsumerIdentity
from subscription_manager.i18n_optparse import OptionParser, \
    WrappedIndentedHelpFormatter, USAGE
from optparse import SUPPRESS_HELP
from subscription_manager.utils import generate_correlation_id

from subscription_manager.i18n import ugettext as _


def exit_on_signal(_signumber, _stackframe):
    sys.exit(0)
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#

import sys
sys.path.append("/usr/share/rhsm")

import logging

from rhsm import connection

from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()

from subscription_manager import certmgr
from subscription_manager import logutil
from subscription_manager import managerlib
from subscription_manager.certlib import ConsumerIdentity
from subscription_manager.i18n_optparse import OptionParser, \
    WrappedIndentedHelpFormatter, USAGE

import gettext
_ = gettext.gettext


def main(options, log):
    if not ConsumerIdentity.existsAndValid():
        log.error('Either the consumer is not registered or the certificates' +