Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
#
# Written by: Mark Berly
import argparse
import pprint
from jsonrpclib import Server
# connect to the switch either via http or https
@markberly
markberly / gist:6bf398697a7c4809ee72
Last active February 6, 2020 21:10
Monitor an interface on an Arista Networks EOS powered switch (via Python and eAPI) and uses Growl to provide its status
#!/usr/bin/python
#
# Written by: Mark Berly
import argparse
from jsonrpclib import Server
from gntp.notifier import mini
intf2Monitor = "Ethernet 48"
@markberly
markberly / addLoopbacks.py
Created May 22, 2014 13:28
A quick script to add 100 loopback interfaces to a network elemenet, designed to work with Arista EOS eAPI (via JSON RPC) written in python
#!/usr/bin/python
import argparse
from jsonrpclib import Server
def connect( sIpOrHostname, username, password, secure=True ):
return Server( "%s://%s:%s@%s/command-api"
% ( "http" if not secure else "https", password, username, sIpOrHostname ) )
def addLoopback( switch, enablePass, intfLo, ipAddr ):
rc = switch.runCmds( 1, [ { "cmd": "enable", "input": enablePass },
@markberly
markberly / getEventMonitorMac.py
Created February 17, 2014 20:30
Arista EOS eAPI tool to get Event Monitor data and convert from text format to string to make it easier to manipulate
#!/usr/bin/python
#
# Copyright (c) 2014
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@markberly
markberly / updateRoute.py
Created February 14, 2014 22:17
Arista EOS eAPI, Ever want a quick solution to your SDN traffic steering whoas, here is a shot script that allows you to push or remove static routes from an Arista EOS powered switch. The updateRoute script can be used in order to add or delete routes from the routing table.
#!/usr/bin/python
#
# Copyright (c) 2012-2013, Arista Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@markberly
markberly / portAutoDescription.py
Created February 14, 2014 22:14
Port auto-description tool automatically updates the port description of an interface based on the lldp neighbor information of the attached device. Utilizes Arista EOS eAPI.
#!/usr/bin/python
#
# Copyright (c) 2013, Arista Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@markberly
markberly / yodaSpeaks.py
Created February 12, 2014 15:31
Let Yoda 'speak' a short python script that uses a API on Mashape API, found at: https://www.mashape.com/ismaelc/yoda-speak. You need to register and insert a Mashape-Authorization key in order to use the API. Have fun...
#!/usr/bin/python
import urllib2, urllib, argparse
# goto: https://www.mashape.com
# you need to create a Mashape account insert your key
# if you do not do this the script will fail
mashapeAuthorization = "MASHAPE_KEY"
def drawYoda () :
@markberly
markberly / getInfo.py
Last active February 8, 2017 05:30
A short script to provide more detail about the devices connected to an ethernet switch, enhancing 'show mac address' to include OUI vendor info (via API call so you must have access to the Internet) and LLDP neighbor information. Built using Arista EOS eAPI.
#!/usr/bin/python
#
# Written by: Mark Berly
#
# Copyright (c) 2014, Arista Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: