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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/mitchellh/mapstructure" | |
) |
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
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 | |
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
import json | |
from jsonrpclib import Server | |
switches = ["172.22.28.156", "172.22.28.157", "172.22.28.158"] | |
username = "admin" | |
password = "admin" | |
# Going through all the switch IP addresses listed above | |
for switch in switches: | |
urlString = "https://{}:{}@{}/command-api".format(username, password, switch) |
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
# Create an object which represents session options | |
# -SkipCACheck and -SkipCNCheck are used to skip SSL certificate checks | |
$so = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl | |
# Switch credentials | |
$password = ConvertTo-SecureString "password" -AsPlainText -Force | |
$credentials = New-Object System.Management.Automation.PSCredential( "admin", $password ) | |
# Create a session to the switch | |
$switch = "172.22.28.159" |
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
[[local|localrc]] | |
HOST_IP=172.22.28.204 | |
# Interface connected to switch | |
FLAT_INTERFACE=eth1 | |
# Logging settings | |
LOGDAYS=1 | |
LOGFILE=$DEST/logs/stack.sh.log | |
SCREEN_LOGDIR=$DEST/logs/screen |
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 libvirt | |
import xml.etree.ElementTree as ET | |
def findDomainWithMac(conn, addr): | |
domlist = map(conn.lookupByID, conn.listDomainsID()) | |
for dom in domlist: | |
root = ET.fromstring(dom.XMLDesc()) | |
searchString = "./devices/interface/mac[@address='{0}']".format(addr) | |
if (root.find(searchString) is not None): | |
return dom |
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
:ssh.start | |
{:ok, cref} = :ssh.connect('10.55.3.1', 22, [{:user, 'user'}, {:password, 'password'}]) | |
{:ok, cid} = :ssh_connection.session_channel(cref, 5000) | |
:ssh_connection.exec(cref, cid, String.to_char_list("show ver | xml | no-more"), 3000) | |
#:ssh_connection.exec(cref, cid, String.to_char_list("show core"), 3000) | |
# need to do a receive on the cref(pid) | |
#flush() -- useful to find out what the result will look like | |
receive do | |
{:ssh_cm, _, {:data, _, _, d}} -> IO.puts d | |
end |