mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #31930 from cro/bp-31601
Backport changes from 2016.3
This commit is contained in:
commit
723d0ca19f
8 changed files with 99 additions and 44 deletions
|
@ -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
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Service support for the REST example
|
||||
Package support for the REST example
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
@ -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):
|
||||
|
@ -52,7 +55,15 @@ def version(*names, **kwargs):
|
|||
salt '*' pkg.version <package1> <package2> <package3> ...
|
||||
'''
|
||||
if len(names) == 1:
|
||||
return str(__proxy__['rest_sample.package_status'](names))
|
||||
return str(__proxy__['rest_sample.package_status'](names[0]))
|
||||
|
||||
|
||||
def upgrade(refresh=True, skip_verify=True, **kwargs):
|
||||
old = __proxy__['rest_sample.package_list']()
|
||||
new = __proxy__['rest_sample.uptodate']()
|
||||
pkg_installed = __proxy__['rest_sample.upgrade']()
|
||||
ret = salt.utils.compare_dicts(old, pkg_installed)
|
||||
return ret
|
||||
|
||||
|
||||
def installed(
|
||||
|
|
21
salt/modules/rest_sample_utils.py
Normal file
21
salt/modules/rest_sample_utils.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Utility functions for the rest_sample
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
__proxyenabled__ = ['rest_sample']
|
||||
|
||||
|
||||
def fix_outage():
|
||||
'''
|
||||
"Fix" the outage
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt 'rest-sample-proxy' rest_sample.fix_outage
|
||||
|
||||
'''
|
||||
return __proxy__['rest_sample.fix_outage']()
|
|
@ -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():
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Add table
Reference in a new issue