Skip to content

Instantly share code, notes, and snippets.

View mathershifter's full-sized avatar

Jesse Mather mathershifter

View GitHub Profile
@mathershifter
mathershifter / goeapishowrib.go
Last active March 14, 2024 19:44
Example user-defined module for goeapi
package main
import (
"fmt"
"github.com/aristanetworks/goeapi"
)
type ShowRibRouteIp struct {
RibRoutesByProtocol map[string]Protocol
! **Make sure to change the common-name to match your environment**
security pki certificate generate self-signed switch.crt key switch.key generate rsa 2048 validity 30000 parameters common-name myswitch.lab.lan
!
configure
!
management security
ssl profile SELFSIGNED
certificate switch.crt key switch.key
!
management api gnmi
@mathershifter
mathershifter / arssh.py
Last active March 17, 2021 21:10
Arista SSH client
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Arista Networks, Inc. All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.
"""
Example:
>>> sess = ssh.Session()
>>> sess.open("ck327", auth=("admin", ""))
>>> print(sess.send("show ver"))
@mathershifter
mathershifter / eossdk_helloworld_config.md
Last active November 13, 2020 23:48
EOSSDK HelloWorld configuration

EOSSDK Agent Install Example

copy the agent

host# chmod +x HelloWorld.py
host# scp HelloWorld.py admin@<switch>:/mnt/flash/HelloWorld

create the mount profile script

@mathershifter
mathershifter / docker-snat.md
Last active October 30, 2020 17:38
Example docker network to source packets from a specific IP address/interface

Example TOPO:

[      Node A     ]           [        Node B       ]           [     Node C      ]
[Lo0:1.1.1.1] [et0] <- Eth -> [et0] lo0:1.1.1.2 [et1] <- Eth -> [et1] [lo0:1.1.1.3]

Note: EtX interface IP addresses are not advertised; packets must be sourced from a loopback interface to make a successful round trip.

Sample Script

# Example:
#
# source ceoslab.rc
#
# run-netc ceos1-net
# run-netc ceos2-net
#
# for i in `seq 1 16`
# do
# link-netc ceos1-net ceos2-net eth${i} eth${i}
@mathershifter
mathershifter / tunnelmon.go
Last active August 14, 2020 20:25
Golang eAPI example
package main
import (
"fmt"
"net"
"github.com/aristanetworks/goeapi"
)
type ShowIsisDatabase struct {
@mathershifter
mathershifter / eapiclient.py
Last active November 16, 2021 20:40
Python3 eAPI client with no external dependencies
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2020 Arista Networks, Inc. All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.
"""Simple EAPI Client
API Usage:
import eapiclient
@mathershifter
mathershifter / gonso.go
Last active April 15, 2020 23:01
Experimenting with sockets in a namespace
// +build go1.10
// Demo listening on a socket inside an network namespace
package main
import (
"bufio"
"fmt"
"net"
@mathershifter
mathershifter / demohttpserver.go
Created September 30, 2019 18:23
Go DEMO HTTP server
// Copyright (c) 2019 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package main
import (
"fmt"
"io/ioutil"
"log"