Skip to content

Instantly share code, notes, and snippets.

@imbriaco
Created May 18, 2013 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imbriaco/5605757 to your computer and use it in GitHub Desktop.
Save imbriaco/5605757 to your computer and use it in GitHub Desktop.
Hacking on a Ruby client for the new Arista Networks Command API
[1] pry(main)> host, user, password = %w(EAPI_HOST EAPI_USER EAPI_PASSWORD).map { |n| ENV[n] }; nil
=> nil
[2] pry(main)> Arista::EAPI::Switch.new(host, user, password).version
=> {:model_name=>"DCS-7048T-A-R",
:internal_version=>"4.12.0-1244071.EOS4120",
:system_mac_address=>"00:1c:73:16:c2:c8",
:serial_number=>"*redacted*",
:mem_total=>4009152,
:bootup_timestamp=>1368735672.686644,
:mem_free=>1851640,
:version=>"4.12.0",
:architecture=>"i386",
:internal_build_id=>"c25ec8ea-cb8f-40a8-af0b-d11eaa94d57c",
:hardware_revision=>"01.04"}
@chad
Copy link

chad commented May 18, 2013

Are you familiar with Hash#values_at?

Arista::EAPI::Switch.new(ENV.values_at(*%w(EAPI_HOST EAPI_USER EAPI_PASSWORD))

It'll change your life :trollface:

@imbriaco
Copy link
Author

Learn something new every day! Thanks, @chad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment