Backport PR#31601

This commit is contained in:
C. R. Oldham 2016-03-16 15:09:54 -06:00
parent 390ef9fea7
commit d571f3b8fe
7 changed files with 68 additions and 42 deletions

View file

@ -24,10 +24,14 @@ GRAINS_CACHE = {}
def __virtual__():
if not salt.utils.is_proxy():
return False
else:
return __virtualname__
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'esxi':
return __virtualname__
except KeyError:
pass
return False
def esxi():
@ -80,14 +84,19 @@ def _grains():
'''
Get the grains from the proxied device.
'''
host = __pillar__['proxy']['host']
username, password = _find_credentials(host)
protocol = __pillar__['proxy'].get('protocol')
port = __pillar__['proxy'].get('port')
ret = salt.modules.vsphere.system_info(host=host,
username=username,
password=password,
protocol=protocol,
port=port)
GRAINS_CACHE.update(ret)
try:
host = __pillar__['proxy']['host']
if host:
username, password = _find_credentials(host)
protocol = __pillar__['proxy'].get('protocol')
port = __pillar__['proxy'].get('port')
ret = salt.modules.vsphere.system_info(host=host,
username=username,
password=password,
protocol=protocol,
port=port)
GRAINS_CACHE.update(ret)
except KeyError:
pass
return GRAINS_CACHE

View file

@ -24,10 +24,12 @@ GRAINS_CACHE = {}
def __virtual__():
if not salt.utils.is_proxy():
return False
else:
return __virtualname__
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'fx2':
return __virtualname__
except KeyError:
pass
return False
def _find_credentials():

View file

@ -11,10 +11,13 @@ __virtualname__ = 'rest_sample'
def __virtual__():
if not salt.utils.is_proxy():
return False
else:
return __virtualname__
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'rest_sample':
return __virtualname__
except KeyError:
pass
return False
def kernel():

View file

@ -11,18 +11,21 @@ import salt.utils
log = logging.getLogger(__name__)
__proxyenabled__ = ['rest_sample']
# Define the module's virtual name
__virtualname__ = 'pkg'
def __virtual__():
'''
Only work on proxy
Only work on systems that are a proxy minion
'''
if salt.utils.is_proxy():
return __virtualname__
return False
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'rest_sample':
return __virtualname__
except KeyError:
return (False, 'The rest_package execution module failed to load. Check the proxy key in pillar.')
return (False, 'The rest_package execution module failed to load: only works on a rest_sample proxy minion.')
def list_pkgs(versions_as_list=False, **kwargs):

View file

@ -4,9 +4,9 @@ Provide the service module for the proxy-minion REST sample
'''
# Import python libs
from __future__ import absolute_import
import logging
import salt.utils
__proxyenabled__ = ['rest_sample']
import logging
log = logging.getLogger(__name__)
@ -23,9 +23,13 @@ def __virtual__():
'''
Only work on systems that are a proxy minion
'''
if __grains__['os'] == 'proxy':
return __virtualname__
return False
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'rest_sample':
return __virtualname__
except KeyError:
return (False, 'The rest_service execution module failed to load. Check the proxy key in pillar.')
return (False, 'The rest_service execution module failed to load: only works on a rest_sample proxy minion.')
def get_all():

View file

@ -13,7 +13,6 @@ import salt.utils
log = logging.getLogger(__name__)
__proxyenabled__ = ['ssh_sample']
# Define the module's virtual name
__virtualname__ = 'pkg'
@ -22,9 +21,13 @@ def __virtual__():
'''
Only work on proxy
'''
if salt.utils.is_proxy():
return __virtualname__
return False
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'ssh_sample':
return __virtualname__
except KeyError:
return (False, 'The ssh_package execution module failed to load. Check the proxy key in pillar.')
return (False, 'The ssh_package execution module failed to load: only works on an ssh_sample proxy minion.')
def list_pkgs(versions_as_list=False, **kwargs):

View file

@ -6,8 +6,7 @@ Provide the service module for the proxy-minion SSH sample
# Import python libs
from __future__ import absolute_import
import logging
__proxyenabled__ = ['ssh_sample']
import salt.utils
log = logging.getLogger(__name__)
@ -15,7 +14,6 @@ __func_alias__ = {
'list_': 'list'
}
# Define the module's virtual name
__virtualname__ = 'service'
@ -24,9 +22,13 @@ def __virtual__():
'''
Only work on systems that are a proxy minion
'''
if __grains__['os'] == 'proxy':
return __virtualname__
return False
try:
if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'ssh_sample':
return __virtualname__
except KeyError:
return (False, 'The ssh_service execution module failed to load. Check the proxy key in pillar.')
return (False, 'The ssh_service execution module failed to load: only works on an ssh_sample proxy minion.')
def get_all():