Skip to content

Commit

Permalink
fix tplink not sending enable
Browse files Browse the repository at this point in the history
Closes #3271
  • Loading branch information
robertcheramy committed Nov 29, 2024
1 parent 7a07357 commit 970bb17
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Changed

### Fixed

- tplink: send 'enable' before the enable password. Fixes #3271 (@robertcheramy)


## [0.31.0 – 2024-11-29]
Expand Down
22 changes: 22 additions & 0 deletions docs/Creating-Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ The API documentation contains a list of [methods](https://github.com/ytti/oxidi

A more fleshed out example can be found in the `IOS` and `JunOS` models.

### Common task: mechanism for handling 'enable' mode
The following code snippet demonstrates how to handle sending the 'enable'
command and an enable password.

This example is taken from the `IOS` model. It covers scenarios where users
need to enable privileged mode, either without providing a password (by setting
`enable: true` in the configuration) or with a password.

```ruby
cfg :telnet, :ssh do
post_login do
if vars(:enable) == true
cmd "enable"
elsif vars(:enable)
cmd "enable", /^[pP]assword:/
cmd vars(:enable)
end
end
end
```
Note: remove `:telnet, ` if your device does not support telnet.

## Extending an existing model with a new command

The example below can be used to extend the `JunOS` model to collect the output of `show interfaces diagnostics optics` and append the output to the configuration file as a comment. This command retrieves DOM information on pluggable optics present in a `JunOS`-powered chassis.
Expand Down
1 change: 1 addition & 0 deletions lib/oxidized/model/tplink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TPLink < Oxidized::Model
if vars(:enable) == true
cmd "enable"
elsif vars(:enable)
cmd "enable", /^[pP]assword:/
cmd vars(:enable)
end
end
Expand Down

0 comments on commit 970bb17

Please sign in to comment.