forked from aristanetworks/goeapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 858 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"github.com/aristanetworks/goeapi"
)
type showVersionResp struct {
ModelName string
InternalVersion string
SystemMacAddress string
SerialNumber string
MemTotal int
BootupTimestamp float64
MemFree int
Version string
Architecture string
InternalBuildID string
HardwareRevision string
}
func (s *showVersionResp) GetCmd() string {
return "show version"
}
func main() {
node, err := goeapi.ConnectTo("dut")
if err != nil {
panic(err)
}
svRsp := &showVersionResp{}
handle, _ := node.GetHandle("json")
handle.AddCommand(svRsp)
if err := handle.Call(); err != nil {
panic(err)
}
fmt.Printf("Version : %s\n", svRsp.Version)
fmt.Printf("System MAC : %s\n", svRsp.SystemMacAddress)
fmt.Printf("Serial Number : %s\n", svRsp.SerialNumber)
}