Merge branch 'develop' of git://github.com/saltstack/salt into develop

This commit is contained in:
Pedro Algarvio 2012-08-14 00:48:43 +01:00
commit 30c7f190c7
11 changed files with 81 additions and 78 deletions

View File

@ -1,4 +1,5 @@
include AUTHORS
include HACKING.rst
include LICENSE
include README.rst
include requirements.txt

View File

@ -31,17 +31,18 @@ class Master(parsers.MasterOptionParser):
self.parse_args()
try:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
], self.config['user'],
permissive=self.config['permissive_pki_access'])
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
], self.config['user'],
permissive=self.config['permissive_pki_access'])
except OSError, err:
sys.exit(err.errno)
@ -76,14 +77,15 @@ class Minion(parsers.MinionOptionParser):
self.parse_args()
try:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
os.path.dirname(self.config['log_file']),
], self.config['user'],
permissive=self.config['permissive_pki_access'])
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
os.path.dirname(self.config['log_file']),
], self.config['user'],
permissive=self.config['permissive_pki_access'])
except OSError, err:
sys.exit(err.errno)
@ -117,13 +119,14 @@ class Syndic(parsers.SyndicOptionParser):
'''
self.parse_args()
try:
verify_env([
self.config['pki_dir'], self.config['cachedir'],
os.path.dirname(self.config['log_file']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
self.config['pki_dir'], self.config['cachedir'],
os.path.dirname(self.config['log_file']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
except OSError, err:
sys.exit(err.errno)

View File

@ -162,15 +162,16 @@ class SaltKey(parsers.SaltKeyOptionParser):
'''
self.parse_args()
verify_env([
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
os.path.dirname(self.config['key_logfile']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
os.path.dirname(self.config['key_logfile']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
self.setup_logfile_logger()
@ -189,14 +190,15 @@ class SaltCall(parsers.SaltCallOptionParser):
'''
self.parse_args()
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
os.path.dirname(self.config['log_file'])
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
os.path.dirname(self.config['log_file'])
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
caller = salt.cli.caller.Caller(self.config)

View File

@ -177,6 +177,7 @@ class LocalClient(object):
continue
if comps[0] not in grains:
minions.remove(id_)
continue
if isinstance(grains[comps[0]], list):
# We are matching a single component to a single list member
found = False

View File

@ -193,6 +193,7 @@ def minion_config(path):
'state_verbose': False,
'acceptance_wait_time': 10,
'dns_check': True,
'verify_env': True,
'grains': {},
'permissive_pki_access': False,
'default_include': 'minion.d/*.conf',
@ -284,6 +285,7 @@ def master_config(path):
'nodegroups': {},
'cython_enable': False,
'key_logfile': '/var/log/salt/key',
'verify_env': True,
'permissive_pki_access': False,
'default_include': 'master.d/*.conf',
}

View File

@ -28,15 +28,6 @@ def __virtual__():
return 'network'
def _sanitize_host(host):
'''
Sanitize host string.
'''
return ''.join([
c for c in host[0:255] if c in (ascii_letters + digits + '.-')
])
def _cidr_to_ipv4_netmask(cidr_bits):
'''
Returns an IPv4 netmask

View File

@ -27,7 +27,7 @@ def _sanitize_host(host):
'''
Sanitize host string.
'''
return "".join([
return ''.join([
c for c in host[0:255] if c in (ascii_letters + digits + '.-')
])

View File

@ -242,12 +242,6 @@ class Pillar(object):
for item in data:
if isinstance(item, string_types):
matches[env].append(item)
ext_matches = self.client.ext_nodes()
for env in ext_matches:
if env in matches:
matches[env] = list(set(ext_matches[env]).union(matches[env]))
else:
matches[env] = ext_matches[env]
return matches
def render_pstate(self, sls, env, mods):

View File

@ -800,7 +800,6 @@ class State(object):
Call a state directly with the low data structure, verify data
before processing.
'''
self.module_refresh(data)
errors = self.verify_data(data)
if errors:
ret = {
@ -814,6 +813,7 @@ class State(object):
ret['__run_num__'] = self.__run_num
self.__run_num += 1
format_log(ret)
self.module_refresh(data)
return ret
log.info(
@ -844,6 +844,7 @@ class State(object):
format_log(ret)
if 'provider' in data:
self.load_modules()
self.module_refresh(data)
return ret
def call_chunks(self, chunks):

View File

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
"""
'''
salt.utils.parsers
~~~~~~~~~~~~~~~~~~
:copyright: © 2012 UfSoft.org - :email:`Pedro Algarvio (pedro@algarvio.me)`
:license: Apache 2.0, see LICENSE for more details.
"""
'''
import os
import sys
@ -32,8 +32,8 @@ class MixInMeta(type):
instance = super(MixInMeta, cls).__new__(cls, name, bases, attrs)
if not hasattr(instance, '_mixin_setup'):
raise RuntimeError(
"Don't subclass {0} in {1} if you're not going to use it as a "
"salt parser mix-in.".format(cls.__name__, name)
'Don\'t subclass {0} in {1} if you\'re not going to use it as a '
'salt parser mix-in.'.format(cls.__name__, name)
)
return instance
@ -71,18 +71,18 @@ class OptionParserMeta(MixInMeta):
class OptionParser(optparse.OptionParser):
usage = "%prog"
usage = '%prog'
epilog = ("You can find additional help about %prog issuing 'man %prog' "
"or on http://docs.saltstack.org/en/latest/index.html")
epilog = ('You can find additional help about %prog issuing "man %prog" '
'or on http://docs.saltstack.org/en/latest/index.html')
description = None
# Private attributes
_mixin_prio_ = 100
def __init__(self, *args, **kwargs):
kwargs.setdefault("version", "%prog {0}".format(version.__version__))
kwargs.setdefault("usage", self.usage)
kwargs.setdefault('version', '%prog {0}'.format(version.__version__))
kwargs.setdefault('usage', self.usage)
if self.description:
kwargs.setdefault('description', self.description)
@ -91,8 +91,8 @@ class OptionParser(optparse.OptionParser):
optparse.OptionParser.__init__(self, *args, **kwargs)
if "%prog" in self.epilog:
self.epilog = self.epilog.replace("%prog", self.get_prog_name())
if '%prog' in self.epilog:
self.epilog = self.epilog.replace('%prog', self.get_prog_name())
def parse_args(self, args=None, values=None):
options, args = optparse.OptionParser.parse_args(self, args, values)
@ -104,7 +104,7 @@ class OptionParser(optparse.OptionParser):
# Gather and run the process_<option> functions in the proper order
process_option_funcs = []
for option_key in options.__dict__.keys():
process_option_func = getattr(self, "process_%s" % option_key, None)
process_option_func = getattr(self, 'process_%s' % option_key, None)
if process_option_func is not None:
process_option_funcs.append(process_option_func)
@ -112,7 +112,7 @@ class OptionParser(optparse.OptionParser):
try:
process_option_func()
except Exception, err:
self.error("Error while processing {0}: {1}".format(
self.error('Error while processing {0}: {1}'.format(
process_option_func, err
))
@ -122,7 +122,7 @@ class OptionParser(optparse.OptionParser):
if self.config.get('conf_file', None) is not None:
logging.getLogger(__name__).info(
"Loaded configuration file: %s", self.config['conf_file']
'Loaded configuration file: %s', self.config['conf_file']
)
# Retain the standard behaviour of optparse to return options and args
return options, args
@ -138,7 +138,7 @@ class OptionParser(optparse.OptionParser):
optparse.OptionParser._add_version_option(self)
self.add_option(
'--versions-report', action='store_true',
help="show program's dependencies version number and exit"
help='show program\'s dependencies version number and exit'
)
def print_versions_report(self, file=sys.stdout):
@ -151,9 +151,9 @@ class DeprecatedConfigMessage(object):
def print_config_warning(self, *args, **kwargs):
self.error(
"The '-c/--config' option is deprecated. You should now use "
"-c/--config-dir to point to a directory which holds all of "
"salt's configuration files.\n"
'The "-c/--config" option is deprecated. You should now use '
'-c/--config-dir to point to a directory which holds all of '
'salt\'s configuration files.\n'
)
class ConfigDirMixIn(DeprecatedConfigMessage):

View File

@ -1,5 +1,13 @@
import socket
def _sanitize_host(host):
'''
Sanitize host string.
'''
return ''.join([
c for c in host[0:255] if c in (ascii_letters + digits + '.-')
])
def isportopen(host, port):
'''
Return status of a port