func main() { node, err := goeapi.ConnectTo("dut") if err != nil { panic(err) } conf := node.RunningConfig() fmt.Println(conf) var showversion module.ShowVersion handle, _ := node.GetHandle("json") handle.Enable(&showversion) fmt.Println("\nVersion:", showversion.Version) s := module.Show(node) showData := s.ShowVersion() fmt.Printf("\nModelname : %s\n", showData.ModelName) fmt.Printf("Internal Version : %s\n", showData.InternalVersion) fmt.Printf("System MAC : %s\n", showData.SystemMacAddress) fmt.Printf("Serial Number : %s\n", showData.SerialNumber) fmt.Printf("Mem Total : %d\n", showData.MemTotal) fmt.Printf("Bootup Timestamp : %.2f\n", showData.BootupTimestamp) fmt.Printf("Mem Free : %d\n", showData.MemFree) fmt.Printf("Version : %s\n", showData.Version) fmt.Printf("Architecture : %s\n", showData.Architecture) fmt.Printf("Internal Build ID : %s\n", showData.InternalBuildID) fmt.Printf("Hardware Revision : %s\n", showData.HardwareRevision) sys := module.System(node) if ok := sys.SetHostname("Ladie"); !ok { fmt.Printf("SetHostname Failed\n") } sysInfo := sys.Get() fmt.Printf("\nSysinfo: %#v\n", sysInfo.HostName()) }
func main() { node, err := goeapi.ConnectTo("dut") if err != nil { panic(err) } commands := []string{"show version"} conf, _ := node.Enable(commands) for k, v := range conf[0] { fmt.Println("k:", k, "v:", v) } }
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) }
func main() { node, err := goeapi.ConnectTo("dut") if err != nil { panic(err) } sv := &MyShowVlan{} handle, _ := node.GetHandle("json") handle.AddCommand(sv) if err := handle.Call(); err != nil { panic(err) } for k, v := range sv.Vlans { fmt.Printf("Vlan:%s\n", k) fmt.Printf(" Name : %s\n", v.Name) fmt.Printf(" Status: %s\n", v.Status) } }
func TestMain(m *testing.M) { fmt.Println("Export_test.go") runConf = GetFixture("running_config.text") goeapi.LoadConfig(GetFixture("dut.conf")) conns := goeapi.Connections() fmt.Println("Connections: ", conns) for _, name := range conns { if name != "localhost" { node, _ := goeapi.ConnectTo(name) duts = append(duts, node) } } // Create a Node with a DummyConnection to be used in // UnitTests. dummyConnection = NewDummyEapiConnection("", "", "", "", 0) dummyNode = &goeapi.Node{} dummyNode.SetAutoRefresh(true) dummyNode.SetConnection(dummyConnection) // os.Exit(m.Run()) }
func main() { node, err := goeapi.ConnectTo("dut") if err != nil { panic(err) } shVerRsp := &showVersionResp{} shHostnameRsp := &showHostName{} shVlanRsp := &showVlan{} shIntRsp := &showInterfacesStatus{} handle, _ := node.GetHandle("json") handle.AddCommand(shVerRsp) handle.AddCommand(shHostnameRsp) handle.AddCommand(shVlanRsp) handle.AddCommand(shIntRsp) if err := handle.Call(); err != nil { panic(err) } fmt.Printf("Hostname : %s\n", shHostnameRsp.HostName) fmt.Printf("Version : %s\n", shVerRsp.Version) fmt.Printf("System MAC : %s\n", shVerRsp.SystemMacAddress) fmt.Printf("Serial Number : %s\n", shVerRsp.SerialNumber) fmt.Println("\nInterface Description Line Link") fmt.Println("-------------------------------------------------") for intf, v := range shIntRsp.InterfaceStatuses { fmt.Printf("%-14s %-16s %-6s %-12s\n", intf, v.Description, v.LineProtocolStatus, v.LinkStatus) } fmt.Println("") for vlanID, v := range shVlanRsp.Vlans { fmt.Printf("VlanID:%s %s\n", vlanID, v.String()) } }