Chapter 16. The EOS Extension System

EOS is the Extensible Operating System, so let’s have some fun and extend it!

OK, so my idea of fun is installing extensions into a networking switch. What can I say? I’m living the dream.

Extensions are nothing more than one or more RPMs zipped up with a manifest file. These extensions have the filename extension .swix, for SoftWare Image eXtension. For those who are not familiar with Linux, RPM stands for RPM Package Manager. If that makes you twitch because your fifth-grade teacher wouldn’t let you use the word being defined within the definition, you’re not alone. RPM originally stood for Red Hat Package Manager, which is far less likely to offend a fifth-grade teacher’s sensibilities. The reason for the change is that RPMs are used in many more operating systems these days, even if the recursive name gives me hives.

RPMs are packages that usually contain compiled code. Using an RPM is just like downloading a program from the internet that needs to be unpacked and installed. On a Windows machine, you might download an Installer, whereas on a Mac, you might download a DMG image that contains a PKG package file. The idea is the same. RPMs are just the way Linux handles packages. Because EOS is running on Linux, it’s only natural to use RPMs to add extensions. If you’re familiar with Linux, you probably know about repositories that allow you to do things like add packages and all of the required dependencies with ease. Arista disables access to these repositories for the very valid reason that doing something like upgrading Linux might break EOS. To counter this, the extension system exists, which allows you to install packages with all of their dependencies in a single file. You can also use the extension system to install single RPMs, which is how Arista deploys security patches.

So, what sort of extensions can you add? If you are a skilled programmer, I’d say that you can add anything you want! In fact, we’ll be installing a package that I wrote. A quick place to look for existing extensions is on Arista’s EOS Extensions web page, which you can find on the EOS Central site. You also can search GitHub for Arista extensions or just go to the software downloads page on arista.com. Any extensions I write are on my GADify GitHub page.

For this example, I use the extension CPU-Hist, which I wrote. This extension adds functionality similar to Cisco’s show proc cpu hist command using gnuplot (another extension that we need to add).

First, I need to download the package. I have a lab server set up, so I just used that to get my files.

With my hostname set and the file located on my server, I can copy directly from the web server to my switch. To accomplish this, I do what most of us do and look at what my options are by using the ? character at the command prompt:

Arista#copy ?
  boot-extensions        Copy boot extensions configuration
  certificate:           Source file path
  clean-config           Copy from clean, default, configuration
  drive:                 Source file path
  extension:             Source file path
  file:                  Source file path
  flash:                 Source file path
  ftp:                   Source file path
  http:                  Source file path
  https:                 Source file path
  installed-extensions   Copy installed extensions status
  running-config         Copy from current system configuration
  scp:                   Source file path
  sftp:                  Source file path
  startup-config         Copy from startup configuration
  system:                Source file path
  terminal:              Source file path
  tftp:                  Source file path

As you can see, there are a lot of options. For this example, I use http:, but note that you can copy from secure websites (https:), secure copy (scp:), and a bunch of other cool options. I include the entire URL and then include the destination extension:

Arista#copy http://10.0.0.100/RPM/CPU-Hist-1-4.swix extension:
Copy completed successfully.

If the file is small, as this one is, you might see a message flash so quickly that you can’t see it. Don’t worry too much about it; it’s more important for huge files or for files being transferred over slow connections. If you’re really wondering (as I was) what it says, here’s a snapshot while downloading a generic huge file:

Arista#copy http://www.gad.net/RPM/HugeFile.zip extension:
'RPM/HugeFile.zip' at 5235283 (3%) [Receiving data]

Because this extension actually requires another extension, I need to grab that one, as well:

Arista#copy http://10.0.0.100/RPM/GnuPlot-EOS-4-15-2.swix extension:
Copy completed successfully.
Note

I should point out that I could add GnuPlot to my own CPU-Hist extension and make it a single installation, but the way I wrote it allows for it to work in text-only mode for sites that might not want to install GnuPlot.

To see what’s in your extension: drive, you can use the dir extension: command from EOS:

Arista#dir extension:
Directory of extension:/

       -rwx       13895      Apr 17 21:10  CPU-Hist-1-4.swix
       -rwx     4375995      Apr 17 21:10  GnuPlot-EOS-4-15-2.swix

3564371968 bytes total (2246819840 bytes free)

A much better command to use is the show extensions command:

Arista#sho extensions
Name                             Version/Release     Status extension
-------------------------------- ------------------- ------ ----
CPU-Hist-1-4.swix                1/4                 A, NI     1
GnuPlot-EOS-4-15-2.swix          1.10.0/1.fc14       A, NI    18

A: available | NA: not available | I: installed | NI: not installed |
F: forced

This command shows some great information about the extensions, including the version, if it’s available, and whether it’s installed.

Note

If you’re using a chassis-based switch like the Arista 7500s, you’ll need to copy extensions on all supervisors.

So now that we have our RPMs, let’s get those suckers installed. To do so, simply use the extension command, followed by the name of the extension. You can use the ? character to get a list of available extensions:

Arista#extension GnuPlot-EOS-4-15-2.swix
Arista#extension CPU-Hist-1-4.swix

Success! If your extension has modified anything at the EOS command line, you’ll need to log out and back in to see the effects, though extensions that do this generally warn you about this fact.

With our extensions successfully installed, let’s check the status again by using the show extensions command:

Arista#show extensions
Name                             Version/Release     Status extension
-------------------------------- ------------------- ------ ----
CPU-Hist-1-4.swix                1/4                 A, I      1
GnuPlot-EOS-4-15-2.swix          1.10.0/1.fc14       A, I     18

A: available | NA: not available | I: installed | NI: not installed |
 F: forced

The flag under the Status column now shows an I (installed), whereas before we installed it, it showed an NI (not installed).

So, what do these extensions get us, anyway? The GnuPlot extension basically installed the GnuPlot open source graphing tool and all of its dependencies onto the switch. The CPU-Hist extension records CPU utilization and uses GnuPlot to graph it. The CPU-Hist tool accesses with the cpuhist command, which is actually an alias installed by the RPM during the extension installation process:

Arista#cpuhist sec


                        CPU Utilization - 180 Seconds

100 ++-------------------------------------------------------------+
    |                                                              |
    |                                                              |
 75 ++                                                             |
    |                                                              |
    |                                                              |
 50 ++                                                             |
    |                                                              |
    |                                                              |
    |            *                                                 |
 25 ++           *                    *                   **       |
    |           **                    *                   **       |
    |****** * * ** * * *  *** **** * **** * * **** * ** * ** * * ***
  0 +***************************************************************
    0      20     40     60     80    100    120    140    160    180
                                Seconds

Here’s the output of cpuhist min after about an hour:

Arista#cpuhist min


                          CPU Utilization - 3 Hours

100 ++-------------------------------------------------------------+
    |                                                              |
    |                                                              |
 75 ++                                                             |
    |                                                              |
    |           .                                                  |
 50 ++          .           .                                      |
    |                                                              |
    |                                                              |
    ............#..........                                        |
 25 ..  .  .   .#.  ...    .                                       |
    |           #  .                                               |
    #########################                                      |
  0 ########################.---+------+------+------+------+------+
    0      20     40     60     80    100    120    140    160    180
                                Minutes

To remove an extension, just negate the extension command used to install it:

Arista#no extension CPU-Hist-1-4.swix
Arista#no extension GnuPlot-EOS-4-15-2.swix

Note that this does not remove the extension; instead, it just makes them inactive:

Arista#sho extensions
Name                              Version/Release   Status extension
--------------------------------- ----------------- ------ ----
CPU-Hist-1-4.swix                 1/4               A, NI     1
GnuPlot-EOS-4-15-2.swix           1.10.0/1.fc14     A, NI    18

A: available | NA: not available | I: installed | NI: not installed |
 F: forced

If you want to completely remove an extension, delete it from the extensions: device:

Arista#del extension:CPU-Hist-1-4.swix
Arista#del extension:GnuPlot-EOS-4-15-2.swix
Arista#sho extensions
No extensions are available

If you’re wondering what the extensions: device really is, it is nothing more than a hidden directory on flash:

Arista#bash ls -al /mnt/flash | grep extensions
drwxrwx--- 2 root eosadmin      4096 Nov 27 21:49 .extensions

There is a limitation of extensions: their status of being installed does not survive a reboot. If you’d like extensions to be installed when the system boots, use the copy installed-extensions boot-extensions command. Here I’ve put them both back, installed them, and then configured them to load after boot:

Arista#copy http://10.0.0.100/RPM/GnuPlot-EOS-4-15-2.swix extension:
Copy completed successfully.
Arista#copy http://10.0.0.100/RPM/CPU-Hist-1-4.swix extension:
Copy completed successfully.
Arista#extension CPU-Hist-1-4.swix
Arista#extension GnuPlot-EOS-4-15-2-min.swix
Arista#copy installed-extensions boot-extensions
Copy completed successfully.

“Boot extensions” is really just a file on flash that contains a list of extensions to be loaded:

Arista#dir boot*
Directory of flash:/boot*

       -rwx          27           Nov 22 17:00  boot-config
       -rwx          46           Nov 27 21:53  boot-extensions

3564371968 bytes total (2246811648 bytes free)

Here’s what the boot-extensions file looks like:

Arista#more flash:boot-extensions
CPU-Hist-1-4.swix
GnuPlot-EOS-4-15-2-min.swix

Even on EOS version 4.21.1F, there is seemingly no way to get rid of the boot extension entry for a deleted extension. There is no del boot-extensions command available, and I could find no other way to delete it from within the command-line interface (CLI). Luckily, this is EOS, and there’s always another way. The list of items in the boot-extension directory is simply a list of extension names found in flash. Here’s the contents of the boot extensions file from Bash:

Arista(config)#bash

Arista Networks EOS shell

[admin@Arista ~]$ more /mnt/flash/boot-extensions
CPU-Hist-1-4.swix
GnuPlot-EOS-4-15-2-min.swix

To delete one line, use vi from Bash and delete the line. In the past, if you just deleted the file, you’d get an error when trying to view it, but that is no longer the case in modern EOS:

[admin@Arista ~]$ cd /mnt/flash
[admin@Arista flash]$ mv boot-extensions GAD
[admin@Arista flash]$ exit
logout
Arista(config)#
Arista(config)#
Arista(config)#sho boot-extensions
Arista(config)#

There are many other cool extensions out there, from Apache to DHCP, and myriad other cool tools. You can find many of them in the EOS Central repository (registration required). Even if you don’t extend your switch using something like my CPU-Hist package, if Arista releases a patch for a bug fix or security advisory, it will usually be installed using the extension system.

Here’s a snapshot of one of my switches running an older version of code that has not only CPU-Hist installed, but also the Apache server as well as a patch for Arista Security Advisory #15 (you can view security advisories on arista.com):

Old-Arista#sho extensions
Name                           Version/Release     Status RPMs
------------------------------ ------------------- ------ ----
CPU-Hist-1-3.swix              1/3                 A, I      1
GnuPlot-4.4.0.swix             1.2.14/11.fc14      A, I     42
httpd.swix                     2.2.17/1.fc14       A, NI     7
secAdvisory0015.swix           1.0.0/SA15          A, I      1

A: available | NA: not available | I: installed | NI: not installed F: forced

One final note about extensions is in order. Extensions are loaded very early in the boot process, which means that you can actually have CLI commands in the startup-config that rely on them.

Conclusion

When I first started at Arista, I envisioned a world in which everyone was writing software extensions that could be used to make EOS even better. Although that does happen, most of the time I see the extension system being used for things like security or bug patches. The big players, though are absolutely writing custom extensions for their switches, and even their own agents, through something called the EOS SDK, but that is outside the scope of this book. Talk to your account team if you’d like to know more about the EOS SDK.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset