Skip to content

Commit

Permalink
Merge pull request #5 from shiftky/implement_save_function
Browse files Browse the repository at this point in the history
Implement Save() function
  • Loading branch information
Yuki KIRII authored Jun 12, 2017
2 parents d53a8ab + 9b3f72b commit a110468
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tmsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tmsh
import (
"bufio"
"bytes"
"fmt"
"io"
"strings"

Expand Down Expand Up @@ -83,10 +84,26 @@ func (bigip *BigIP) ExecuteCommand(cmd string) (string, error) {
return strings.Join(lines, "\n"), nil
}

func (bigip *BigIP) Close() {
bigip.sshconn.Close()
func (bigip *BigIP) Save() error {
ret, err := bigip.ExecuteCommand("save /sys config current-partition")
if err != nil {
fmt.Errorf(ret)
}

if strings.Contains(ret, "Syntax Error: \"current-partition\" unknown property") {
ret, err = bigip.ExecuteCommand("save /sys config")
if err != nil {
fmt.Errorf(ret)
}
}

if strings.Contains(ret, "Error") {
return fmt.Errorf(ret)
}

return nil
}

func (bigip *BigIP) Save() {
bigip.Close()
func (bigip *BigIP) Close() {
bigip.sshconn.Close()
}

0 comments on commit a110468

Please sign in to comment.