Skip to content

Commit

Permalink
Handle FortiOS devices with vdom.
Browse files Browse the repository at this point in the history
  • Loading branch information
udhos committed Mar 10, 2017
1 parent a1c02b8 commit cae654b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion dev/model_fortios.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ func registerModelFortiOS(logger hasPrintf, t *DeviceTable) {
*/

// preferred method for disabling pager
a.CommandList = []string{"config system console", "set output standard", "end", "get system status", "show"}
a.CommandList = []string{
"config system global", // enter config: valid only for vdom
"config system console", // enter config: valid only for non-vdom
"set output standard", // disable paging
"end", // exit config
"get system status", // system information
"show", // get configuration
}

promptPattern := `\S+\s#\s$` // "hostname # "
a.DisabledPromptPattern = promptPattern
Expand Down
7 changes: 5 additions & 2 deletions dev/model_fortios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type optionsFortiOS struct {
requestPassword bool
breakConn bool
vdom bool
}

func TestFortiOS1(t *testing.T) {
Expand Down Expand Up @@ -57,7 +58,7 @@ func TestFortiOS2(t *testing.T) {

// launch bogus test server
addr := ":2002"
s, listenErr := spawnServerFortiOS(t, addr, optionsFortiOS{})
s, listenErr := spawnServerFortiOS(t, addr, optionsFortiOS{vdom: true})
if listenErr != nil {
t.Errorf("could not spawn bogus FortiOS server: %v", listenErr)
}
Expand Down Expand Up @@ -214,7 +215,9 @@ LOOP:
break LOOP
case strings.HasPrefix(str, "ex"): //exit
break LOOP
case strings.HasPrefix(str, "config system console"):
case !options.vdom && strings.HasPrefix(str, "config system console"):
config = true
case options.vdom && strings.HasPrefix(str, "config system global"):
config = true
case strings.HasPrefix(str, "end"):
config = false
Expand Down

0 comments on commit cae654b

Please sign in to comment.