Merge pull request #27313 from basepi/merge-forward-develop

Merge forward from 2015.8 to develop
This commit is contained in:
Colton Myers 2015-09-22 16:11:07 -06:00
commit 84eba18a93
45 changed files with 347 additions and 84 deletions

View File

@ -1,6 +1,6 @@
============== salt.auth.rest module
salt.auth.rest =====================
==============
.. automodule:: salt.auth.rest .. automodule:: salt.auth.rest
:members: :members:
:undoc-members:

View File

@ -1,6 +1,6 @@
=============== salt.beacons.ps module
salt.beacons.ps ======================
===============
.. automodule:: salt.beacons.ps .. automodule:: salt.beacons.ps
:members: :members:
:undoc-members:

View File

@ -20,6 +20,7 @@ Reference
peer peer
pillar/index pillar/index
pillar/all/index pillar/all/index
proxy/all/index
renderers/index renderers/index
returners/index returners/index
roster/all/index roster/all/index

View File

@ -73,6 +73,7 @@ Full list of builtin execution modules
ddns ddns
deb_apache deb_apache
deb_postgres deb_postgres
debbuild
debconfmod debconfmod
debian_ip debian_ip
debian_service debian_service
@ -131,6 +132,7 @@ Full list of builtin execution modules
incron incron
influx influx
ini_manage ini_manage
inspectlib
introspect introspect
ipmi ipmi
ipset ipset
@ -258,6 +260,7 @@ Full list of builtin execution modules
shadow shadow
slack_notify slack_notify
smartos_imgadm smartos_imgadm
smartos_virt
smartos_vmadm smartos_vmadm
smbios smbios
smf smf
@ -287,6 +290,7 @@ Full list of builtin execution modules
sysrc sysrc
system system
system_profiler system_profiler
system_rest_sample
systemd systemd
telemetry telemetry
temp temp

View File

@ -0,0 +1,6 @@
=====================
salt.modules.debbuild
=====================
.. automodule:: salt.modules.debbuild
:members:

View File

@ -0,0 +1,6 @@
salt.modules.inspectlib.collector module
========================================
.. automodule:: salt.modules.inspectlib.collector
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.modules.inspectlib.dbhandle module
=======================================
.. automodule:: salt.modules.inspectlib.dbhandle
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.modules.inspectlib.exceptions module
=========================================
.. automodule:: salt.modules.inspectlib.exceptions
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.modules.inspectlib.query module
====================================
.. automodule:: salt.modules.inspectlib.query
:members:
:undoc-members:

View File

@ -0,0 +1,19 @@
salt.modules.inspectlib package
===============================
Submodules
----------
.. toctree::
salt.modules.inspectlib.collector
salt.modules.inspectlib.dbhandle
salt.modules.inspectlib.exceptions
salt.modules.inspectlib.query
Module contents
---------------
.. automodule:: salt.modules.inspectlib
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
=========================
salt.modules.smartos_virt
=========================
.. automodule:: salt.modules.smartos_virt
:members:

View File

@ -0,0 +1,6 @@
===============================
salt.modules.system_rest_sample
===============================
.. automodule:: salt.modules.system_rest_sample
:members:

View File

@ -0,0 +1,6 @@
salt.netapi.rest_cherrypy.app module
====================================
.. automodule:: salt.netapi.rest_cherrypy.app
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.netapi.rest_cherrypy.wsgi module
=====================================
.. automodule:: salt.netapi.rest_cherrypy.wsgi
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.netapi.rest_tornado.saltnado module
========================================
.. automodule:: salt.netapi.rest_tornado.saltnado
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.netapi.rest_tornado.saltnado_websockets module
===================================================
.. automodule:: salt.netapi.rest_tornado.saltnado_websockets
:members:
:undoc-members:

View File

@ -1,6 +1,6 @@
========================= salt.pillar.consul_pillar module
salt.pillar.consul_pillar ================================
=========================
.. automodule:: salt.pillar.consul_pillar .. automodule:: salt.pillar.consul_pillar
:members: :members:
:undoc-members:

View File

@ -1,6 +1,6 @@
=================== salt.pillar.neutron module
salt.pillar.neutron ==========================
===================
.. automodule:: salt.pillar.neutron .. automodule:: salt.pillar.neutron
:members: :members:
:undoc-members:

View File

@ -1,6 +1,6 @@
==================== salt.pillar.sql_base module
salt.pillar.sql_base ===========================
====================
.. automodule:: salt.pillar.sql_base .. automodule:: salt.pillar.sql_base
:members: :members:
:undoc-members:

View File

@ -1,6 +1,6 @@
=================== salt.pillar.sqlite3 module
salt.pillar.sqlite3 ==========================
===================
.. automodule:: salt.pillar.sqlite3 .. automodule:: salt.pillar.sqlite3
:members: :members:
:undoc-members:

View File

@ -0,0 +1,14 @@
.. _all-salt.proxy:
==================================
Full list of builtin proxy modules
==================================
.. currentmodule:: salt.proxy
.. autosummary::
:toctree:
:template: autosummary.rst.tmpl
junos
rest_sample

View File

@ -0,0 +1,6 @@
salt.proxy.junos module
=======================
.. automodule:: salt.proxy.junos
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.proxy.rest_sample module
=============================
.. automodule:: salt.proxy.rest_sample
:members:
:undoc-members:

View File

@ -0,0 +1,6 @@
salt.queues.sqlite_queue module
===============================
.. automodule:: salt.queues.sqlite_queue
:members:
:undoc-members:

View File

@ -1,6 +1,6 @@
============= salt.sdb.rest module
salt.sdb.rest ====================
=============
.. automodule:: salt.sdb.rest .. automodule:: salt.sdb.rest
:members: :members:
:undoc-members:

View File

@ -0,0 +1,6 @@
==================
salt.states.glance
==================
.. automodule:: salt.states.glance
:members:

View File

@ -46,7 +46,7 @@ Set up an initial profile at ``/etc/salt/cloud.profiles`` or in the
digitalocean-ubuntu: digitalocean-ubuntu:
provider: my-digitalocean-config provider: my-digitalocean-config
image: Ubuntu 14.04 x32 image: 14.04 x64
size: 512MB size: 512MB
location: New York 1 location: New York 1
private_networking: True private_networking: True
@ -117,18 +117,20 @@ command:
---------- ----------
digital_ocean: digital_ocean:
---------- ----------
Arch Linux 2013.05 x64: 10.1:
---------- ----------
created_at:
2015-01-20T20:04:34Z
distribution: distribution:
Arch Linux FreeBSD
id: id:
350424 10144573
min_disk_size:
20
name: name:
Arch Linux 2013.05 x64 10.1
public: public:
True True
slug:
None
...SNIP... ...SNIP...
.. note:: .. note::

View File

@ -256,6 +256,19 @@ max_net_speed
Specifies the connection speed for the instance's network components. This Specifies the connection speed for the instance's network components. This
setting is optional. By default, this is set to 10. setting is optional. By default, this is set to 10.
post_uri
--------
Specifies the uri location of the script to be downloaded and run after the instance
is provisioned.
.. versionadded:: 2015.8.1
Example:
.. code-block:: yaml
base_softlayer_ubuntu:
post_uri: 'https://SOMESERVERIP:8000/myscript.sh'
public_vlan public_vlan
----------- -----------
If it is necessary for an instance to be created within a specific frontend If it is necessary for an instance to be created within a specific frontend

View File

@ -0,0 +1,8 @@
===========================
Salt 2015.5.6 Release Notes
===========================
Version 2015.5.6 is a bugfix release for :doc:`2015.5.0
</topics/releases/2015.5.0>`.
Changes:

View File

@ -135,9 +135,9 @@ def avail_images(call=None):
items = query(method='images', command='?page=' + str(page) + '&per_page=200') items = query(method='images', command='?page=' + str(page) + '&per_page=200')
for image in items['images']: for image in items['images']:
ret[image['id']] = {} ret[image['name']] = {}
for item in six.iterkeys(image): for item in six.iterkeys(image):
ret[image['id']][item] = image[item] ret[image['name']][item] = image[item]
page += 1 page += 1
try: try:
@ -562,10 +562,20 @@ def list_keypairs(call=None):
items = query(method='account/keys') items = query(method='account/keys')
ret = {} ret = {}
for keypair in items['ssh_keys']: for key_pair in items['ssh_keys']:
ret[keypair['name']] = {} name = key_pair['name']
for item in six.iterkeys(keypair): if name in ret:
ret[keypair['name']][item] = str(keypair[item]) raise SaltCloudSystemExit(
'A duplicate key pair name, \'{0}\', was found in DigitalOcean\'s '
'key pair list. Please change the key name stored by DigitalOcean. '
'Be sure to adjust the value of \'ssh_key_file\' in your cloud '
'profile or provider configuration, if necessary.'.format(
name
)
)
ret[name] = {}
for item in six.iterkeys(key_pair):
ret[name][item] = str(key_pair[item])
return ret return ret

View File

@ -1037,7 +1037,7 @@ def list_storage_services(conn=None, call=None):
def get_operation_status(kwargs=None, conn=None, call=None): def get_operation_status(kwargs=None, conn=None, call=None):
''' '''
.. versionadded:: 2015.2 .. versionadded:: 2015.8.0
Get Operation Status, based on a request ID Get Operation Status, based on a request ID

View File

@ -369,6 +369,12 @@ def create(vm_):
'maxSpeed': int(max_net_speed) 'maxSpeed': int(max_net_speed)
}] }]
post_uri = config.get_cloud_config_value(
'post_uri', vm_, __opts__, default=None
)
if post_uri:
kwargs['postInstallScriptUri'] = post_uri
salt.utils.cloud.fire_event( salt.utils.cloud.fire_event(
'event', 'event',
'requesting instance', 'requesting instance',

View File

@ -308,6 +308,12 @@ def create(vm_):
) )
kwargs['prices'].append({'id': bandwidth}) kwargs['prices'].append({'id': bandwidth})
post_uri = config.get_cloud_config_value(
'post_uri', vm_, __opts__, default=None
)
if post_uri:
kwargs['prices'].append({'id': post_uri})
vlan_id = config.get_cloud_config_value( vlan_id = config.get_cloud_config_value(
'vlan', vm_, __opts__, default=False 'vlan', vm_, __opts__, default=False
) )

View File

@ -3,7 +3,7 @@
Fluent Logging Handler Fluent Logging Handler
======================== ========================
.. versionadded:: 2015.2 .. versionadded:: 2015.8.0
This module provides some `Fluent`_ logging handlers. This module provides some `Fluent`_ logging handlers.

View File

@ -1807,10 +1807,11 @@ class ClearFuncs(object):
# If there are groups in the token, check if any of them are listed in the eauth config # If there are groups in the token, check if any of them are listed in the eauth config
group_auth_match = False group_auth_match = False
try: try:
for group in token['groups']: if token.get('groups'):
if group in eauth_groups: for group in token['groups']:
group_auth_match = True if group in eauth_groups:
break group_auth_match = True
break
except KeyError: except KeyError:
pass pass
if '*' not in eauth_users and token['name'] not in eauth_users and not group_auth_match: if '*' not in eauth_users and token['name'] not in eauth_users and not group_auth_match:

View File

@ -2,7 +2,7 @@
''' '''
Debian Package builder system Debian Package builder system
.. versionadded:: Beryllium .. versionadded:: 2015.8.0
This system allows for all of the components to build debs safely in chrooted This system allows for all of the components to build debs safely in chrooted
environments. This also provides a function to generate debian repositories environments. This also provides a function to generate debian repositories

View File

@ -62,9 +62,9 @@ def usage(args=None):
''' '''
flags = _clean_flags(args, 'disk.usage') flags = _clean_flags(args, 'disk.usage')
if not os.path.isfile('/etc/mtab') and __grains__['kernel'] == 'Linux': if not os.path.isfile('/etc/mtab') and __grains__['kernel'] == 'Linux':
log.warn('df cannot run without /etc/mtab') log.error('df cannot run without /etc/mtab')
if __grains__.get('virtual_subtype') == 'LXC': if __grains__.get('virtual_subtype') == 'LXC':
log.warn('df command failed and LXC detected. If you are running ' log.error('df command failed and LXC detected. If you are running '
'a Docker container, consider linking /proc/mounts to ' 'a Docker container, consider linking /proc/mounts to '
'/etc/mtab or consider running Docker with -privileged') '/etc/mtab or consider running Docker with -privileged')
return {} return {}
@ -116,7 +116,7 @@ def usage(args=None):
'capacity': comps[4], 'capacity': comps[4],
} }
except IndexError: except IndexError:
log.warn('Problem parsing disk usage information') log.error('Problem parsing disk usage information')
ret = {} ret = {}
return ret return ret
@ -163,7 +163,7 @@ def inodeusage(args=None):
'filesystem': comps[0], 'filesystem': comps[0],
} }
except (IndexError, ValueError): except (IndexError, ValueError):
log.warn('Problem parsing inode usage information') log.error('Problem parsing inode usage information')
ret = {} ret = {}
return ret return ret
@ -201,18 +201,21 @@ def percent(args=None):
else: else:
ret[comps[5]] = comps[4] ret[comps[5]] = comps[4]
except IndexError: except IndexError:
log.warn('Problem parsing disk usage information') log.error('Problem parsing disk usage information')
ret = {} ret = {}
if args: if args and args not in ret:
log.error('Problem parsing disk usage information: Partition \'{0}\' does not exist!'.format(args))
ret = {}
elif args:
return ret[args] return ret[args]
else:
return ret return ret
@decorators.which('blkid') @decorators.which('blkid')
def blkid(device=None): def blkid(device=None):
''' '''
Return block device attributes: UUID, LABEL, etc. This function only works Return block device attributes: UUID, LABEL, etc. This function only works
on systems where blkid is available. on systems where blkid is available.
CLI Example: CLI Example:

View File

@ -51,7 +51,7 @@ _ETHTOOL_CONFIG_OPTS = [
] ]
_RH_CONFIG_OPTS = [ _RH_CONFIG_OPTS = [
'domain', 'peerdns', 'peerntp', 'defroute', 'domain', 'peerdns', 'peerntp', 'defroute',
'mtu', 'static-routes', 'gateway' 'mtu', 'static-routes', 'gateway', 'zone'
] ]
_RH_CONFIG_BONDING_OPTS = [ _RH_CONFIG_BONDING_OPTS = [
'mode', 'miimon', 'arp_interval', 'mode', 'miimon', 'arp_interval',
@ -634,7 +634,7 @@ def _parse_settings_eth(opts, iface_type, enabled, iface):
elif 'netmask' in opts: elif 'netmask' in opts:
result['netmask'] = opts['netmask'] result['netmask'] = opts['netmask']
for opt in ['ipaddr', 'master', 'srcaddr', 'delay', 'domain', 'gateway', 'uuid', 'nickname']: for opt in ['ipaddr', 'master', 'srcaddr', 'delay', 'domain', 'gateway', 'uuid', 'nickname', 'zone']:
if opt in opts: if opt in opts:
result[opt] = opts[opt] result[opt] = opts[opt]

View File

@ -870,7 +870,8 @@ def set_known_host(user=None,
port=None, port=None,
enc=None, enc=None,
hash_hostname=True, hash_hostname=True,
config=None): config=None,
hash_known_hosts=True):
''' '''
Download SSH public key from remote host "hostname", optionally validate Download SSH public key from remote host "hostname", optionally validate
its fingerprint against "fingerprint" variable and save the record in the its fingerprint against "fingerprint" variable and save the record in the
@ -878,6 +879,44 @@ def set_known_host(user=None,
If such a record does already exists in there, do nothing. If such a record does already exists in there, do nothing.
user
The user who owns the ssh authorized keys file to modify
hostname
The name of the remote host (e.g. "github.com")
fingerprint
The fingerprint of the key which must be presented in the known_hosts
file (optional if key specified)
key
The public key which must be presented in the known_hosts file
(optional if fingerprint specified)
port
optional parameter, denoting the port of the remote host, which will be
used in case, if the public key will be requested from it. By default
the port 22 is used.
enc
Defines what type of key is being used, can be ed25519, ecdsa ssh-rsa
or ssh-dss
hash_hostname : True
Hash all hostnames and addresses in the known hosts file.
.. deprecated:: Carbon
Please use hash_known_hosts instead.
config
The location of the authorized keys file relative to the user's home
directory, defaults to ".ssh/known_hosts". If no user is specified,
defaults to "/etc/ssh/ssh_known_hosts". If present, must be an
absolute path when a user is not specified.
hash_known_hosts : True
Hash all hostnames and addresses in the known hosts file.
CLI Example: CLI Example:
@ -894,6 +933,14 @@ def set_known_host(user=None,
'error': 'argument port can not be used in ' 'error': 'argument port can not be used in '
'conjunction with argument hash_hostname'} 'conjunction with argument hash_hostname'}
if not hash_hostname:
salt.utils.warn_until(
'Carbon',
'The hash_hostname parameter is misleading as ssh-keygen can only '
'hash the whole known hosts file, not entries for individual'
'hosts. Please use hash_known_hosts=False instead.')
hash_known_hosts = hash_hostname
update_required = False update_required = False
check_required = False check_required = False
stored_host = get_known_host(user, hostname, config, port) stored_host = get_known_host(user, hostname, config, port)
@ -967,7 +1014,7 @@ def set_known_host(user=None,
os.chown(ssh_dir, uinfo['uid'], uinfo['gid']) os.chown(ssh_dir, uinfo['uid'], uinfo['gid'])
os.chmod(ssh_dir, 0o700) os.chmod(ssh_dir, 0o700)
if key: if key and hash_known_hosts:
cmd_result = __salt__['ssh.hash_known_hosts'](user=user, config=full) cmd_result = __salt__['ssh.hash_known_hosts'](user=user, config=full)
# write line to known_hosts file # write line to known_hosts file
@ -1070,6 +1117,13 @@ def hash_known_hosts(user=None, config=None):
.. versionadded:: 2014.7.0 .. versionadded:: 2014.7.0
user
hash known hosts of this user
config
path to known hosts file: can be absolute or relative to user's home
directory
CLI Example: CLI Example:
.. code-block:: bash .. code-block:: bash
@ -1080,7 +1134,7 @@ def hash_known_hosts(user=None, config=None):
full = _get_known_hosts_file(config=config, user=user) full = _get_known_hosts_file(config=config, user=user)
if isinstance(full, dict): if isinstance(full, dict):
return full return full # full contains error information
if not os.path.isfile(full): if not os.path.isfile(full):
return {'status': 'error', return {'status': 'error',

View File

@ -80,19 +80,10 @@ def _yum():
''' '''
contextkey = 'yum_bin' contextkey = 'yum_bin'
if contextkey not in __context__: if contextkey not in __context__:
try: if 'fedora' in __grains__['os'].lower() and int(__grains__['osrelease']) >= 22:
osrelease = int(__grains__['osrelease']) __context__[contextkey] = 'dnf'
except ValueError:
log.warning(
'Unexpected osrelease grain \'{0}\', please report this'
.format(__grains__['osrelease'])
)
__context__[contextkey] = 'yum'
else: else:
if 'fedora' in __grains__['os'].lower() and osrelease >= 22: __context__[contextkey] = 'yum'
__context__[contextkey] = 'dnf'
else:
__context__[contextkey] = 'yum'
return __context__[contextkey] return __context__[contextkey]

View File

@ -23,6 +23,9 @@ from __future__ import absolute_import
# Import python libs # Import python libs
import os import os
# Import salt libs
import salt.utils
def present( def present(
name, name,
@ -32,7 +35,8 @@ def present(
port=None, port=None,
enc=None, enc=None,
config=None, config=None,
hash_hostname=True): hash_hostname=True,
hash_known_hosts=True):
''' '''
Verifies that the specified host is known by the specified user Verifies that the specified host is known by the specified user
@ -70,7 +74,14 @@ def present(
absolute path when a user is not specified. absolute path when a user is not specified.
hash_hostname : True hash_hostname : True
Hash all hostnames and addresses in the output. Hash all hostnames and addresses in the known hosts file.
.. deprecated:: Carbon
Please use hash_known_hosts instead.
hash_known_hosts : True
Hash all hostnames and addresses in the known hosts file.
''' '''
ret = {'name': name, ret = {'name': name,
'changes': {}, 'changes': {},
@ -87,6 +98,14 @@ def present(
ret['result'] = False ret['result'] = False
return dict(ret, comment=comment) return dict(ret, comment=comment)
if not hash_hostname:
salt.utils.warn_until(
'Carbon',
'The hash_hostname parameter is misleading as ssh-keygen can only '
'hash the whole known hosts file, not entries for individual'
'hosts. Please use hash_known_hosts=False instead.')
hash_known_hosts = hash_hostname
if __opts__['test']: if __opts__['test']:
if key and fingerprint: if key and fingerprint:
comment = 'Specify either "key" or "fingerprint", not both.' comment = 'Specify either "key" or "fingerprint", not both.'
@ -121,7 +140,7 @@ def present(
port=port, port=port,
enc=enc, enc=enc,
config=config, config=config,
hash_hostname=hash_hostname) hash_known_hosts=hash_known_hosts)
if result['status'] == 'exists': if result['status'] == 'exists':
return dict(ret, return dict(ret,
comment='{0} already exists in {1}'.format(name, config)) comment='{0} already exists in {1}'.format(name, config))

View File

@ -8,6 +8,12 @@ Provide test case states that enable easy testing of things to do with
.. code-block:: yaml .. code-block:: yaml
always-passes-with-any-kwarg:
test.nop:
- name: foo
- something: else
- foo: bar
always-passes: always-passes:
test.succeed_without_changes: test.succeed_without_changes:
- name: foo - name: foo
@ -49,6 +55,17 @@ from salt.exceptions import SaltInvocationError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def nop(name, **kwargs):
'''
A no-op state that does nothing. Useful in conjunction with the `use`
requisite, or in templates which could otherwise be empty due to jinja
rendering
.. versionadded:: 2015.5.6
'''
return succeed_without_changes(name)
def succeed_without_changes(name): def succeed_without_changes(name):
''' '''
Returns successful. Returns successful.
@ -64,9 +81,6 @@ def succeed_without_changes(name):
'result': True, 'result': True,
'comment': 'Success!' 'comment': 'Success!'
} }
if __opts__['test']:
ret['result'] = True
ret['comment'] = 'If we weren\'t testing, this would be a success!'
return ret return ret

View File

@ -33,6 +33,7 @@ DEVICE="{{name}}"
{%endif%}{% if stp %}STP="{{stp}}" {%endif%}{% if stp %}STP="{{stp}}"
{%endif%}{% if delay or delay == 0 %}DELAY="{{delay}}" {%endif%}{% if delay or delay == 0 %}DELAY="{{delay}}"
{%endif%}{% if mtu %}MTU="{{mtu}}" {%endif%}{% if mtu %}MTU="{{mtu}}"
{%endif%}{% if zone %}ZONE="{{zone}}"
{%endif%}{% if my_inner_ipaddr %}MY_INNER_IPADDR={{my_inner_ipaddr}} {%endif%}{% if my_inner_ipaddr %}MY_INNER_IPADDR={{my_inner_ipaddr}}
{%endif%}{% if my_outer_ipaddr %}MY_OUTER_IPADDR={{my_outer_ipaddr}} {%endif%}{% if my_outer_ipaddr %}MY_OUTER_IPADDR={{my_outer_ipaddr}}
{%endif%}{% if bonding %}BONDING_OPTS="{%for item in bonding %}{{item}}={{bonding[item]}} {%endfor%}" {%endif%}{% if bonding %}BONDING_OPTS="{%for item in bonding %}{{item}}={{bonding[item]}} {%endfor%}"

View File

@ -471,13 +471,13 @@ class SaltEvent(object):
- 'fnmatch' : fnmatch tag event tags matching - 'fnmatch' : fnmatch tag event tags matching
Default is opts['event_match_type'] or 'startswith' Default is opts['event_match_type'] or 'startswith'
.. versionadded:: Beryllium .. versionadded:: 2015.8.0
no_block no_block
Define if getting the event should be a blocking call or not. Define if getting the event should be a blocking call or not.
Defaults to False to keep backwards compatibility. Defaults to False to keep backwards compatibility.
.. versionadded:: Beryllium .. versionadded:: 2015.8.0
Notes: Notes:

View File

@ -313,7 +313,7 @@ def query(url,
urllib_request.HTTPCookieProcessor(sess_cookies) urllib_request.HTTPCookieProcessor(sess_cookies)
] ]
if url.startswith('https') or port == 443: if url.startswith('https'):
hostname = request.get_host() hostname = request.get_host()
handlers[0] = urllib_request.HTTPSHandler(1) handlers[0] = urllib_request.HTTPSHandler(1)
if not HAS_MATCHHOSTNAME: if not HAS_MATCHHOSTNAME:
@ -323,8 +323,12 @@ def query(url,
log.warn(('SSL certificate verification has been explicitly ' log.warn(('SSL certificate verification has been explicitly '
'disabled. THIS CONNECTION MAY NOT BE SECURE!')) 'disabled. THIS CONNECTION MAY NOT BE SECURE!'))
else: else:
if ':' in hostname:
hostname, port = hostname.split(':')
else:
port = 443
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, 443)) sock.connect((hostname, int(port)))
sockwrap = ssl.wrap_socket( sockwrap = ssl.wrap_socket(
sock, sock,
ca_certs=ca_bundle, ca_certs=ca_bundle,
@ -403,6 +407,9 @@ def query(url,
if isinstance(data, dict): if isinstance(data, dict):
data = urllib.urlencode(data) data = urllib.urlencode(data)
if verify_ssl:
req_kwargs['ca_certs'] = ca_bundle
max_body = opts.get('http_max_body', salt.config.DEFAULT_MINION_OPTS['http_max_body']) max_body = opts.get('http_max_body', salt.config.DEFAULT_MINION_OPTS['http_max_body'])
timeout = opts.get('http_request_timeout', salt.config.DEFAULT_MINION_OPTS['http_request_timeout']) timeout = opts.get('http_request_timeout', salt.config.DEFAULT_MINION_OPTS['http_request_timeout'])