Merge branch '2016.3' into '2016.11'

Conflicts:
  - salt/states/pkg.py
This commit is contained in:
rallytime 2017-03-23 16:47:52 -06:00
commit 77415369cc
4 changed files with 57 additions and 60 deletions

View File

@ -38,8 +38,6 @@ examples could be set up in the cloud configuration at
.. code-block:: yaml
my-openstack-config:
# The ID of the minion that will execute the salt nova functions
auth_minion: myminion
# The name of the configuration profile to use on said minion
config_profile: my_openstack_profile

View File

@ -573,33 +573,6 @@ def set_hostname(hostname):
return "successful" in ret
def _lookup_error(number):
'''
Lookup the error based on the passed number
.. versionadded:: 2015.5.7
.. versionadded:: 2015.8.2
:param int number: Number code to lookup
:return: The text that corresponds to the error number
:rtype: str
'''
return_values = {
2: 'Invalid OU or specifying OU is not supported',
5: 'Access is denied',
53: 'The network path was not found',
87: 'The parameter is incorrect',
110: 'The system cannot open the specified object',
1323: 'Unable to update the password',
1326: 'Logon failure: unknown username or bad password',
1355: 'The specified domain either does not exist or could not be contacted',
2224: 'The account already exists',
2691: 'The machine is already joined to the domain',
2692: 'The machine is not currently joined to a domain',
}
return return_values[number]
def join_domain(domain,
username=None,
password=None,
@ -694,7 +667,7 @@ def join_domain(domain,
ret['Restart'] = reboot()
return ret
log.error(_lookup_error(err[0]))
log.error(win32api.FormatMessage(err[0]).rstrip())
return False
@ -783,11 +756,11 @@ def unjoin_domain(username=None,
return ret
else:
log.error(_lookup_error(err[0]))
log.error(win32api.FormatMessage(err[0]).rstrip())
log.error('Failed to join the computer to {0}'.format(workgroup))
return False
else:
log.error(_lookup_error(err[0]))
log.error(win32api.FormatMessage(err[0]).rstrip())
log.error('Failed to unjoin computer from {0}'.format(status['Domain']))
return False

View File

@ -50,11 +50,6 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
with salt.utils.fopen(cache, 'r') as fh_:
cache_data = msgpack.load(fh_)
indexed_minion = cache_data.get(tgt, None)
if indexed_minion is None:
return {}
client = salt.cloud.CloudClient(
os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud')
)
@ -62,15 +57,27 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
if not info:
return {}
provider = indexed_minion.get('provider', None)
profile = indexed_minion.get('profile', None)
driver = indexed_minion.get('driver', None)
not_actioned = info.get('Not Actioned/Not Running')
if not_actioned and tgt in not_actioned:
return {}
indexed_minion = cache_data.get(tgt, None)
if indexed_minion:
provider = indexed_minion.get('provider', None)
driver = indexed_minion.get('driver', None)
profile = indexed_minion.get('profile', None)
else:
provider = next(iter(info))
driver = next(iter(info[provider]))
profile = None
vm_ = {
'provider': provider,
'profile': profile,
}
full_info = info.get(provider, {}).get(driver, {}).get(tgt, {}).get(tgt, {})
full_info = info.get(provider, {}).get(driver, {}).get(tgt, {})
public_ips = full_info.get('public_ips', [])
private_ips = full_info.get('private_ips', [])
ip_list = []
@ -85,34 +92,36 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
))
preferred_ip = extract_ipv4(roster_order, ip_list)
ret['tgt'] = {
ret[tgt] = {
'host': preferred_ip,
}
cloud_opts = salt.config.cloud_config('/etc/salt/cloud')
ssh_username = salt.utils.cloud.ssh_usernames({}, cloud_opts)
cloud_opts = salt.config.cloud_config(
os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud')
)
ssh_username = salt.utils.cloud.ssh_usernames(vm_, cloud_opts)
if isinstance(ssh_username, string_types):
ret['tgt']['user'] = ssh_username
ret[tgt]['user'] = ssh_username
elif isinstance(ssh_username, list):
ret['tgt']['user'] = ssh_username[0]
ret[tgt]['user'] = ssh_username[0]
password = salt.config.get_cloud_config_value(
'password', vm_, cloud_opts, search_global=False, default=None
)
if password:
ret['tgt']['password'] = password
ret[tgt]['password'] = password
key_filename = salt.config.get_cloud_config_value(
'private_key', vm_, cloud_opts, search_global=False, default=None
)
if key_filename:
ret['tgt']['priv'] = key_filename
ret[tgt]['priv'] = key_filename
sudo = salt.config.get_cloud_config_value(
'sudo', vm_, cloud_opts, search_global=False, default=None
)
if sudo:
ret['tgt']['sudo'] = sudo
ret[tgt]['sudo'] = sudo
return ret

View File

@ -2636,6 +2636,7 @@ def mod_aggregate(low, chunks, running):
low chunks and merges them into a single pkgs ref in the present low data
'''
pkgs = []
pkg_type = None
agg_enabled = [
'installed',
'latest',
@ -2658,18 +2659,34 @@ def mod_aggregate(low, chunks, running):
# Check for the same repo
if chunk.get('fromrepo') != low.get('fromrepo'):
continue
# Pull out the pkg names!
if 'pkgs' in chunk:
pkgs.extend(chunk['pkgs'])
chunk['__agg__'] = True
elif 'name' in chunk:
pkgs.append(chunk['name'])
chunk['__agg__'] = True
if pkgs:
if 'pkgs' in low:
low['pkgs'].extend(pkgs)
# Check first if 'sources' was passed so we don't aggregate pkgs
# and sources together.
if 'sources' in chunk:
if pkg_type is None:
pkg_type = 'sources'
if pkg_type == 'sources':
pkgs.extend(chunk['sources'])
chunk['__agg__'] = True
else:
if pkg_type is None:
pkg_type = 'pkgs'
if pkg_type == 'pkgs':
# Pull out the pkg names!
if 'pkgs' in chunk:
pkgs.extend(chunk['pkgs'])
chunk['__agg__'] = True
elif 'name' in chunk:
version = chunk.pop('version', None)
if version is not None:
pkgs.append({chunk['name']: version})
else:
pkgs.append(chunk['name'])
chunk['__agg__'] = True
if pkg_type is not None and pkgs:
if pkg_type in low:
low[pkg_type].extend(pkgs)
else:
low['pkgs'] = pkgs
low[pkg_type] = pkgs
return low