This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jsonrpclib import Server | |
import time | |
username = "fredlhsu" | |
password = "arista" | |
host = "172.22.28.37" | |
def getInterfaceStats(): | |
dictionary = eApiCall() | |
interfaces = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jsonrpclib import Server | |
username = "admin" | |
password = "admin" | |
host = "172.22.28.156" | |
sip = "10.1.1.1" | |
smac = "0000.aaaa.bbbb" | |
dmac = "1111.aaaa.bbbb" | |
urlString = "https://{}:{}@{}/command-api".format(username, password, switch) | |
switchReq = Server( urlString ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jsonrpclib import Server | |
username = "admin" | |
password = "admin" | |
host = "172.22.28.156" | |
dip = "10.1.1.1" | |
outport = "Port-Channel 100" | |
urlString = "https://{}:{}@{}/command-api".format(username, password, switch) | |
switchReq = Server( urlString ) | |
# The following rpc request will match on the source IP, then change both source and dest mac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
"io/ioutil" | |
"encoding/json" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jsonrpclib | |
import time | |
name = "demo1" | |
switchReq = jsonrpclib.Server("http://admin:admin@" + name + | |
"/command-api") | |
for i in range(3,2545: | |
ipaddr = "ip address 2.2.2.{}/24".format(i) | |
response = switchReq.runCmds(1, ["enable", "configure", "interface ethernet 52", ipaddr]) | |
print "trying " + ipaddr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jsonrpclib import Server | |
switch = Server( "https://admin:admin@leaf1/command-api" ) | |
response = switch.runCmds( 1, ["show vrf"], "text" ) | |
lines = response[0]['output'].splitlines() | |
for line in lines: | |
print line | |
for i in range(2, len(lines) - 1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fredhsu/go-eapi" | |
//"time" | |
) | |
func main() { | |
cmds2 := []string{"enable", "show running-config"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fredhsu/go-eapi" | |
) | |
func main() { | |
cmds2 := []string{"enable", "show running-config"} | |
url1 := "https://admin:admin@bleaf1/command-api/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fredhsu/go-eapi" | |
) | |
func main() { | |
cmds2 := []string{"enable", "show running-config"} | |
url1 := "https://admin:admin@bleaf1/command-api/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fredhsu/go-eapi" | |
) | |
func configFetcher(url string, cmds []string, format string, c chan eapi.JsonRpcResponse) { | |
response := eapi.Call(url, cmds, format) | |
c <- response |
OlderNewer