Go for Network Automation?

blov · · 667 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I want to write a program that will hop through a bunch of Cisco devices and do some basic configurations or pull configs from our TFTP server. I know this can be done in Python, using the pexpect module, for example.</p> <p>Is it possible to do this in Go? I would love to write a Go script over python</p> <hr/>**评论:**<br/><br/>nemith: <pre><p>It is sad that screen scraping ssh/telnet output is still a think in 2018. Try to find alternative, more automation friendly, interfaces like NETCONF, RESTCONF, Arista EAPI, etc and push on your vendors to support them.</p> <p>For RESTCONF and Arista EAPI just a small wrapper around net/http.Client. For NETCONF I have wrote a (basic) library <a href="https://github.com/Juniper/go-netconf" rel="nofollow">https://github.com/Juniper/go-netconf</a>.</p> <p>You can still fall back to screen scraping, but try alternatives first.</p> <p>Go and Networks are perfect together. The concurrency makes automating a network of 100, 1,000, 10,000 or 100,000 devices very easy. </p></pre>HighWizardSully: <pre><blockquote> <p>It is sad that screen scraping ssh/telnet output is still a think in 2018</p> </blockquote> <p>You&#39;re telling me! </p></pre>pdffs: <pre><p>Expect (the library that inspired pexpect) has been around for decades. There are quite a number of Expect implementations in Go to choose from, Google&#39;s implementation is one example:</p> <p><a href="https://github.com/google/goexpect" rel="nofollow">https://github.com/google/goexpect</a></p> <p>You can find alternatives by searching for &#39;golang expect&#39;.</p></pre>Redundancy_: <pre><p>I&#39;ve done something similar (cdb integration), but the concurrency and timeouts while managing a process can be challenging. There are some libraries that might help, although I haven&#39;t tried them: <a href="https://github.com/shavac/gexpect/blob/master/examples/ssh.go" rel="nofollow">https://github.com/shavac/gexpect/blob/master/examples/ssh.go</a></p> <p>So there&#39;s no reason you can&#39;t, but YMMV.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

667 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传