def _emit_changes_in_default_configuration(): try: def log_event(msg): logger.info(msg) add_event(AGENT_NAME, op=WALAEventOperation.ConfigurationChange, message=msg) def log_if_int_changed_from_default(name, current): default = conf.get_int_default_value(name) if default != current: log_event( "{0} changed from its default: {1}. New value: {2}". format(name, default, current)) def log_if_op_disabled(name, value): if not value: log_event( "{0} is set to False, not processing the operation". format(name)) log_if_int_changed_from_default("Extensions.GoalStatePeriod", conf.get_goal_state_period()) log_if_op_disabled("OS.EnableFirewall", conf.enable_firewall()) log_if_op_disabled("Extensions.Enabled", conf.get_extensions_enabled()) if conf.enable_firewall(): log_if_int_changed_from_default( "OS.EnableFirewallPeriod", conf.get_enable_firewall_period()) if conf.get_lib_dir() != "/var/lib/waagent": log_event("lib dir is in an unexpected location: {0}".format( conf.get_lib_dir())) except Exception as e: logger.warn("Failed to log changes in configuration: {0}", ustr(e))
def _emit_changes_in_default_configuration(): try: def log_if_int_changed_from_default(name, current): default = conf.get_int_default_value(name) if default != current: msg = "{0} changed from its default; new value: {1}".format( name, current) logger.info(msg) add_event(AGENT_NAME, op=WALAEventOperation.ConfigurationChange, message=msg) log_if_int_changed_from_default("Extensions.GoalStatePeriod", conf.get_goal_state_period()) if not conf.enable_firewall(): message = "OS.EnableFirewall is False" logger.info(message) add_event(AGENT_NAME, op=WALAEventOperation.ConfigurationChange, message=message) else: log_if_int_changed_from_default( "OS.EnableFirewallPeriod", conf.get_enable_firewall_period()) if conf.get_lib_dir() != "/var/lib/waagent": message = "lib dir is in an unexpected location: {0}".format( conf.get_lib_dir()) logger.info(message) add_event(AGENT_NAME, op=WALAEventOperation.ConfigurationChange, message=message) except Exception as e: logger.warn("Failed to log changes in configuration: {0}", ustr(e))
def __init__(self, osutil, protocol): super(EnableFirewall, self).__init__(conf.get_enable_firewall_period()) self._osutil = osutil self._protocol = protocol self._try_remove_legacy_firewall_rule = False
def __init__(self): self.osutil = get_osutil() self.dhcp_handler = get_dhcp_handler() self.protocol_util = None self._protocol = None self.stopped = True self.hostname = None self.dhcp_id_list = [] self.server_thread = None self.dhcp_warning_enabled = True self.archiver = StateArchiver(conf.get_lib_dir()) self._reset_firewall_rules = False self._periodic_operations = [ PeriodicOperation("_remove_persistent_net_rules", self._remove_persistent_net_rules_period, conf.get_remove_persistent_net_rules_period()), PeriodicOperation("_monitor_dhcp_client_restart", self._monitor_dhcp_client_restart, conf.get_monitor_dhcp_client_restart_period()), PeriodicOperation("_cleanup_goal_state_history", self._cleanup_goal_state_history, conf.get_goal_state_history_cleanup_period()) ] if conf.enable_firewall(): self._periodic_operations.append(PeriodicOperation("_enable_firewall", self._enable_firewall, conf.get_enable_firewall_period())) if conf.get_root_device_scsi_timeout() is not None: self._periodic_operations.append(PeriodicOperation("_set_root_device_scsi_timeout", self._set_root_device_scsi_timeout, conf.get_root_device_scsi_timeout_period())) if conf.get_monitor_hostname(): self._periodic_operations.append(PeriodicOperation("_monitor_hostname", self._monitor_hostname_changes, conf.get_monitor_hostname_period()))