salt.proxy.onyx module

Proxy Minion for Onyx OS Switches

The Onyx OS Proxy Minion uses the built in SSHConnection module in salt.utils.vt_helper

To configure the proxy minion:

proxy:
  proxytype: onyx
  host: 192.168.187.100
  username: admin
  password: admin
  prompt_name: switch
  ssh_args: '-o PubkeyAuthentication=no'
  key_accept: True
proxytype

(REQUIRED) Use this proxy minion onyx

host

(REQUIRED) ip address or hostname to connect to

username

(REQUIRED) username to login with

password

(REQUIRED) password to use to login with

prompt_name

(REQUIRED) The name in the prompt on the switch. By default, use your devices hostname.

ssh_args

Any extra args to use to connect to the switch.

key_accept

Whether or not to accept a the host key of the switch on initial login. Defaults to False.

The functions from the proxy minion can be run from the salt commandline using the salt.modules.onyx execution module.

salt.proxy.onyx.add_config(lines)

Add one or more config lines to the switch running config

salt '*' onyx.cmd add_config 'snmp-server community TESTSTRINGHERE rw'

Note

For more than one config added per command, lines should be a list.

salt.proxy.onyx.check_role(username, role)

Check if user is assigned a specific role on switch

salt '*' onyx.cmd check_role username=admin role=network-admin
salt.proxy.onyx.configure_terminal()

Shortcut to run configure terminal on switch

salt '*' onyx.cmd configure_terminal
salt.proxy.onyx.configure_terminal_exit()

Shortcut to run exit from configuration mode on switch

salt '*' onyx.cmd configure_terminal_exit
salt.proxy.onyx.delete_config(lines)

Delete one or more config lines to the switch running config

salt '*' onyx.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator'

Note

For more than one config deleted per command, lines should be a list.

salt.proxy.onyx.disable()

Shortcut to run disable on switch

salt '*' onyx.cmd disable
salt.proxy.onyx.enable()

Shortcut to run enable on switch

salt '*' onyx.cmd enable
salt.proxy.onyx.find(pattern)

Find all instances where the pattern is in the running command

salt '*' onyx.cmd find '^snmp-server.*$'

Note

This uses the re.MULTILINE regex format for python, and runs the regex against the whole show_run output.

salt.proxy.onyx.get_roles(username)

Get roles that the username is assigned from switch

salt.proxy.onyx.get_user(username)

Get username line from switch

salt.proxy.onyx.grains()

Get grains for proxy minion

salt.proxy.onyx.grains_refresh()

Refresh the grains from the proxy device.

salt.proxy.onyx.init(opts=None)

Required. Can be used to initialize the server connection.

salt.proxy.onyx.initialized()

module initialization

salt.proxy.onyx.ping()

Ping the device on the other end of the connection

salt.proxy.onyx.remove_user(username)

Remove user from switch

salt '*' onyx.cmd remove_user username=daniel
salt.proxy.onyx.replace(old_value, new_value, full_match=False)

Replace string or full line matches in switch's running config

If full_match is set to True, then the whole line will need to be matched as part of the old value.

salt '*' onyx.cmd replace 'TESTSTRINGHERE' 'NEWTESTSTRINGHERE'
salt.proxy.onyx.sendline(command)

Run command through switch's cli

salt.proxy.onyx.set_role(username, role)

Assign role to username

salt '*' onyx.cmd set_role username=daniel role=vdc-admin
salt.proxy.onyx.show_run()

Shortcut to run show run on switch

salt '*' onyx.cmd show_run
salt.proxy.onyx.show_ver()

Shortcut to run show ver on switch

salt '*' onyx.cmd show_ver
salt.proxy.onyx.shutdown()

Disconnect

salt.proxy.onyx.system_info()

Return system information for grains of the NX OS proxy minion

salt '*' onyx.system_info
salt.proxy.onyx.unset_role(username, role)

Remove role from username

salt '*' onyx.cmd unset_role username=daniel role=vdc-admin