mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge branch '2015.8' into '2016.3'
No conflicts.
This commit is contained in:
commit
c12b9a5094
@ -49,8 +49,8 @@ Requisite Statements
|
||||
|
||||
.. note::
|
||||
|
||||
This document represents behavior exhibited by Salt requisites as of
|
||||
version 0.9.7 of Salt.
|
||||
The behavior of requisites changed in version 0.9.7 of Salt. This
|
||||
documentation applies to requisites in version 0.9.7 and later.
|
||||
|
||||
Often when setting up states any single action will require or depend on
|
||||
another action. Salt allows for the building of relationships between states
|
||||
|
@ -170,11 +170,11 @@ class SaltLogRecord(logging.LogRecord):
|
||||
# pylint: enable=E1321
|
||||
|
||||
|
||||
class SaltColorLogRecord(logging.LogRecord):
|
||||
class SaltColorLogRecord(SaltLogRecord):
|
||||
def __init__(self, *args, **kwargs):
|
||||
logging.LogRecord.__init__(self, *args, **kwargs)
|
||||
reset = TextFormat('reset')
|
||||
SaltLogRecord.__init__(self, *args, **kwargs)
|
||||
|
||||
reset = TextFormat('reset')
|
||||
clevel = LOG_COLORS['levels'].get(self.levelname, reset)
|
||||
cmsg = LOG_COLORS['msgs'].get(self.levelname, reset)
|
||||
|
||||
@ -188,7 +188,7 @@ class SaltColorLogRecord(logging.LogRecord):
|
||||
self.colorprocess = '%s[%5s]%s' % (LOG_COLORS['process'],
|
||||
self.process,
|
||||
reset)
|
||||
self.colormsg = '%s%s%s' % (cmsg, self.msg, reset)
|
||||
self.colormsg = '%s%s%s' % (cmsg, self.getMessage(), reset)
|
||||
# pylint: enable=E1321
|
||||
|
||||
|
||||
|
@ -172,9 +172,21 @@ def write_cron_file(user, path):
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cron.write_cron_file root /tmp/new_cron
|
||||
|
||||
.. versionchanged:: 2015.8.9
|
||||
|
||||
.. note::
|
||||
|
||||
Solaris and AIX require that `path` is readable by `user`
|
||||
'''
|
||||
return __salt__['cmd.retcode'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False) == 0
|
||||
appUser = __opts__['user']
|
||||
if __grains__.get('os_family') in ('Solaris', 'AIX') and appUser != user:
|
||||
return __salt__['cmd.retcode'](_get_cron_cmdstr(path, user),
|
||||
runas=user,
|
||||
python_shell=False) == 0
|
||||
else:
|
||||
return __salt__['cmd.retcode'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False) == 0
|
||||
|
||||
|
||||
def write_cron_file_verbose(user, path):
|
||||
@ -186,20 +198,42 @@ def write_cron_file_verbose(user, path):
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cron.write_cron_file_verbose root /tmp/new_cron
|
||||
|
||||
.. versionchanged:: 2015.8.9
|
||||
|
||||
.. note::
|
||||
|
||||
Solaris and AIX require that `path` is readable by `user`
|
||||
'''
|
||||
return __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False)
|
||||
appUser = __opts__['user']
|
||||
if __grains__.get('os_family') in ('Solaris', 'AIX') and appUser != user:
|
||||
return __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
runas=user,
|
||||
python_shell=False)
|
||||
else:
|
||||
return __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False)
|
||||
|
||||
|
||||
def _write_cron_lines(user, lines):
|
||||
'''
|
||||
Takes a list of lines to be committed to a user's crontab and writes it
|
||||
'''
|
||||
appUser = __opts__['user']
|
||||
path = salt.utils.mkstemp()
|
||||
with salt.utils.fopen(path, 'w+') as fp_:
|
||||
fp_.writelines(lines)
|
||||
ret = __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False)
|
||||
if __grains__.get('os_family') in ('Solaris', 'AIX') and appUser != user:
|
||||
# on solaris/aix we change to the user before executing the commands
|
||||
with salt.utils.fpopen(path, 'w+', uid=__salt__['file.user_to_uid'](user), mode=0o600) as fp_:
|
||||
fp_.writelines(lines)
|
||||
ret = __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
runas=user,
|
||||
python_shell=False)
|
||||
else:
|
||||
with salt.utils.fpopen(path, 'w+', mode=0o600) as fp_:
|
||||
fp_.writelines(lines)
|
||||
ret = __salt__['cmd.run_all'](_get_cron_cmdstr(path, user),
|
||||
python_shell=False)
|
||||
|
||||
os.remove(path)
|
||||
return ret
|
||||
|
||||
|
@ -198,10 +198,12 @@ class BotoSecgroupTestCase(TestCase):
|
||||
tests return of 'config' when given group name. get_config returns an OrderedDict.
|
||||
'''
|
||||
group_name = _random_group_name()
|
||||
ip_protocol = 'tcp'
|
||||
ip_protocol = u'tcp'
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
cidr_ip = '0.0.0.0/0'
|
||||
cidr_ip = u'0.0.0.0/0'
|
||||
rules_egress = [{'to_port': -1, 'from_port': -1, 'ip_protocol': u'-1', 'cidr_ip': u'0.0.0.0/0'}]
|
||||
|
||||
conn = boto.ec2.connect_to_region(region, **boto_conn_parameters)
|
||||
group = conn.create_security_group(name=group_name, description=group_name)
|
||||
group.authorize(ip_protocol=ip_protocol, from_port=from_port, to_port=to_port, cidr_ip=cidr_ip)
|
||||
@ -210,7 +212,7 @@ class BotoSecgroupTestCase(TestCase):
|
||||
('description', group.description), ('tags', {}),
|
||||
('rules', [{'to_port': to_port, 'from_port': from_port,
|
||||
'ip_protocol': ip_protocol, 'cidr_ip': cidr_ip}]),
|
||||
('rules_egress', [])])
|
||||
('rules_egress', rules_egress)])
|
||||
secgroup_get_config_result = boto_secgroup.get_config(group_id=group.id, **conn_parameters)
|
||||
self.assertEqual(expected_get_config_result, secgroup_get_config_result)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user