mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
converted junos proxy minion to new __proxy__ global
added cli() in junos.py module to execute arbitrary command
This commit is contained in:
parent
07cac0b434
commit
28eff3caf2
3 changed files with 35 additions and 27 deletions
|
@ -43,11 +43,10 @@ def defaults():
|
|||
|
||||
|
||||
def facts():
|
||||
if 'proxymodule' in __opts__:
|
||||
if 'junos.facts' in __opts__['proxymodule']:
|
||||
facts = __opts__['proxymodule']['junos.facts']()
|
||||
facts['version_info'] = 'override'
|
||||
return facts
|
||||
if 'junos.facts' in __proxy__:
|
||||
facts = __proxy__['junos.facts']()
|
||||
facts['version_info'] = 'override'
|
||||
return facts
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
@ -52,17 +52,16 @@ def facts_refresh():
|
|||
Reload the facts dictionary from the device. Usually only needed
|
||||
if the device configuration is changed by some other actor.
|
||||
'''
|
||||
|
||||
return __opts__['proxymodule']['junos.refresh']()
|
||||
return __proxy__['junos.refresh']()
|
||||
|
||||
|
||||
def call_rpc():
|
||||
return __opts__['proxymodule']['junos.rpc']()
|
||||
return __proxy__['junos.rpc']()
|
||||
|
||||
|
||||
def set_hostname(hostname=None, commit_change=True):
|
||||
|
||||
conn = __opts__['proxymodule']['junos.conn']()
|
||||
conn = __proxy__['junos.conn']()
|
||||
ret = dict()
|
||||
if hostname is None:
|
||||
ret['out'] = False
|
||||
|
@ -84,7 +83,7 @@ def set_hostname(hostname=None, commit_change=True):
|
|||
|
||||
def commit():
|
||||
|
||||
conn = __opts__['proxymodule']['junos.conn']()
|
||||
conn = __proxy__['junos.conn']()
|
||||
ret = {}
|
||||
commit_ok = conn.cu.commit_check()
|
||||
if commit_ok:
|
||||
|
@ -104,7 +103,7 @@ def commit():
|
|||
|
||||
def rollback():
|
||||
ret = dict()
|
||||
conn = __opts__['proxymodule']['junos.conn']()
|
||||
conn =__proxy__['junos.conn']()
|
||||
|
||||
ret['out'] = conn.cu.rollback(0)
|
||||
|
||||
|
@ -118,7 +117,7 @@ def rollback():
|
|||
|
||||
def diff():
|
||||
|
||||
conn = __opts__['proxymodule']['junos.conn']()
|
||||
conn = __proxy__['junos.conn']()
|
||||
ret = dict()
|
||||
ret['out'] = True
|
||||
ret['message'] = conn.cu.diff()
|
||||
|
@ -128,7 +127,17 @@ def diff():
|
|||
|
||||
def ping():
|
||||
|
||||
conn = __opts__['proxymodule']['junos.conn']()
|
||||
conn = __proxy__['junos.conn']()
|
||||
ret = dict()
|
||||
ret['message'] = conn.probe()
|
||||
ret['out'] = True
|
||||
|
||||
return ret
|
||||
|
||||
def cli(command):
|
||||
|
||||
conn = __proxy__['junos.conn']()
|
||||
ret = dict()
|
||||
ret['message'] = conn.cli(command)
|
||||
ret['out'] = True
|
||||
return ret
|
||||
|
|
|
@ -10,9 +10,9 @@ from __future__ import absolute_import
|
|||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
# import jnpr.junos
|
||||
# import jnpr.junos.utils
|
||||
# import jnpr.junos.utils.config
|
||||
import jnpr.junos
|
||||
import jnpr.junos.utils
|
||||
import jnpr.junos.utils.config
|
||||
import json
|
||||
HAS_JUNOS = True
|
||||
|
||||
|
@ -22,17 +22,17 @@ thisproxy = {}
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# def __init__(opts):
|
||||
# '''
|
||||
# Open the connection to the Junos device, login, and bind to the
|
||||
# Resource class
|
||||
# '''
|
||||
# log.debug('Opening connection to junos')
|
||||
# thisproxy['conn'] = jnpr.junos.Device(user=opts['proxy']['username'],
|
||||
# host=opts['proxy']['host'],
|
||||
# password=opts['proxy']['passwd'])
|
||||
# thisproxy['conn'].open()
|
||||
# thisproxy['conn'].bind(cu=jnpr.junos.utils.config.Config)
|
||||
def init(opts):
|
||||
'''
|
||||
Open the connection to the Junos device, login, and bind to the
|
||||
Resource class
|
||||
'''
|
||||
log.debug('Opening connection to junos')
|
||||
thisproxy['conn'] = jnpr.junos.Device(user=opts['proxy']['username'],
|
||||
host=opts['proxy']['host'],
|
||||
password=opts['proxy']['passwd'])
|
||||
thisproxy['conn'].open()
|
||||
thisproxy['conn'].bind(cu=jnpr.junos.utils.config.Config)
|
||||
|
||||
|
||||
def conn():
|
||||
|
|
Loading…
Add table
Reference in a new issue