Skip to content

Commit

Permalink
feat(frr): enable privileged mode
Browse files Browse the repository at this point in the history
this is needed to send configuration

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Oct 14, 2023
1 parent 61fe35c commit 1962819
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pkg/utils/telnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,36 @@ func TelnetDialAndCommunicate(ctx context.Context, command string) (string, erro
if err != nil {
return "", err
}

// command
err = conn.SkipUntil(">")
if err != nil {
return "", err
}
_, err = conn.Write([]byte(command + "\n"))

// privileged
_, err = conn.Write([]byte("enable\n"))
if err != nil {
return "", err
}
err = conn.SkipUntil("Password: ")
if err != nil {
return "", err
}
_, err = conn.Write([]byte(password + "\n"))
if err != nil {
return "", err
}
err = conn.SkipUntil("#")
if err != nil {
return "", err
}

// command
_, err = conn.Write([]byte(command + "\n"))
if err != nil {
return "", err
}
// response
data, err := conn.ReadBytes('>')
data, err := conn.ReadBytes('#')
if err != nil {
return "", err
}
Expand Down

0 comments on commit 1962819

Please sign in to comment.