def _create_async_pool(self): provide(inj.CP_PROVIDER, stubs.StubCPProvider()) inj.provide(inj.PROD_DIR, stubs.StubProductDirectory()) inj.provide(inj.ENT_DIR, stubs.StubEntitlementDirectory()) inj.provide(inj.CERT_SORTER, stubs.StubCertSorter()) self.pool_stash = \ managerlib.PoolStash() self.ap = async_utils.AsyncPool(self.pool_stash) # add a timeout and a idle handler self.idle = ga_GObject.idle_add(self.ap.refresh, datetime.date.today(), self.idle_callback) self.timer = ga_GObject.timeout_add(50, self.idle_callback) self.mainloop = ga_GObject.MainLoop()
def main(): log.info("rhsmd started") parser = OptionParser(usage=USAGE, formatter=WrappedIndentedHelpFormatter()) parser.add_option("-d", "--debug", dest="debug", help="Display debug messages", action="store_true", default=False) parser.add_option( "-k", "--keep-alive", dest="keep_alive", help="Stay running (don't shut down after the first dbus call)", action="store_true", default=False) parser.add_option("-s", "--syslog", dest="syslog", help="Run standalone and log result to syslog", action="store_true", default=False) parser.add_option( "-f", "--force-signal", dest="force_signal", help="Force firing of a signal " + "(valid, expired, warning, partial, classic or registration_required)") parser.add_option( "-i", "--immediate", dest="immediate", action="store_true", default=False, help="Fire forced signal immediately (requires --force-signal)") options, args = parser.parse_args() force_signal = parse_force_signal(options.force_signal) if options.immediate and force_signal is None: print_error("--immediate must be used with --force-signal") sys.exit(-2) global enable_debug enable_debug = options.debug # short-circuit dbus initialization if options.syslog: log.info("logging subscription status to syslog") status = check_status(force_signal) if status == RHSM_EXPIRED: log_syslog( syslog.LOG_NOTICE, "This system is missing one or more subscriptions. " + "Please run subscription-manager for more information.") elif status == RHSM_PARTIALLY_VALID: log_syslog( syslog.LOG_NOTICE, "This system is missing one or more subscriptions " + "to fully cover its products. " + "Please run subscription-manager for more information.") elif status == RHSM_WARNING: log_syslog( syslog.LOG_NOTICE, "This system's subscriptions are about to expire. " + "Please run subscription-manager for more information.") elif status == RHN_CLASSIC: log_syslog(syslog.LOG_INFO, get_branding().RHSMD_REGISTERED_TO_OTHER) elif status == RHSM_REGISTRATION_REQUIRED: log_syslog( syslog.LOG_NOTICE, "In order for Subscription Manager to provide your " + "system with updates, your system must be registered " + "with the Customer Portal. Please enter your Red Hat " + "login to ensure your system is up-to-date.") # Return an exit code for the program. having valid entitlements is # good, so it gets an exit status of 0. return status # we are not running from cron here, so unset the excepthook # though, we may be running from cli, or as a dbus activation. For # cli, we should traceback. For dbus, we should try to log it and # raise dbus exception? sys.excepthook = sys.__excepthook__ system_bus = dbus.SystemBus() loop = ga_GObject.MainLoop() checker = StatusChecker(system_bus, options.keep_alive, force_signal, loop) if options.immediate: checker.entitlement_status_changed(force_signal) loop.run()