-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anas Badaha <anasb@mellanox.com>
- Loading branch information
Anas Badaha
committed
Oct 7, 2018
1 parent
0396331
commit 49bc71f
Showing
4 changed files
with
1,096 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Grains for Onyx OS Switches Proxy minions | ||
.. versionadded: Neon | ||
For documentation on setting up the onyx proxy minion look in the documentation | ||
for :mod:`salt.proxy.onyx<salt.proxy.onyx>`. | ||
''' | ||
# Import Python Libs | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
# Import Salt Libs | ||
import logging | ||
import salt.utils.platform | ||
import salt.modules.onyx | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
__proxyenabled__ = ['onyx'] | ||
__virtualname__ = 'onyx' | ||
|
||
|
||
def __virtual__(): | ||
try: | ||
if salt.utils.platform.is_proxy() and __opts__['proxy']['proxytype'] == 'onyx': | ||
return __virtualname__ | ||
except KeyError: | ||
pass | ||
|
||
return False | ||
|
||
|
||
def proxy_functions(proxy=None): | ||
''' | ||
Proxy Initialization | ||
''' | ||
if proxy is None: | ||
return {} | ||
if proxy['onyx.initialized']() is False: | ||
return {} | ||
return {'onyx': proxy['onyx.grains']()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Execution module for Onyx OS Switches Proxy minions | ||
.. versionadded:: Neon | ||
For documentation on setting up the onyx proxy minion look in the documentation | ||
for :mod:`salt.proxy.onyx <salt.proxy.onyx>`. | ||
''' | ||
# Import Python libs | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
# Import Salt libs | ||
import salt.utils.platform | ||
|
||
__proxyenabled__ = ['onyx'] | ||
__virtualname__ = 'onyx' | ||
|
||
|
||
def __virtual__(): | ||
if salt.utils.platform.is_proxy(): | ||
return __virtualname__ | ||
return (False, 'The onyx execution module failed to load: ' | ||
'only available on proxy minions.') | ||
|
||
|
||
def system_info(): | ||
''' | ||
Return system information for grains of the Onyx OS proxy minion | ||
.. code-block:: bash | ||
salt '*' onyx.system_info | ||
''' | ||
return cmd('system_info') | ||
|
||
|
||
def cmd(command, *args, **kwargs): | ||
''' | ||
run commands from __proxy__ | ||
:mod:`salt.proxy.onyx<salt.proxy.onyx>` | ||
command | ||
function from `salt.proxy.onyx` to run | ||
args | ||
positional args to pass to `command` function | ||
kwargs | ||
key word arguments to pass to `command` function | ||
.. code-block:: bash | ||
salt '*' onyx.cmd sendline 'show ver' | ||
salt '*' onyx.cmd show_run | ||
salt '*' onyx.cmd check_password username=admin | ||
password='$5$lkjsdfoi$blahblahblah' encrypted=True | ||
''' | ||
proxy_prefix = __opts__['proxy']['proxytype'] | ||
proxy_cmd = '.'.join([proxy_prefix, command]) | ||
if proxy_cmd not in __proxy__: | ||
return False | ||
for k in list(kwargs): | ||
if k.startswith('__pub_'): | ||
kwargs.pop(k) | ||
return __proxy__[proxy_cmd](*args, **kwargs) |
Oops, something went wrong.