def run(self): """Start the RHSM DBus service. And also some related tasks, such as setting RHSM log levels. """ # start the rhsm.service # - this is blocking, but as we are effectively running in a thread # it should not be an issue # - if the return code is non-zero, return False immediately rc = util.start_service(self.RHSM_SYSTEMD_UNIT_NAME) if rc: log.warning( "subscription: RHSM systemd service failed to start with error code: %s", rc) return False # create a temporary proxy to set the log levels rhsm_config_proxy = RHSM.get_proxy(RHSM_CONFIG) # set RHSM log levels to debug # - otherwise the RHSM log output is not usable for debugging subscription issues log.debug("subscription: setting RHSM log level to DEBUG") rhsm_config_proxy.Set("logging.default_log_level", get_variant(Str, "DEBUG"), "") # all seems fine log.debug("subscription: RHSM service start successfully.") return True
def setup(self, ksdata): timezone_proxy = TIMEZONE.get_proxy() services_proxy = SERVICES.get_proxy() enabled_services = services_proxy.EnabledServices disabled_services = services_proxy.DisabledServices # do not install and use NTP package if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList: if util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.stop_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to stop NTP service") if NTP_SERVICE not in disabled_services: disabled_services.append(NTP_SERVICE) services_proxy.SetDisabledServices(disabled_services) # install and use NTP package else: if not util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.start_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to start NTP service") self.packages.append(NTP_PACKAGE) if not NTP_SERVICE in enabled_services and \ not NTP_SERVICE in disabled_services: enabled_services.append(NTP_SERVICE) services_proxy.SetEnabledServices(enabled_services)
def setup(self, ksdata): timezone_proxy = TIMEZONE.get_proxy() services_proxy = SERVICES.get_proxy() enabled_services = services_proxy.EnabledServices disabled_services = services_proxy.DisabledServices # do not install and use NTP package if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList: if util.service_running( NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.stop_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to stop NTP service") if NTP_SERVICE not in disabled_services: disabled_services.append(NTP_SERVICE) services_proxy.SetDisabledServices(disabled_services) # install and use NTP package else: if not util.service_running( NTP_SERVICE) and conf.system.can_set_time_synchronization: ret = util.start_service(NTP_SERVICE) if ret != 0: timezone_log.error("Failed to start NTP service") self.packages.append(NTP_PACKAGE) if not NTP_SERVICE in enabled_services and \ not NTP_SERVICE in disabled_services: enabled_services.append(NTP_SERVICE) services_proxy.SetEnabledServices(enabled_services)
def run(self): """Start the RHSM DBus service. And also some related tasks, such as setting RHSM log levels. """ # Due to a RHSM bug (https://bugzilla.redhat.com/show_bug.cgi?id=1700441) # we need to create /etc/yum.repos.d if it does not exist. Otherwise RHSM # will not create the expected redhat.repo file inside it. if not os.path.exists("/etc/yum.repos.d"): log.debug("subscription: creating /etc/yum.repos.d") os.mkdir("/etc/yum.repos.d") # start the rhsm.service # - this is blocking, but as we are effectively running in a thread # it should not be an issue # - if the return code is non-zero, return False immediately rc = util.start_service(self.RHSM_SYSTEMD_UNIT_NAME) if rc: log.warning( "subscription: RHSM systemd service failed to start with error code: %s", rc) return False # create a temporary proxy to set the log levels rhsm_config_proxy = RHSM.get_proxy(RHSM_CONFIG, interface_name=RHSM_CONFIG) # set RHSM log levels to debug # - otherwise the RHSM log output is not usable for debugging subscription issues log.debug("subscription: setting RHSM log level to DEBUG") rhsm_config_proxy.Set("logging.default_log_level", get_variant(Str, "DEBUG"), "") # all seems fine log.debug("subscription: RHSM service start successfully.") return True
def start_chronyd(): """Start the NTP daemon chronyd. Set up NTP servers and start NTP daemon if not requested otherwise. """ if not conf.system.can_set_time_synchronization: log.debug("Skip the time synchronization.") return timezone_proxy = TIMEZONE.get_proxy() enabled = timezone_proxy.NTPEnabled servers = TimeSourceData.from_structure_list(timezone_proxy.TimeSources) if servers: ntp.save_servers_to_config(servers) if enabled: util.start_service("chronyd")
def on_ntp_switched(self, switch, *args): if switch.get_active(): #turned ON if not conf.system.can_set_time_synchronization: #cannot touch runtime system, not much to do here return if not self._network_module.proxy.Connected: self._show_no_network_warning() switch.set_active(False) return else: self.clear_info() working_server = self._config_dialog.working_server if working_server is None: self._show_no_ntp_server_warning() else: #we need a one-time sync here, because chronyd would not change #the time as drastically as we need ntp.one_time_sync_async(working_server) ret = util.start_service(NTP_SERVICE) self._set_date_time_setting_sensitive(False) #if starting chronyd failed and chronyd is not running, #set switch back to OFF if (ret != 0) and not util.service_running(NTP_SERVICE): switch.set_active(False) else: #turned OFF if not conf.system.can_set_time_synchronization: #cannot touch runtime system, nothing to do here return self._set_date_time_setting_sensitive(True) ret = util.stop_service(NTP_SERVICE) #if stopping chronyd failed and chronyd is running, #set switch back to ON if (ret != 0) and util.service_running(NTP_SERVICE): switch.set_active(True) self.clear_info()
def on_ntp_switched(self, switch, *args): if switch.get_active(): #turned ON if not conf.system.can_set_time_synchronization: #cannot touch runtime system, not much to do here return if not self._network_module.Connected: self._show_no_network_warning() switch.set_active(False) return else: self.clear_info() working_server = self._get_working_server() if working_server is None: self._show_no_ntp_server_warning() ret = util.start_service(NTP_SERVICE) self._set_date_time_setting_sensitive(False) #if starting chronyd failed and chronyd is not running, #set switch back to OFF if (ret != 0) and not util.service_running(NTP_SERVICE): switch.set_active(False) else: #turned OFF if not conf.system.can_set_time_synchronization: #cannot touch runtime system, nothing to do here return self._set_date_time_setting_sensitive(True) ret = util.stop_service(NTP_SERVICE) #if stopping chronyd failed and chronyd is running, #set switch back to ON if (ret != 0) and util.service_running(NTP_SERVICE): switch.set_active(True) self.clear_info()
# start geolocation lookup if enabled if geoloc.geoloc.enabled: geoloc.geoloc.refresh() # setup ntp servers and start NTP daemon if not requested otherwise if conf.system.can_set_time_synchronization: kickstart_ntpservers = timezone_proxy.NTPServers if kickstart_ntpservers: pools, servers = ntp.internal_to_pools_and_servers( kickstart_ntpservers) ntp.save_servers_to_config(pools, servers) if timezone_proxy.NTPEnabled: util.start_service("chronyd") # Finish the initialization of the setup on boot action. # This should be done sooner and somewhere else once it is possible. from pyanaconda.core.constants import SETUP_ON_BOOT_DEFAULT, SETUP_ON_BOOT_ENABLED from pyanaconda.modules.common.constants.services import SERVICES services_proxy = SERVICES.get_proxy() if services_proxy.SetupOnBoot == SETUP_ON_BOOT_DEFAULT: if not flags.automatedInstall: # Enable by default for interactive installations. services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_ENABLED) # Create pre-install snapshots from pykickstart.constants import SNAPSHOT_WHEN_PRE_INSTALL from pyanaconda.kickstart import check_kickstart_error
geoloc.init_geolocation(geoloc_option=opts.geoloc, options_override=opts.geoloc_use_with_ks) # start geolocation lookup if enabled if geoloc.geoloc.enabled: geoloc.geoloc.refresh() # setup ntp servers and start NTP daemon if not requested otherwise if conf.system.can_set_time_synchronization: kickstart_ntpservers = timezone_proxy.NTPServers if kickstart_ntpservers: pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntpservers) ntp.save_servers_to_config(pools, servers) if timezone_proxy.NTPEnabled: util.start_service("chronyd") # Finish the initialization of the setup on boot action. # This should be done sooner and somewhere else once it is possible. from pyanaconda.core.constants import SETUP_ON_BOOT_DEFAULT, SETUP_ON_BOOT_DISABLED from pyanaconda.modules.common.constants.services import SERVICES services_proxy = SERVICES.get_proxy() if services_proxy.SetupOnBoot == SETUP_ON_BOOT_DEFAULT: if flags.automatedInstall: # Disable by default after kickstart installations. services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_DISABLED) # Create pre-install snapshots from pykickstart.constants import SNAPSHOT_WHEN_PRE_INSTALL from pyanaconda.kickstart import check_kickstart_error