EOS APIs - Meetupfiles.meetup.com/3747522/EOS.pdf · 3 My switch is a Linux server! Arista#bash...

Preview:

Citation preview

1

EOS APIs Andrei Dvornic

andrei@arista.com

My network deploys itself…

How about yours?

2

EOS fundamentals

§  Standard Linux kernel

§  Unique multi-process state sharing architecture that separates networking state from the processing itself

§  ExtensibleOS

Linux Kernel

Data Plane

3

My switch is a Linux server!

Arista#bash

Arista Networks EOS shell

[admin@localhost ~]$ uname -rpo

2.6.32.28.Ar-856351.EOS4102 x86_64 GNU/Linux

4

EOS built-in extensibility

§  /mnt/flash/rc.eos §  executed during the first phase of EOS boot process

§  CLI Scheduler

(config)# #  schedule  myscript  interval  60  max-­‐log-­‐files  3  command  /mnt/flash/myScript  

§  Event Manager (config)# event-handler mydaemon

(config-event-handler)# action bash /usr/bin/immortalize --daemonize /mnt/flash/myDaemon

(config-event-handler)# trigger onBoot

§  Process manager (config)# daemon MYDAEMON

(config-daemon-MYDAEMON)# command /mnt/flash/myDaemon

 

5

XMPP

 

vEOS-L2#xmpp send veos-l1 command show version message from user: veos-l1@jabber.vlab.com -------------------------------------------------- Arista vEOS Hardware version: Serial number: System MAC address: 0800.27f5.b860 Software image version: 4.13.0-1672898.4133F.1 (engineering build) Architecture: i386 Internal build version: 4.13.0-1672898.4133F.1 Internal build ID: 607a8116-2de1-4def-8ab9-9cccbc9da7e9 Uptime: 4 hours and 16 minutes Total memory: 2033864 kB Free memory: 197240 kB

6

Command API

 

Nginx  

HTTP request

HTTP response

JSON EOS

7

Command API

 

localhost(config)#  management  api  http-­‐commands    localhost(config-­‐mgmt-­‐api-­‐http-­‐cmds)#  no  shutdown  

     localhost#  show  management  api  http-­‐commands  Enabled:                Yes  HTTPS  server:      running,  set  to  use  port  443  HTTP  server:        shutdown,  set  to  use  port  80  ...  

Python example (more on GitHub/EOS Central)

from  jsonrpclib  import  Server  switch  =  Server(  ‘https://username:passw0rd@myswitch/command-­‐api’  )    response  =  switch.runCmds(  1,  [  ‘show  version’  ]  )  print  ‘The  system  MAC  addess  is  %s’  %  \                response[  0  ][  ‘systemMacAddress’  ]  print  ‘Switch  has  %d  bytes  of  memory  free!’  %  \              response[  0  ][  ‘memFree’  ]

8

pyeapi

import pyeapi

pyeapi.connect_to('veos01')

vlans = node.api('vlans')

vlans.getall()

{'1': {'state': 'active', 'name': 'default', 'vlan_id': 1, 'trunk_groups': []},

'10': {'state': 'active', 'name': 'VLAN0010', 'vlan_id':

10, 'trunk_groups':

[]}}

vlans.create(100)

vlans.set_name(100, 'foo')

eAPI  

pyeapi  

eapish   Ansible  

9

eapish – eAPI from bash

$ eapish show version --hosts veos01

$ eapish show version, show hostname --hosts veos01

$ eapish show version --hosts veos01,veos02,veos03

$ eapish vlan 100, name TEST_VLAN --hosts veos01,veos02,veos03 --config

eAPI  

eapish   Ansible  

pyeapi  

10

Arista role for Ansible

$ ansible-playbook add_vlan.yml PLAY [example] ****************************************************************

TASK: [Configure EOS VLAN resources] ******************************************

ok: [s7152] => (item={'name': 'TEST_VLAN_100', 'vlanid': 100})

PLAY RECAP ********************************************************************

s7152 : ok=1 changed=0 unreachable=0 failed=0

eAPI  

eapish   Ansible  

pyeapi  

11

What else?

eAPI  

eapish   Ansible   Puppet  

pyeapi   rbeapi   telemetry  

Splunk   Log  insight  

12

Reactive eAPI

Nginx  react via eAPI

stream data

EOS

VM Google Protocol Buffers

13

Reactive eAPI

Nginx  react via eAPI

stream data

EOS

VM Google Protocol Buffers

14

Sim API

 

Nginx      

HTTP request

HTTP response

JSON

SimAPI  EOS

{ "cmds" : { "show my version": { "result" : { "version" : 1 } “delay” : 3 }, "show port-channel detail": { "plugin" : "show_port_channel_detail", …

15

EOS SDK - Unleash the full power of EOS

Linux Kernel

Data Plane

16

Automating deployment

Zero Touch Provisioning -  Switch is plugged in and connected -  Because it doesn’t have a startup-config yet, will enter ZTP mode:

1.  DHCP query is sent on all interfaces with a link 2.  the server returns an IP address (to-be-configured on the

receiving interface), along with the address of the config/bootstrap script (DHCP - option 66,67)

3.  switch configures IP address and retrieves config/bootstrap script

4.  switch applies config/runs bootstrap script 5.  switch reboots

ZTP  Server  APIs  enables  extensible  node  provisioning      

17

QUESTIONS?

Recommended