CG-Net is a simple netmiko like package for go to manage cisco devices.
Currently, It's possible to connect to devices using telnet and ssh.
Tested on various cisco catalyst switches, ASRs and ISRs. Other devices should also be possible (:
go get github.com/Letsu/cgnet
Get Version and configure a loopback interface
package main
import (
"fmt"
"github.com/Letsu/cgnet"
)
func main() {
d := cgnet.Device{
Ip: "10.10.10.10",
Username: "cisco",
Password: "cisco",
Enable: "cisco",
ConnType: cgnet.SSH,
}
err := d.Open()
defer d.Close()
if err != nil {
panic(err)
}
ver, err := d.Exec("sh version")
if err != nil {
panic(err)
}
fmt.Println(ver)
cmds := []string{"interface loopback10", "ip address 10.10.10.11 255.255.255.255", "no shut"}
err = d.Configure(cmds)
if err != nil {
panic(err)
}
}