Get default logging level and file from default opts dict

This commit is contained in:
Denys Havrysh 2016-10-27 12:53:06 +03:00
parent 580eca709b
commit 2065e8311c
3 changed files with 43 additions and 44 deletions

View file

@ -206,7 +206,7 @@ class CloudClient(object):
the kwargs
'''
# Let's start with the default salt cloud configuration
opts = salt.config.CLOUD_CONFIG_DEFAULTS.copy()
opts = salt.config.DEFAULT_CLOUD_OPTS.copy()
# Update it with the loaded configuration
opts.update(self.opts.copy())
# Reset some of the settings to sane values

View file

@ -144,19 +144,20 @@ VALID_OPTS = {
# Must also set master_sign_pubkey for this to work
'verify_master_pubkey_sign': bool,
# If verify_master_pubkey_sign is enabled, the signature is only verified, if the public-key of the master changes.
# If the signature should always be verified, this can be set to True.
# If verify_master_pubkey_sign is enabled, the signature is only verified, if the public-key of
# the master changes. If the signature should always be verified, this can be set to True.
'always_verify_signature': bool,
# The name of the file in the masters pki-directory that holds the pre-calculated signature of the masters public-key.
# The name of the file in the masters pki-directory that holds the pre-calculated signature of
# the masters public-key
'master_pubkey_signature': str,
# Instead of computing the signature for each auth-reply, use a pre-calculated signature.
# The master_pubkey_signature must also be set for this.
'master_use_pubkey_signature': bool,
# The key fingerprint of the higher-level master for the syndic to verify it is talking to the intended
# master
# The key fingerprint of the higher-level master for the syndic to verify it is talking to the
# intended master
'syndic_finger': str,
# The user under which the daemon should run
@ -432,8 +433,8 @@ VALID_OPTS = {
# have an event_return(event) function!
'event_return': str,
# The number of events to queue up in memory before pushing them down the pipe to an event returner
# specified by 'event_return'
# The number of events to queue up in memory before pushing them down the pipe to an event
# returner specified by 'event_return'
'event_return_queue': int,
# Only forward events to an event returner if it matches one of the tags in this list
@ -451,8 +452,8 @@ VALID_OPTS = {
# Used with the SECO range master tops system
'range_server': str,
# The tcp keepalive interval to set on TCP ports. This setting can be used to tune salt connectivity
# issues in messy network environments with misbehaving firewalls
# The tcp keepalive interval to set on TCP ports. This setting can be used to tune Salt
# connectivity issues in messy network environments with misbehaving firewalls
'tcp_keepalive': bool,
# Sets zeromq TCP keepalive idle. May be used to tune issues with minion disconnects
@ -675,7 +676,8 @@ VALID_OPTS = {
# index
'search_index_interval': int,
# A compound target definition. See: http://docs.saltstack.com/en/latest/topics/targeting/nodegroups.html
# A compound target definition.
# See: http://docs.saltstack.com/en/latest/topics/targeting/nodegroups.html
'nodegroups': dict,
# List-only nodegroups for salt-ssh. Each group must be formed as either a
@ -784,7 +786,8 @@ VALID_OPTS = {
'ioflo_period': float,
# Set ioflo to realtime. Useful only for testing/debugging to simulate many ioflo periods very quickly.
# Set ioflo to realtime. Useful only for testing/debugging to simulate many ioflo periods very
# quickly
'ioflo_realtime': bool,
# Location for ioflo logs
@ -842,14 +845,14 @@ VALID_OPTS = {
# If set, all minion exec module actions will be rerouted through sudo as this user
'sudo_user': str,
# HTTP request timeout in seconds. Applied for tornado http fetch functions like cp.get_url should be greater than
# overall download time.
# HTTP request timeout in seconds. Applied for tornado http fetch functions like cp.get_url
# should be greater than overall download time
'http_request_timeout': float,
# HTTP request max file content size.
'http_max_body': int,
# Delay in seconds before executing bootstrap (salt cloud)
# Delay in seconds before executing bootstrap (Salt Cloud)
'bootstrap_delay': int,
# If a proxymodule has a function called 'grains', then call it during
@ -857,7 +860,7 @@ VALID_OPTS = {
# dictionary. Otherwise it is assumed that the module calls the grains
# function in a custom way and returns the data elsewhere
#
# Default to False for 2016.3 and Carbon. Switch to True for Nitrogen
# Default to False for 2016.3 and Carbon. Switch to True for Nitrogen
'proxy_merge_grains_in_module': bool,
# Extra modules for Salt Thin
@ -1360,7 +1363,7 @@ DEFAULT_PROXY_MINION_OPTS = {
}
# ----- Salt Cloud Configuration Defaults ----------------------------------->
CLOUD_CONFIG_DEFAULTS = {
DEFAULT_CLOUD_OPTS = {
'verify_env': True,
'default_include': 'cloud.conf.d/*.conf',
# Global defaults
@ -1400,7 +1403,7 @@ DEFAULT_SPM_OPTS = {
'formula_path': '/srv/spm/salt',
'pillar_path': '/srv/spm/pillar',
'reactor_path': '/srv/spm/reactor',
'spm_logfile': '/var/log/salt/spm',
'spm_logfile': os.path.join(salt.syspaths.LOGS_DIR, 'spm'),
'default_include': 'spm.d/*.conf',
# spm_repos_config also includes a .d/ directory
'spm_repos_config': '/etc/salt/spm.repos',
@ -1924,7 +1927,7 @@ def cloud_config(path, env_var='SALT_CLOUD_CONFIG', defaults=None,
)
if defaults is None:
defaults = CLOUD_CONFIG_DEFAULTS
defaults = DEFAULT_CLOUD_OPTS
# Load cloud configuration from any default or provided includes
default_include = overrides.get(
@ -2134,7 +2137,7 @@ def apply_cloud_config(overrides, defaults=None):
Return a cloud config
'''
if defaults is None:
defaults = CLOUD_CONFIG_DEFAULTS
defaults = DEFAULT_CLOUD_OPTS
config = defaults.copy()
if overrides:

View file

@ -1668,7 +1668,7 @@ class MasterOptionParser(six.with_metaclass(OptionParserMeta,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'master')
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS['log_file']
_setup_mp_logging_listener_ = True
def setup_config(self):
@ -1684,7 +1684,7 @@ class MinionOptionParser(six.with_metaclass(OptionParserMeta, MasterOptionParser
# ConfigDirMixIn config filename attribute
_config_filename_ = 'minion'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'minion')
_default_logging_logfile_ = config.DEFAULT_MINION_OPTS['log_file']
_setup_mp_logging_listener_ = True
def setup_config(self):
@ -1710,7 +1710,7 @@ class ProxyMinionOptionParser(six.with_metaclass(OptionParserMeta,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'proxy'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'proxy')
_default_logging_logfile_ = config.DEFAULT_PROXY_MINION_OPTS['log_file']
def setup_config(self):
try:
@ -1719,7 +1719,8 @@ class ProxyMinionOptionParser(six.with_metaclass(OptionParserMeta,
minion_id = None
return config.minion_config(self.get_config_file_path(),
cache_minion_id=False, minion_id=minion_id)
cache_minion_id=False,
minion_id=minion_id)
class SyndicOptionParser(six.with_metaclass(OptionParserMeta,
@ -1739,7 +1740,8 @@ class SyndicOptionParser(six.with_metaclass(OptionParserMeta,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'master')
_default_logging_level_ = config.DEFAULT_MASTER_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS['syndic_log_file']
_setup_mp_logging_listener_ = True
def setup_config(self):
@ -1768,9 +1770,8 @@ class SaltCMDOptionParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_level_ = 'warning'
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'master')
_loglevel_config_setting_name_ = 'cli_salt_log_file'
_default_logging_level_ = config.DEFAULT_MASTER_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS['log_file']
try:
os.getcwd()
except OSError:
@ -2057,9 +2058,8 @@ class SaltCPOptionParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_level_ = 'warning'
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'master')
_loglevel_config_setting_name_ = 'cli_salt_cp_log_file'
_default_logging_level_ = config.DEFAULT_MASTER_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS['log_file']
def _mixin_after_parsed(self):
# salt-cp needs arguments
@ -2398,8 +2398,8 @@ class SaltCallOptionParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'minion'
# LogLevelMixIn attributes
_default_logging_level_ = 'info'
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'minion')
_default_logging_level_ = config.DEFAULT_MINION_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_MINION_OPTS['log_file']
def _mixin_setup(self):
self.add_option(
@ -2606,9 +2606,8 @@ class SaltRunOptionParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_level_ = 'warning'
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'master')
_loglevel_config_setting_name_ = 'cli_salt_run_log_file'
_default_logging_level_ = config.DEFAULT_MASTER_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_MASTER_OPTS['log_file']
def _mixin_setup(self):
self.add_option(
@ -2671,9 +2670,8 @@ class SaltSSHOptionParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_level_ = 'warning'
_default_logging_level_ = config.DEFAULT_MASTER_OPTS['log_level']
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'ssh')
_loglevel_config_setting_name_ = 'cli_salt_run_log_file'
def _mixin_setup(self):
self.add_option(
@ -2914,10 +2912,8 @@ class SaltCloudParser(six.with_metaclass(OptionParserMeta,
_config_filename_ = 'cloud'
# LogLevelMixIn attributes
_default_logging_level_ = 'info'
_logfile_config_setting_name_ = 'log_file'
_loglevel_config_setting_name_ = 'log_level_logfile'
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'cloud')
_default_logging_level_ = config.DEFAULT_CLOUD_OPTS['log_level']
_default_logging_logfile_ = config.DEFAULT_CLOUD_OPTS['log_file']
def print_versions_report(self, file=sys.stdout): # pylint: disable=redefined-builtin
print('\n'.join(version.versions_report(include_salt_cloud=True)),
@ -2967,7 +2963,7 @@ class SPMParser(six.with_metaclass(OptionParserMeta,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'spm'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'spm')
_default_logging_logfile_ = config.DEFAULT_SPM_OPTS['spm_logfile']
def _mixin_setup(self):
self.add_option(
@ -3012,7 +3008,7 @@ class SaltAPIParser(six.with_metaclass(OptionParserMeta,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'api')
_default_logging_logfile_ = config.DEFAULT_API_OPTS['logfile']
def setup_config(self):
return salt.config.api_config(self.get_config_file_path()) # pylint: disable=no-member