Merge branch '2016.11' into 'develop'

Conflicts:
  - requirements/dev_python27.txt
  - requirements/dev_python34.txt
This commit is contained in:
rallytime 2017-02-21 14:20:20 -07:00
commit c46f82c029
26 changed files with 232 additions and 134 deletions

View file

@ -41075,7 +41075,7 @@ The above command is equivalent to the following command at the CLI:
.sp
.nf
.ft C
salt \(aqhaproxy*\(aq state.apply haproxy.refresh_pool \(aqpillar={new_minion: minionid}\(aq
salt \(aqhaproxy*\(aq state.apply haproxy.refresh_pool pillar=\(aq{new_minion: minionid}\(aq
.ft P
.fi
.UNINDENT

View file

@ -495,7 +495,7 @@ The above command is equivalent to the following command at the CLI:
.. code-block:: bash
salt 'haproxy*' state.apply haproxy.refresh_pool 'pillar={new_minion: minionid}'
salt 'haproxy*' state.apply haproxy.refresh_pool pillar='{new_minion: minionid}'
This works with Orchestrate files as well:

View file

@ -232,7 +232,7 @@ Extended Changelog Courtesy of Todd Stansell (https://github.com/tjstansell/salt
- **ISSUE** `#23900`_: (*hashi825*) salt ubuntu network building issue 2015.5.0
| refs: `#23922`_
* b818f72 Merge pull request `#23922`_ from garethgreenaway/23900_2015_5_bonding_interface_fixes
* 0bba536 Fixing issue reported when using bonded interfaces on Ubuntu. Attributes should be bond-, but the code was attempting to split just on bond_. Fix accounts for both, but the debian_ip.py module will write out bond attributes with bond-
* 0bba536 Fixing issue reported when using bonded interfaces on Ubuntu. Attributes should be bond-, but the code was attempting to split just on ``bond_``. Fix accounts for both, but the debian_ip.py module will write out bond attributes with bond-
- **PR** `#23925`_: (*jpic*) Fixed wrong path in LXC cloud documentation
@ *2015-05-19T18:23:56Z*

View file

@ -113,7 +113,7 @@ Changes:
* bbd8260 Ignore Raspbian in service.py __virtual__ (`#32421`_)
* 690addf FreeBSD supports packages in format java/openjdk7 so the prior commit broke that functionality. Check freebsd/pkg`#1409`_ for more info.
* 690addf FreeBSD supports packages in format java/openjdk7 so the prior commit broke that functionality. Check ``freebsd/pkg#1409`` for more info.
- **PR** `#32399`_: (*amontalban*) Backport to fix `#28262`_ for 2015.5 as requested in PR `#32376`_
@ -289,6 +289,10 @@ Changes:
- **PR** `#30291`_: (*thegoodduke*) ipset: fix test=true & add comment for every entry
.. _`#23643`: https://github.com/saltstack/salt/issues/23643
.. _`#23714`: https://github.com/saltstack/salt/issues/23714
.. _`#28262`: https://github.com/saltstack/salt/issues/28262
.. _`#31369`: https://github.com/saltstack/salt/issues/31369
.. _`#24952`: https://github.com/saltstack/salt/pull/24952
.. _`#26170`: https://github.com/saltstack/salt/pull/26170
.. _`#26853`: https://github.com/saltstack/salt/pull/26853

View file

@ -2024,7 +2024,6 @@ Changes:
.. _`fix-24036`: https://github.com/saltstack/salt/issues/24036
.. _`fix-24272`: https://github.com/saltstack/salt/issues/24272
.. _`fix-24483`: https://github.com/saltstack/salt/issues/24483
.. _`fix-24484`: https://github.com/saltstack/salt/issues/24484
.. _`fix-24882`: https://github.com/saltstack/salt/issues/24882
.. _`fix-25192`: https://github.com/saltstack/salt/issues/25192
.. _`fix-25616`: https://github.com/saltstack/salt/issues/25616
@ -2032,11 +2031,7 @@ Changes:
.. _`#16049`: https://github.com/saltstack/salt/issues/16049
.. _`#16179`: https://github.com/saltstack/salt/issues/16179
.. _`#24334`: https://github.com/saltstack/salt/issues/24334
.. _`#24484`: https://github.com/saltstack/salt/issues/24484
.. _`#25562`: https://github.com/saltstack/salt/issues/25562
.. _`#25801`: https://github.com/saltstack/salt/issues/25801
.. _`#25998`: https://github.com/saltstack/salt/issues/25998
.. _`#26000`: https://github.com/saltstack/salt/pull/26000
.. _`#26155`: https://github.com/saltstack/salt/issues/26155
.. _`#26160`: https://github.com/saltstack/salt/pull/26160
.. _`#26161`: https://github.com/saltstack/salt/issues/26161

View file

@ -49,7 +49,7 @@ Changes:
- **PR** `#27469`_: (*twangboy*) Added quotes to version numbers example
- **PR** `#27467`_: (*cachedout*) file.managed: check contents_{pillar|grain} result
- **PR** `#27467`_: (*cachedout*) file.managed: check ``contents_{pillar|grain}`` result
- **PR** `#27419`_: (*rallytime*) Amend error log to include multiple tips for troubleshooting.
@ -328,6 +328,7 @@ Changes:
.. _`#26617`: https://github.com/saltstack/salt/pull/26617
.. _`#26618`: https://github.com/saltstack/salt/pull/26618
.. _`#26620`: https://github.com/saltstack/salt/pull/26620
.. _`#26628`: https://github.com/saltstack/salt/issues/26628
.. _`#26631`: https://github.com/saltstack/salt/pull/26631
.. _`#26636`: https://github.com/saltstack/salt/pull/26636
.. _`#26640`: https://github.com/saltstack/salt/pull/26640
@ -454,14 +455,17 @@ Changes:
.. _`#27336`: https://github.com/saltstack/salt/pull/27336
.. _`#27345`: https://github.com/saltstack/salt/pull/27345
.. _`#27351`: https://github.com/saltstack/salt/pull/27351
.. _`#27356`: https://github.com/saltstack/salt/issues/27356
.. _`#27358`: https://github.com/saltstack/salt/pull/27358
.. _`#27375`: https://github.com/saltstack/salt/pull/27375
.. _`#27379`: https://github.com/saltstack/salt/pull/27379
.. _`#27389`: https://github.com/saltstack/salt/issues/27389
.. _`#27408`: https://github.com/saltstack/salt/pull/27408
.. _`#27410`: https://github.com/saltstack/salt/pull/27410
.. _`#27419`: https://github.com/saltstack/salt/pull/27419
.. _`#27426`: https://github.com/saltstack/salt/pull/27426
.. _`#27434`: https://github.com/saltstack/salt/pull/27434
.. _`#27438`: https://github.com/saltstack/salt/issues/27438
.. _`#27467`: https://github.com/saltstack/salt/pull/27467
.. _`#27468`: https://github.com/saltstack/salt/pull/27468
.. _`#27469`: https://github.com/saltstack/salt/pull/27469

View file

@ -210,6 +210,10 @@ Changes:
- **PR** `#27568`_: (*jacobhammons*) regenerated man pages
.. _`#19673`: https://github.com/saltstack/salt/issues/19673
.. _`#25775`: https://github.com/saltstack/salt/issues/25775
.. _`#28372`: https://github.com/saltstack/salt/issues/28372
.. _`#28783`: https://github.com/saltstack/salt/issues/28783
.. _`#29110`: https://github.com/saltstack/salt/issues/29110
.. _`#25521`: https://github.com/saltstack/salt/pull/25521
.. _`#25928`: https://github.com/saltstack/salt/pull/25928

View file

@ -242,7 +242,9 @@ Changes:
- **PR** `#27568`_: (*jacobhammons*) regenerated man pages
.. _`#19673`: https://github.com/saltstack/salt/issues/19673
.. _`#25521`: https://github.com/saltstack/salt/pull/25521
.. _`#25775`: https://github.com/saltstack/salt/issues/25775
.. _`#25928`: https://github.com/saltstack/salt/pull/25928
.. _`#27201`: https://github.com/saltstack/salt/pull/27201
.. _`#27286`: https://github.com/saltstack/salt/pull/27286
@ -321,6 +323,7 @@ Changes:
.. _`#28358`: https://github.com/saltstack/salt/pull/28358
.. _`#28359`: https://github.com/saltstack/salt/pull/28359
.. _`#28366`: https://github.com/saltstack/salt/pull/28366
.. _`#28372`: https://github.com/saltstack/salt/issues/28372
.. _`#28373`: https://github.com/saltstack/salt/pull/28373
.. _`#28381`: https://github.com/saltstack/salt/pull/28381
.. _`#28400`: https://github.com/saltstack/salt/pull/28400
@ -366,6 +369,7 @@ Changes:
.. _`#28760`: https://github.com/saltstack/salt/pull/28760
.. _`#28776`: https://github.com/saltstack/salt/pull/28776
.. _`#28777`: https://github.com/saltstack/salt/pull/28777
.. _`#28783`: https://github.com/saltstack/salt/issues/28783
.. _`#28786`: https://github.com/saltstack/salt/pull/28786
.. _`#28826`: https://github.com/saltstack/salt/pull/28826
.. _`#28829`: https://github.com/saltstack/salt/pull/28829

View file

@ -108,6 +108,8 @@ Using the new features will require updates to the git ext_pillar
configuration, further details can be found in the :ref:`pillar.git_pillar
<git-pillar-2015-8-0-and-later>` docs.
.. _pygit2: https://github.com/libgit2/pygit2
Salt Cloud Improvements
=======================

View file

@ -409,6 +409,7 @@ Changes:
.. _`#27210`: https://github.com/saltstack/salt/pull/27210
.. _`#27213`: https://github.com/saltstack/salt/pull/27213
.. _`#27214`: https://github.com/saltstack/salt/pull/27214
.. _`#27217`: https://github.com/saltstack/salt/issues/27217
.. _`#27218`: https://github.com/saltstack/salt/pull/27218
.. _`#27223`: https://github.com/saltstack/salt/pull/27223
.. _`#27230`: https://github.com/saltstack/salt/pull/27230

View file

@ -565,12 +565,19 @@ Changes:
- **PR** `#27585`_: (*ryan-lane*) Fix undefined variable in cron state module
.. _`#3436`: https://github.com/saltstack/salt/issues/3436
.. _`#8646`: https://github.com/saltstack/salt/issues/8646
.. _`#12363`: https://github.com/saltstack/salt/issues/12363
.. _`#13513`: https://github.com/saltstack/salt/issues/13513
.. _`#13850`: https://github.com/saltstack/salt/issues/13850
.. _`#20678`: https://github.com/saltstack/salt/issues/20678
.. _`#29110`: https://github.com/saltstack/salt/issues/29110
.. _`#22115`: https://github.com/saltstack/salt/pull/22115
.. _`#25315`: https://github.com/saltstack/salt/pull/25315
.. _`#25521`: https://github.com/saltstack/salt/pull/25521
.. _`#25668`: https://github.com/saltstack/salt/pull/25668
.. _`#25928`: https://github.com/saltstack/salt/pull/25928
.. _`#26336`: https://github.com/saltstack/salt/issues/26336
.. _`#26945`: https://github.com/saltstack/salt/pull/26945
.. _`#27099`: https://github.com/saltstack/salt/pull/27099
.. _`#27116`: https://github.com/saltstack/salt/pull/27116
@ -679,6 +686,7 @@ Changes:
.. _`#27809`: https://github.com/saltstack/salt/pull/27809
.. _`#27816`: https://github.com/saltstack/salt/pull/27816
.. _`#27824`: https://github.com/saltstack/salt/pull/27824
.. _`#27825`: https://github.com/saltstack/salt/issues/27825
.. _`#27826`: https://github.com/saltstack/salt/pull/27826
.. _`#27827`: https://github.com/saltstack/salt/pull/27827
.. _`#27833`: https://github.com/saltstack/salt/pull/27833
@ -887,6 +895,7 @@ Changes:
.. _`#28465`: https://github.com/saltstack/salt/pull/28465
.. _`#28472`: https://github.com/saltstack/salt/pull/28472
.. _`#28473`: https://github.com/saltstack/salt/pull/28473
.. _`#28484`: https://github.com/saltstack/salt/issues/28484
.. _`#28485`: https://github.com/saltstack/salt/pull/28485
.. _`#28486`: https://github.com/saltstack/salt/pull/28486
.. _`#28487`: https://github.com/saltstack/salt/pull/28487
@ -903,6 +912,8 @@ Changes:
.. _`#28516`: https://github.com/saltstack/salt/pull/28516
.. _`#28517`: https://github.com/saltstack/salt/pull/28517
.. _`#28525`: https://github.com/saltstack/salt/pull/28525
.. _`#28526`: https://github.com/saltstack/salt/issues/28526
.. _`#28527`: https://github.com/saltstack/salt/issues/28527
.. _`#28529`: https://github.com/saltstack/salt/pull/28529
.. _`#28530`: https://github.com/saltstack/salt/pull/28530
.. _`#28531`: https://github.com/saltstack/salt/pull/28531

View file

@ -672,6 +672,12 @@ Changes:
- **PR** `#27585`_: (*ryan-lane*) Fix undefined variable in cron state module
.. _`#3436`: https://github.com/saltstack/salt/issues/3436
.. _`#8646`: https://github.com/saltstack/salt/issues/8646
.. _`#12363`: https://github.com/saltstack/salt/issues/12363
.. _`#13513`: https://github.com/saltstack/salt/issues/13513
.. _`#13850`: https://github.com/saltstack/salt/issues/13850
.. _`#20678`: https://github.com/saltstack/salt/issues/20678
.. _`#22115`: https://github.com/saltstack/salt/pull/22115
.. _`#24314`: https://github.com/saltstack/salt/pull/24314
.. _`#25315`: https://github.com/saltstack/salt/pull/25315
@ -681,6 +687,7 @@ Changes:
.. _`#25923`: https://github.com/saltstack/salt/pull/25923
.. _`#25928`: https://github.com/saltstack/salt/pull/25928
.. _`#25946`: https://github.com/saltstack/salt/pull/25946
.. _`#26336`: https://github.com/saltstack/salt/issues/6336
.. _`#26945`: https://github.com/saltstack/salt/pull/26945
.. _`#27099`: https://github.com/saltstack/salt/pull/27099
.. _`#27116`: https://github.com/saltstack/salt/pull/27116
@ -789,6 +796,7 @@ Changes:
.. _`#27809`: https://github.com/saltstack/salt/pull/27809
.. _`#27816`: https://github.com/saltstack/salt/pull/27816
.. _`#27824`: https://github.com/saltstack/salt/pull/27824
.. _`#27825`: https://github.com/saltstack/salt/issues/27825
.. _`#27826`: https://github.com/saltstack/salt/pull/27826
.. _`#27827`: https://github.com/saltstack/salt/pull/27827
.. _`#27833`: https://github.com/saltstack/salt/pull/27833
@ -997,6 +1005,7 @@ Changes:
.. _`#28465`: https://github.com/saltstack/salt/pull/28465
.. _`#28472`: https://github.com/saltstack/salt/pull/28472
.. _`#28473`: https://github.com/saltstack/salt/pull/28473
.. _`#28484`: https://github.com/saltstack/salt/issues/28484
.. _`#28485`: https://github.com/saltstack/salt/pull/28485
.. _`#28486`: https://github.com/saltstack/salt/pull/28486
.. _`#28487`: https://github.com/saltstack/salt/pull/28487
@ -1013,6 +1022,8 @@ Changes:
.. _`#28516`: https://github.com/saltstack/salt/pull/28516
.. _`#28517`: https://github.com/saltstack/salt/pull/28517
.. _`#28525`: https://github.com/saltstack/salt/pull/28525
.. _`#28526`: https://github.com/saltstack/salt/issues/28526
.. _`#28527`: https://github.com/saltstack/salt/issues/28527
.. _`#28529`: https://github.com/saltstack/salt/pull/28529
.. _`#28530`: https://github.com/saltstack/salt/pull/28530
.. _`#28531`: https://github.com/saltstack/salt/pull/28531
@ -1099,6 +1110,7 @@ Changes:
.. _`#28744`: https://github.com/saltstack/salt/pull/28744
.. _`#28746`: https://github.com/saltstack/salt/pull/28746
.. _`#28752`: https://github.com/saltstack/salt/pull/28752
.. _`#28754`: https://github.com/saltstack/salt/issues/28754
.. _`#28755`: https://github.com/saltstack/salt/pull/28755
.. _`#28756`: https://github.com/saltstack/salt/pull/28756
.. _`#28757`: https://github.com/saltstack/salt/pull/28757
@ -1114,6 +1126,7 @@ Changes:
.. _`#28777`: https://github.com/saltstack/salt/pull/28777
.. _`#28778`: https://github.com/saltstack/salt/pull/28778
.. _`#28782`: https://github.com/saltstack/salt/pull/28782
.. _`#28784`: https://github.com/saltstack/salt/pull/issues/28784
.. _`#28786`: https://github.com/saltstack/salt/pull/28786
.. _`#28787`: https://github.com/saltstack/salt/pull/28787
.. _`#28789`: https://github.com/saltstack/salt/pull/28789
@ -1199,6 +1212,7 @@ Changes:
.. _`#29095`: https://github.com/saltstack/salt/pull/29095
.. _`#29096`: https://github.com/saltstack/salt/pull/29096
.. _`#29097`: https://github.com/saltstack/salt/pull/29097
.. _`#29107`: https://github.com/saltstack/salt/issues/29107
.. _`#29108`: https://github.com/saltstack/salt/pull/29108
.. _`#29113`: https://github.com/saltstack/salt/pull/29113
.. _`#29118`: https://github.com/saltstack/salt/pull/29118

View file

@ -6,7 +6,7 @@ Version 2016.11.3 is a bugfix release for :ref:`2016.11.0 <release-2016-11-0>`.
Changes for v2016.11.2..v2016.11.3
----------------------------------------------------------------
----------------------------------
Extended changelog courtesy of Todd Stansell (https://github.com/tjstansell/salt-changelogs):
@ -691,7 +691,7 @@ Changes:
* f8a6863 Merge pull request `#39087`_ from lomeroe/`bp-37375`_
* c3aaa53 _in_range_inclusive class method incorrectly called isinstance
* ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name set_
* ce263f9 set_computer_policy and set_user_policy call "set" by the original function name (set) instead of the aliased function name ``set_``
* ff7d74b correct tool extension guid for user registry policies

View file

@ -1796,7 +1796,7 @@ Changes:
- **PR** `#37447`_: (*rallytime*) Cast ip_protocol rule as a str() in boto_secgroup.present
@ *2016-11-04T04:03:45Z*
- **ISSUE** `#36961`_: (*nullify005*) boto_secgroup assumes a string when checking ip_protocol validity when not tcp|udp|all|-1
- **ISSUE** `#36961`_: (*nullify005*) boto_secgroup assumes a string when checking ip_protocol validity when not ``tcp|udp|all|-1``
| refs: `#37447`_
* 651e0f7 Merge pull request `#37447`_ from rallytime/`fix-36961`_
* 6b930ac Cast ip_protocol rule as a str() in boto_secgroup.present

View file

@ -226,6 +226,9 @@ Boolean-style options should be specified in their YAML representation.
`Saltfile` with a capital `S` and be readable by the user running
salt-ssh.
At last you can create ``~/.salt/Saltfile`` and ``salt-ssh``
will automatically load it by default.
Debugging salt-ssh
==================

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

View file

@ -477,7 +477,7 @@ class Client(object):
'Path \'{0}\' is not absolute'.format(url_path)
)
if dest is None:
with salt.utils.fopen(url_data.path, 'r') as fp_:
with salt.utils.fopen(url_path, 'r') as fp_:
data = fp_.read()
return data
return url_path

View file

@ -2711,7 +2711,7 @@ def owner(*paths):
return ret
def info_installed(*names):
def info_installed(*names, **kwargs):
'''
Return the information of the named package(s) installed on the system.
@ -2720,15 +2720,27 @@ def info_installed(*names):
names
The names of the packages for which to return information.
failhard
Whether to throw an exception if none of the packages are installed.
Defaults to True.
.. versionadded:: 2016.11.3
CLI example:
.. code-block:: bash
salt '*' pkg.info_installed <package1>
salt '*' pkg.info_installed <package1> <package2> <package3> ...
salt '*' pkg.info_installed <package1> failhard=false
'''
kwargs = salt.utils.clean_kwargs(**kwargs)
failhard = kwargs.pop('failhard', True)
if kwargs:
salt.utils.invalid_kwargs(kwargs)
ret = dict()
for pkg_name, pkg_nfo in __salt__['lowpkg.info'](*names).items():
for pkg_name, pkg_nfo in __salt__['lowpkg.info'](*names, failhard=failhard).items():
t_nfo = dict()
# Translate dpkg-specific keys to a common structure
for key, value in pkg_nfo.items():

View file

@ -248,14 +248,19 @@ def file_dict(*packages):
return {'errors': errors, 'packages': ret}
def _get_pkg_info(*packages):
def _get_pkg_info(*packages, **kwargs):
'''
Return list of package information. If 'packages' parameter is empty,
then data about all installed packages will be returned.
:param packages: Specified packages.
:param failhard: Throw an exception if no packages found.
:return:
'''
kwargs = salt.utils.clean_kwargs(**kwargs)
failhard = kwargs.pop('failhard', True)
if kwargs:
salt.utils.invalid_kwargs(kwargs)
if __grains__['os'] == 'Ubuntu' and __grains__['osrelease_info'] < (12, 4):
bin_var = '${binary}'
@ -286,7 +291,10 @@ def _get_pkg_info(*packages):
call = __salt__['cmd.run_all'](cmd, python_chell=False)
if call['retcode']:
raise CommandExecutionError("Error getting packages information: {0}".format(call['stderr']))
if failhard:
raise CommandExecutionError("Error getting packages information: {0}".format(call['stderr']))
else:
return ret
for pkg_info in [elm for elm in re.split(r"------", call['stdout']) if elm.strip()]:
pkg_data = {}
@ -369,7 +377,7 @@ def _get_pkg_ds_avail():
return ret
def info(*packages):
def info(*packages, **kwargs):
'''
Returns a detailed summary of package information for provided package names.
If no packages are specified, all packages will be returned.
@ -379,19 +387,31 @@ def info(*packages):
packages
The names of the packages for which to return information.
failhard
Whether to throw an exception if none of the packages are installed.
Defaults to True.
.. versionadded:: 2016.11.3
CLI example:
.. code-block:: bash
salt '*' lowpkg.info
salt '*' lowpkg.info apache2 bash
salt '*' lowpkg.info 'php5*' failhard=false
'''
# Get the missing information from the /var/lib/dpkg/available, if it is there.
# However, this file is operated by dselect which has to be installed.
dselect_pkg_avail = _get_pkg_ds_avail()
kwargs = salt.utils.clean_kwargs(**kwargs)
failhard = kwargs.pop('failhard', True)
if kwargs:
salt.utils.invalid_kwargs(kwargs)
ret = dict()
for pkg in _get_pkg_info(*packages):
for pkg in _get_pkg_info(*packages, failhard=failhard):
# Merge extra information from the dselect, if available
for pkg_ext_k, pkg_ext_v in dselect_pkg_avail.get(pkg['package'], {}).items():
if pkg_ext_k not in pkg:

View file

@ -3783,16 +3783,22 @@ def get_managed(
if source and (template or parsed_scheme in salt.utils.files.REMOTE_PROTOS):
# Check if we have the template or remote file cached
cache_refetch = False
cached_dest = __salt__['cp.is_cached'](source, saltenv)
if cached_dest and (source_hash or skip_verify):
htype = source_sum.get('hash_type', 'sha256')
cached_sum = get_hash(cached_dest, form=htype)
if skip_verify or cached_sum == source_sum['hsum']:
if cached_sum != source_sum['hsum']:
cache_refetch = True
elif skip_verify:
# prev: if skip_verify or cached_sum == source_sum['hsum']:
# but `cached_sum == source_sum['hsum']` is elliptical as prev if
sfn = cached_dest
source_sum = {'hsum': cached_sum, 'hash_type': htype}
# If we didn't have the template or remote file, let's get it
if not sfn:
# Similarly when the file has been updated and the cache has to be refreshed
if not sfn or cache_refetch:
try:
sfn = __salt__['cp.cache_file'](source, saltenv)
except Exception as exc:

View file

@ -4680,14 +4680,6 @@ def _lookup_admin_template(policy_name,
return (False, None, [], 'Unable to find {0} policy {1}'.format(policy_class, policy_name))
def list_configurable_policies(policy_class='Machine',
include_administrative_templates=True,
adml_language='en-US'):
'''
list the policies that the execution module can configure
'''
def get_policy_info(policy_name,
policy_class,
adml_language='en-US'):

View file

@ -329,6 +329,7 @@ def present(name,
homephone
The user's home phone number (not supported in MacOS)
If GECOS field contains more than 3 commas, this field will have the rest of 'em
.. versionchanged:: 2014.7.0
Shadow attribute support added.
@ -409,7 +410,7 @@ def present(name,
# the comma is used to separate field in GECOS, thus resulting into
# salt adding the end of fullname each time this function is called
for gecos_field in ['fullname', 'roomnumber', 'workphone', 'homephone']:
for gecos_field in ['fullname', 'roomnumber', 'workphone']:
if isinstance(gecos_field, string_types) and ',' in gecos_field:
ret['comment'] = "Unsupported char ',' in {0}".format(gecos_field)
ret['result'] = False

View file

@ -378,6 +378,10 @@ class SaltfileMixIn(six.with_metaclass(MixInMeta, object)):
saltfile = ''
if os.path.isfile(saltfile):
self.options.saltfile = saltfile
else:
saltfile = os.path.join(os.path.expanduser("~"), '.salt', 'Saltfile')
if os.path.isfile(saltfile):
self.options.saltfile = saltfile
else:
saltfile = self.options.saltfile
@ -387,8 +391,7 @@ class SaltfileMixIn(six.with_metaclass(MixInMeta, object)):
if not os.path.isfile(self.options.saltfile):
self.error(
'\'{0}\' file does not exist.\n'.format(self.options.saltfile
)
'\'{0}\' file does not exist.\n'.format(self.options.saltfile)
)
# Make sure we have an absolute path
@ -499,6 +502,7 @@ class ConfigDirMixIn(six.with_metaclass(MixInMeta, object)):
)
def process_config_dir(self):
self.options.config_dir = os.path.expanduser(self.options.config_dir)
if not os.path.isdir(self.options.config_dir):
# No logging is configured yet
sys.stderr.write(
@ -556,11 +560,10 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
'-l', '--log-level',
dest=self._loglevel_config_setting_name_,
choices=list(log.LOG_LEVELS),
help='Console logging log level. One of {0}. '
'Default: \'{1}\'.'.format(
', '.join([repr(l) for l in log.SORTED_LEVEL_NAMES]),
self._default_logging_level_
)
help='Console logging log level. One of {0}. Default: \'{1}\'.'.format(
', '.join([repr(l) for l in log.SORTED_LEVEL_NAMES]),
self._default_logging_level_
)
)
group.add_option(
@ -576,11 +579,10 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
'--log-file-level',
dest=self._logfile_loglevel_config_setting_name_,
choices=list(log.LOG_LEVELS),
help='Logfile logging log level. One of {0}. '
'Default: \'{1}\'.'.format(
', '.join([repr(l) for l in log.SORTED_LEVEL_NAMES]),
self._default_logging_level_
)
help='Logfile logging log level. One of {0}. Default: \'{1}\'.'.format(
', '.join([repr(l) for l in log.SORTED_LEVEL_NAMES]),
self._default_logging_level_
)
)
def process_log_level(self):
@ -590,15 +592,13 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
# Is the regular log level setting set?
setattr(self.options,
self._loglevel_config_setting_name_,
self.config.get(self._loglevel_config_setting_name_)
)
self.config.get(self._loglevel_config_setting_name_))
else:
# Nothing is set on the configuration? Let's use the CLI tool
# defined default
setattr(self.options,
self._loglevel_config_setting_name_,
self._default_logging_level_
)
self._default_logging_level_)
# Setup extended logging right before the last step
self._mixin_after_parsed_funcs.append(self.__setup_extended_logging)
@ -621,15 +621,13 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
# Is the regular log file setting set?
setattr(self.options,
self._logfile_config_setting_name_,
self.config.get(self._logfile_config_setting_name_)
)
self.config.get(self._logfile_config_setting_name_))
else:
# Nothing is set on the configuration? Let's use the CLI tool
# defined default
setattr(self.options,
self._logfile_config_setting_name_,
self._default_logging_logfile_
)
self._default_logging_logfile_)
if self._logfile_config_setting_name_ in self.config:
# Remove it from config so it inherits from log_file
self.config.pop(self._logfile_config_setting_name_)
@ -641,8 +639,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
# Is the regular log file level setting set?
setattr(self.options,
self._logfile_loglevel_config_setting_name_,
self.config.get(self._logfile_loglevel_config_setting_name_)
)
self.config.get(self._logfile_loglevel_config_setting_name_))
else:
# Nothing is set on the configuration? Let's use the CLI tool
# defined default
@ -652,8 +649,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
self.config.get(
self._loglevel_config_setting_name_,
self._default_logging_level_
)
)
))
if self._logfile_loglevel_config_setting_name_ in self.config:
# Remove it from config so it inherits from log_level_logfile
self.config.pop(self._logfile_loglevel_config_setting_name_)
@ -983,12 +979,6 @@ class DaemonMixIn(six.with_metaclass(MixInMeta, object)):
Check if a pid file exists and if it is associated with
a running process.
'''
# There is no os.getppid method for windows
if salt.utils.is_windows():
from salt.utils.win_functions import get_parent_pid
ppid = get_parent_pid()
else:
ppid = os.getppid()
if self.check_pidfile():
pid = self.get_pidfile()
@ -1549,9 +1539,9 @@ class CloudQueriesMixIn(six.with_metaclass(MixInMeta, object)):
def _mixin_after_parsed(self):
group_options_selected = [
option for option in self.cloud_queries_group.option_list if
getattr(self.options, option.dest) is not False and
getattr(self.options, option.dest) is not None
option for option in self.cloud_queries_group.option_list if
getattr(self.options, option.dest) is not False and
getattr(self.options, option.dest) is not None
]
if len(group_options_selected) > 1:
self.error(
@ -3028,7 +3018,7 @@ class SaltCloudParser(six.with_metaclass(OptionParserMeta,
description = (
'Salt Cloud is the system used to provision virtual machines on various public\n'
'clouds via a cleanly controlled profile and mapping system'
)
)
usage = '%prog [options] <-m MAP | -p PROFILE> <NAME> [NAME2 ...]'

View file

@ -5,17 +5,33 @@ from __future__ import absolute_import
import sys
# Import salt libs
from salt.utils.winservice import Service, instart
from salt.utils.winservice import service, instart
import salt
import salt.defaults.exitcodes
# Import third party libs
import win32serviceutil
import win32service
import winerror
try:
import win32serviceutil
import win32service
import winerror
HAS_WIN32 = True
except ImportError:
HAS_WIN32 = False
class MinionService(Service):
# Although utils are often directly imported, it is also possible to use the
# loader.
def __virtual__():
'''
Only load if Win32 Libraries are installed
'''
if not HAS_WIN32:
return False, 'This utility requires pywin32'
return 'saltminionservice'
class MinionService(service(False)):
def start(self):
self.runflag = True

View file

@ -29,40 +29,42 @@ def __virtual__():
return 'win_osinfo'
class OSVERSIONINFO(ctypes.Structure):
_fields_ = (('dwOSVersionInfoSize', DWORD),
('dwMajorVersion', DWORD),
('dwMinorVersion', DWORD),
('dwBuildNumber', DWORD),
('dwPlatformId', DWORD),
('szCSDVersion', WCHAR * 128))
def os_version_info_ex():
'''
Helper function to return the results of the GetVersionExW Windows API call.
It is a ctypes Structure that contains Windows OS Version information.
def __init__(self, *args, **kwds):
super(OSVERSIONINFO, self).__init__(*args, **kwds)
self.dwOSVersionInfoSize = ctypes.sizeof(self)
kernel32.GetVersionExW(ctypes.byref(self))
Returns:
class: An instance of a class containing version info
'''
if not HAS_WIN32:
return
class OSVersionInfo(ctypes.Structure):
_fields_ = (('dwOSVersionInfoSize', DWORD),
('dwMajorVersion', DWORD),
('dwMinorVersion', DWORD),
('dwBuildNumber', DWORD),
('dwPlatformId', DWORD),
('szCSDVersion', WCHAR * 128))
class OSVERSIONINFOEX(OSVERSIONINFO):
_fields_ = (('wServicePackMajor', WORD),
('wServicePackMinor', WORD),
('wSuiteMask', WORD),
('wProductType', BYTE),
('wReserved', BYTE))
def __init__(self, *args, **kwds):
super(OSVersionInfo, self).__init__(*args, **kwds)
self.dwOSVersionInfoSize = ctypes.sizeof(self)
kernel32.GetVersionExW(ctypes.byref(self))
class OSVersionInfoEx(OSVersionInfo):
_fields_ = (('wServicePackMajor', WORD),
('wServicePackMinor', WORD),
('wSuiteMask', WORD),
('wProductType', BYTE),
('wReserved', BYTE))
def errcheck_bool(result, func, args):
if not result:
raise ctypes.WinError(ctypes.get_last_error())
return args
if HAS_WIN32:
kernel32.GetVersionExW.errcheck = errcheck_bool
kernel32.GetVersionExW.argtypes = (ctypes.POINTER(OSVERSIONINFO),)
return OSVersionInfoEx()
def get_os_version_info():
info = OSVERSIONINFOEX()
info = os_version_info_ex()
ret = {'MajorVersion': info.dwMajorVersion,
'MinorVersion': info.dwMinorVersion,
'BuildNumber': info.dwBuildNumber,

View file

@ -30,52 +30,69 @@ def __virtual__():
return 'winservice'
class Service(win32serviceutil.ServiceFramework):
def service(instantiated=True):
'''
Helper function to return an instance of the ServiceFramework class
_svc_name_ = '_unNamed'
_svc_display_name_ = '_Service Template'
Args:
instantiated (bool): True to return an instantiated object, False to
return the object definition. Use False if inherited by another
class. Default is True.
def __init__(self, *args):
win32serviceutil.ServiceFramework.__init__(self, *args)
self.log('init')
self.stop_event = win32event.CreateEvent(None, 0, 0, None)
Returns:
class: An instance of the ServiceFramework class
'''
if not HAS_WIN32:
return
def log(self, msg):
import servicemanager
servicemanager.LogInfoMsg(str(msg))
class Service(win32serviceutil.ServiceFramework):
def sleep(self, sec):
win32api.Sleep(sec * 1000, True)
_svc_name_ = '_unNamed'
_svc_display_name_ = '_Service Template'
def SvcDoRun(self): # pylint: disable=C0103
self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
try:
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
self.log('start')
self.start()
self.log('wait')
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
self.log('done')
except Exception as err:
self.log('Exception: {0}'.format(err))
self.SvcStop()
def __init__(self, *args):
win32serviceutil.ServiceFramework.__init__(self, *args)
self.log('init')
self.stop_event = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self): # pylint: disable=C0103
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.log('stopping')
self.stop()
self.log('stopped')
win32event.SetEvent(self.stop_event)
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
def log(self, msg):
import servicemanager
servicemanager.LogInfoMsg(str(msg))
# to be overridden
def start(self):
pass
def sleep(self, sec):
win32api.Sleep(sec * 1000, True)
# to be overridden
def stop(self):
pass
def SvcDoRun(self): # pylint: disable=C0103
self.ReportServiceStatus(win32service.SERVICE_START_PENDING)
try:
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
self.log('start')
self.start()
self.log('wait')
win32event.WaitForSingleObject(self.stop_event,
win32event.INFINITE)
self.log('done')
except Exception as err:
self.log('Exception: {0}'.format(err))
self.SvcStop()
def SvcStop(self): # pylint: disable=C0103
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.log('stopping')
self.stop()
self.log('stopped')
win32event.SetEvent(self.stop_event)
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
# to be overridden
def start(self):
pass
# to be overridden
def stop(self):
pass
return Service() if instantiated else Service
def instart(cls, name, display_name=None, stay_alive=True):