rbeapi 0.5.1 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG.md +211 -76
  2. data/Gemfile +14 -3
  3. data/README.md +74 -38
  4. data/Rakefile +38 -17
  5. data/gems/inifile/inifile.spec.tmpl +31 -4
  6. data/gems/net_http_unix/net_http_unix.spec.tmpl +34 -8
  7. data/gems/netaddr/netaddr.spec.tmpl +31 -5
  8. data/guide/getting-started.rst +95 -64
  9. data/guide/installation.rst +27 -6
  10. data/guide/release-notes.rst +5 -1
  11. data/guide/testing.rst +5 -2
  12. data/guide/upgrading.rst +2 -0
  13. data/lib/rbeapi/api/dns.rb +8 -2
  14. data/lib/rbeapi/api/interfaces.rb +107 -21
  15. data/lib/rbeapi/api/ipinterfaces.rb +48 -0
  16. data/lib/rbeapi/api/prefixlists.rb +53 -23
  17. data/lib/rbeapi/api/routemaps.rb +11 -0
  18. data/lib/rbeapi/api/stp.rb +6 -3
  19. data/lib/rbeapi/api/switchports.rb +5 -11
  20. data/lib/rbeapi/api/system.rb +1 -1
  21. data/lib/rbeapi/api/users.rb +2 -0
  22. data/lib/rbeapi/api/varp.rb +6 -0
  23. data/lib/rbeapi/api/vlans.rb +44 -0
  24. data/lib/rbeapi/api/vrrp.rb +13 -0
  25. data/lib/rbeapi/client.rb +19 -4
  26. data/lib/rbeapi/switchconfig.rb +330 -0
  27. data/lib/rbeapi/version.rb +1 -1
  28. data/rbeapi.gemspec +2 -0
  29. data/rbeapi.spec.tmpl +30 -3
  30. data/spec/fixtures/.gitignore +1 -0
  31. data/spec/support/matchers/switch_config_sections.rb +80 -0
  32. data/spec/system/rbeapi/api/interfaces_base_spec.rb +32 -3
  33. data/spec/system/rbeapi/api/interfaces_ethernet_spec.rb +56 -8
  34. data/spec/system/rbeapi/api/interfaces_portchannel_spec.rb +33 -1
  35. data/spec/system/rbeapi/api/interfaces_vxlan_spec.rb +27 -0
  36. data/spec/system/rbeapi/api/ipinterfaces_spec.rb +34 -1
  37. data/spec/system/rbeapi/api/prefixlists_spec.rb +198 -0
  38. data/spec/system/rbeapi/api/stp_instances_spec.rb +49 -5
  39. data/spec/system/rbeapi/api/switchports_spec.rb +15 -9
  40. data/spec/system/rbeapi/api/vlans_spec.rb +46 -0
  41. data/spec/unit/rbeapi/api/interfaces/base_spec.rb +1 -1
  42. data/spec/unit/rbeapi/api/interfaces/ethernet_spec.rb +1 -1
  43. data/spec/unit/rbeapi/api/interfaces/portchannel_spec.rb +9 -2
  44. data/spec/unit/rbeapi/api/interfaces/vxlan_spec.rb +1 -1
  45. data/spec/unit/rbeapi/api/prefixlists/default_spec.rb +202 -0
  46. data/spec/unit/rbeapi/api/prefixlists/fixture_prefixlists.text +11 -0
  47. data/spec/unit/rbeapi/api/routemaps/default_spec.rb +5 -0
  48. data/spec/unit/rbeapi/api/switchports/default_spec.rb +4 -4
  49. data/spec/unit/rbeapi/api/system/default_spec.rb +5 -0
  50. data/spec/unit/rbeapi/api/system/fixture_system.text +1 -0
  51. data/spec/unit/rbeapi/api/vlans/default_spec.rb +30 -0
  52. data/spec/unit/rbeapi/api/vrrp/default_spec.rb +10 -0
  53. data/spec/unit/rbeapi/client_spec.rb +42 -0
  54. data/spec/unit/rbeapi/switchconfig2_spec.rb +119 -0
  55. data/spec/unit/rbeapi/switchconfig3_spec.rb +125 -0
  56. data/spec/unit/rbeapi/switchconfig_spec.rb +335 -0
  57. metadata +21 -7
data/Rakefile CHANGED
@@ -82,50 +82,65 @@ task all_rpms: :build do
82
82
  puts 'RPMs are available in rpms/noarch/'
83
83
  puts "Copy the RPMs to an EOS device then run the 'swix create' command."
84
84
  puts ' Examples: '
85
+ puts ' Chef client: '
86
+ puts ' cd /mnt/flash; \\'
87
+ puts " swix create rbeapi-chef-#{Rbeapi::VERSION}-1.swix \\"
88
+ puts " rubygem-rbeapi-chef-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
89
+ puts ' rubygem-inifile-chef-3.0.0-5.eos4.noarch.rpm \\'
90
+ puts ' rubygem-netaddr-chef-1.5.1-4.eos4.noarch.rpm \\'
91
+ puts ' rubygem-net_http_unix-chef-0.2.2-5.eos4.noarch.rpm'
85
92
  puts ' Puppet Open Source: '
86
93
  puts ' cd /mnt/flash; \\'
87
94
  puts " swix create rbeapi-#{Rbeapi::VERSION}-1.swix \\"
88
95
  puts " rubygem-rbeapi-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
89
- puts ' rubygem-inifile-3.0.0-3.eos4.noarch.rpm \\'
90
- puts ' rubygem-netaddr-1.5.0-2.eos4.noarch.rpm \\'
91
- puts ' rubygem-net_http_unix-0.2.1-3.eos4.noarch.rpm'
96
+ puts ' rubygem-inifile-3.0.0-5.eos4.noarch.rpm \\'
97
+ puts ' rubygem-netaddr-1.5.1-4.eos4.noarch.rpm \\'
98
+ puts ' rubygem-net_http_unix-0.2.2-5.eos4.noarch.rpm'
92
99
  puts ' Puppet-enterprise agent (3.x): '
93
100
  puts ' cd/mnt/flash; \\'
94
101
  puts " swix create rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix \\"
95
102
  puts " rubygem-rbeapi-puppet3-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
96
- puts ' rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \\'
97
- puts ' rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm'
103
+ puts ' rubygem-inifile-puppet3-3.0.0-5.eos4.noarch.rpm \\'
104
+ puts ' rubygem-netaddr-puppet3-1.5.1-4.eos4.noarch.rpm'
98
105
  puts ' Puppet-All-in-one agent (2015.x/4.x): '
99
106
  puts ' cd/mnt/flash; \\'
100
107
  puts " swix create rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix \\"
101
108
  puts " rubygem-rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \\"
102
- puts ' rubygem-inifile-puppet-aio-3.0.0-3.eos4.noarch.rpm \\'
103
- puts ' rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm \\'
104
- puts ' rubygem-net_http_unix-puppet-aio-0.2.1-3.eos4.noarch.rpm'
109
+ puts ' rubygem-inifile-puppet-aio-3.0.0-5.eos4.noarch.rpm \\'
110
+ puts ' rubygem-netaddr-puppet-aio-1.5.1-4.eos4.noarch.rpm \\'
111
+ puts ' rubygem-net_http_unix-puppet-aio-0.2.2-5.eos4.noarch.rpm'
105
112
  end
106
113
 
107
114
  desc 'Generate SWIX files from RPMs'
108
115
  task swix: :all_rpms do
109
116
  SWIX = 'PYTHONPATH=${PYTHONPATH}:/nfs/misc/tools/swix \
110
117
  /nfs/misc/tools/swix/swix'
111
- system "cd rpms/noarch;
118
+ system "(cd rpms/noarch;
112
119
  rm -f rbeapi-#{Rbeapi::VERSION}-1.swix;
113
120
  #{SWIX} create rbeapi-#{Rbeapi::VERSION}-1.swix \
114
121
  rubygem-rbeapi-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
115
- rubygem-inifile-3.0.0-3.eos4.noarch.rpm \
116
- rubygem-netaddr-1.5.0-2.eos4.noarch.rpm"
117
- system "cd rpms/noarch;
122
+ rubygem-inifile-3.0.0-5.eos4.noarch.rpm \
123
+ rubygem-netaddr-1.5.1-4.eos4.noarch.rpm \
124
+ rubygem-net_http_unix-0.2.2-5.eos4.noarch.rpm)"
125
+ system "(cd rpms/noarch;
126
+ rm -f rbeapi-chef-#{Rbeapi::VERSION}-1.swix;
127
+ #{SWIX} create rbeapi-chef-#{Rbeapi::VERSION}-1.swix \
128
+ rubygem-rbeapi-chef-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
129
+ rubygem-inifile-chef-3.0.0-5.eos4.noarch.rpm \
130
+ rubygem-netaddr-chef-1.5.1-4.eos4.noarch.rpm)"
131
+ system "(cd rpms/noarch;
118
132
  rm -f rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix;
119
133
  #{SWIX} create rbeapi-puppet3-#{Rbeapi::VERSION}-1.swix \
120
134
  rubygem-rbeapi-puppet3-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
121
- rubygem-inifile-puppet3-3.0.0-3.eos4.noarch.rpm \
122
- rubygem-netaddr-puppet3-1.5.0-2.eos4.noarch.rpm"
123
- system "cd rpms/noarch;
135
+ rubygem-inifile-puppet3-3.0.0-5.eos4.noarch.rpm \
136
+ rubygem-netaddr-puppet3-1.5.1-4.eos4.noarch.rpm)"
137
+ system "(cd rpms/noarch;
124
138
  rm -f rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix;
125
139
  #{SWIX} create rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.swix \
126
140
  rubygem-rbeapi-puppet-aio-#{Rbeapi::VERSION}-1.eos4.noarch.rpm \
127
- rubygem-inifile-puppet-aio-3.0.0-3.eos4.noarch.rpm \
128
- rubygem-netaddr-puppet-aio-1.5.0-2.eos4.noarch.rpm"
141
+ rubygem-inifile-puppet-aio-3.0.0-5.eos4.noarch.rpm \
142
+ rubygem-netaddr-puppet-aio-1.5.1-4.eos4.noarch.rpm \
143
+ rubygem-net_http_unix-puppet-aio-0.2.2-5.eos4.noarch.rpm)"
129
144
  SWIXS = `find rpms/noarch -name "rbeapi*swix" -ls`
130
145
  puts "\n################################################\n#"
131
146
  puts "The following artifacts are in rpms/noarch/\n#{SWIXS}"
@@ -155,6 +170,12 @@ task ci_spec: [:ci_prep, 'ci:setup:rspec', :spec]
155
170
 
156
171
  require 'rspec/core/rake_task'
157
172
  RSpec::Core::RakeTask.new(:spec)
173
+ RSpec::Core::RakeTask.new(:unit) do |t|
174
+ t.pattern = './**/unit/**/*_spec.rb'
175
+ end
176
+ RSpec::Core::RakeTask.new(:system) do |t|
177
+ t.pattern = './**/system/**/*_spec.rb'
178
+ end
158
179
 
159
180
  desc 'Generate typedoc.rst for the guide'
160
181
  task :typedoc do
@@ -3,7 +3,7 @@
3
3
 
4
4
  Name: %{?enterprise:pe-}rubygem-%{gem_name}
5
5
  Version: 3.0.0
6
- Release: 3.eos4
6
+ Release: 5.eos4
7
7
  Summary: INI file reader and writer
8
8
 
9
9
  Group: Development/Languages
@@ -49,6 +49,15 @@ are also possible
49
49
  var1 = baz
50
50
  var2 = shoodle.
51
51
 
52
+ %package chef
53
+ Summary: Inifile rubygem packaged for Chef
54
+ Group: Development/Languages
55
+ Requires: chef
56
+ Provides: chef-rubygem(%{gem_name}) = %{version}
57
+ Provides: chef-rubygem-%{gem_name} = %{version}
58
+ %description chef
59
+ The inifile rubygem packaged for Chef client on Arista EOS.
60
+
52
61
  %package puppet3
53
62
  Summary: Inifile rubygem packaged for Puppet 3.x on Arista EOS
54
63
  Group: Development/Languages
@@ -78,6 +87,9 @@ install %{SOURCE0} %{buildroot}/
78
87
  %files
79
88
  /%{gem_name}-%{version}.gem
80
89
 
90
+ %files chef
91
+ /%{gem_name}-%{version}.gem
92
+
81
93
  %files puppet3
82
94
  /%{gem_name}-%{version}.gem
83
95
 
@@ -85,15 +97,24 @@ install %{SOURCE0} %{buildroot}/
85
97
  /%{gem_name}-%{version}.gem
86
98
 
87
99
  %post
88
- GEM_OPTS="--no-document --local"
100
+ GEM_OPTS="--no-rdoc --no-ri --local"
89
101
  gem install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
90
102
 
91
103
  %preun
92
104
  gem uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
93
105
 
106
+ %post chef
107
+ GEM=/opt/chef/embedded/bin/gem
108
+ GEM_OPTS="--no-document --local"
109
+ ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
110
+
111
+ %preun chef
112
+ GEM=/opt/chef/embedded/bin/gem
113
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
114
+
94
115
  %post puppet3
95
116
  GEM=/opt/puppet/bin/gem
96
- GEM_OPTS="--no-document --local"
117
+ GEM_OPTS="--no-rdoc --no-ri --local"
97
118
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
98
119
 
99
120
  %preun puppet3
@@ -102,7 +123,7 @@ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
102
123
 
103
124
  %post puppet-aio
104
125
  GEM=/opt/puppetlabs/puppet/bin/gem
105
- GEM_OPTS="--no-document --local"
126
+ GEM_OPTS="--no-rdoc --no-ri --local"
106
127
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
107
128
 
108
129
  %preun puppet-aio
@@ -110,6 +131,12 @@ GEM=/opt/puppetlabs/puppet/bin/gem
110
131
  ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
111
132
 
112
133
  %changelog
134
+ * Tue May 24 2016 Jere Julian - 3.0.0-5
135
+ - Add chef package
136
+
137
+ * Wed Apr 6 2016 Jere Julian - 3.0.0-4
138
+ - Disable install of gem docs
139
+
113
140
  * Fri Oct 30 2015 Jere Julian - 3.0.0-3
114
141
  - Detect the location of the puppet-agent's gem install
115
142
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Name: %{?enterprise:pe-}rubygem-%{gem_name}
5
5
  Version: 0.2.1
6
- Release: 3.eos4
6
+ Release: 5.eos4
7
7
  Summary: Wrapper around Net::HTTP with AF_UNIX support
8
8
 
9
9
  Group: Development/Languages
@@ -19,9 +19,17 @@ BuildArch: noarch
19
19
  %description
20
20
  Wrapper around Net::HTTP with AF_UNIX support.
21
21
 
22
- %package puppet3
22
+ %package chef
23
23
  Group: Development/Languages
24
- Summary: Net_http_unix rubygem packaged for Puppet Enterprise 3.x agents
24
+ Summary: Net_http_unix rubygem packaged for Chef client
25
+ Requires: chef
26
+ Provides: chef-rubygem(%{gem_name}) = %{version}
27
+ Provides: chef-rubygem-%{gem_name} = %{version}
28
+ %description chef
29
+
30
+ %package puppet3
31
+ Group: Development/Languages
32
+ Summary: Net_http_unix rubygem packaged for Puppet Enterprise 3.x agents
25
33
  Requires: pe-ruby
26
34
  Requires: pe-rubygems
27
35
  Provides: pe-rubygem(%{gem_name}) = %{version}
@@ -29,7 +37,7 @@ Provides: pe-rubygem-%{gem_name} = %{version}
29
37
  %description puppet3
30
38
 
31
39
  %package puppet-aio
32
- Group: Development/Languages
40
+ Group: Development/Languages
33
41
  Summary: Net_http_unix rubygem packaged for Puppet All-In-One (4.x) agents
34
42
  Requires: puppet >= 4.0.0
35
43
  Provides: rubygem-%{gem_name} = %{version}
@@ -45,6 +53,9 @@ install %{SOURCE0} %{buildroot}/
45
53
  %files
46
54
  /%{gem_name}-%{version}.gem
47
55
 
56
+ %files chef
57
+ /%{gem_name}-%{version}.gem
58
+
48
59
  %files puppet3
49
60
  /%{gem_name}-%{version}.gem
50
61
 
@@ -52,15 +63,24 @@ install %{SOURCE0} %{buildroot}/
52
63
  /%{gem_name}-%{version}.gem
53
64
 
54
65
  %post
55
- GEM_OPTS="--no-document --local"
66
+ GEM_OPTS="--no-rdoc --no-ri --local"
56
67
  gem install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
57
68
 
58
69
  %preun
59
70
  gem uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
60
71
 
72
+ %post chef
73
+ GEM=/opt/chef/embedded/bin/gem
74
+ GEM_OPTS="--no-document --local"
75
+ ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
76
+
77
+ %preun chef
78
+ GEM=/opt/chef/embedded/bin/gem
79
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
80
+
61
81
  %post puppet3
62
82
  GEM=/opt/puppet/bin/gem
63
- GEM_OPTS="--no-document --local"
83
+ GEM_OPTS="--no-rdoc --no-ri --local"
64
84
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
65
85
 
66
86
  %preun puppet3
@@ -69,14 +89,20 @@ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
69
89
 
70
90
  %post puppet-aio
71
91
  GEM=/opt/puppetlabs/puppet/bin/gem
72
- GEM_OPTS="--no-document --local"
92
+ GEM_OPTS="--no-rdoc --no-ri --local"
73
93
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
74
94
 
75
95
  %preun puppet-aio
76
96
  GEM=/opt/puppetlabs/puppet/bin/gem
77
- ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1pckage puppet3
97
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
78
98
 
79
99
  %changelog
100
+ * Tue May 24 2016 Jere Julian - 0.2.1-5
101
+ - Add Chef package
102
+
103
+ * Wed Apr 6 2016 Jere Julian - 0.2.1-4
104
+ - Disable install of gem docs
105
+
80
106
  * Fri Oct 30 2015 Jere Julian - 0.2.1-3
81
107
  - Detect the location of the puppet-agent's gem install
82
108
 
@@ -2,8 +2,8 @@
2
2
  %global gem_name netaddr
3
3
 
4
4
  Name: %{?enterprise:pe-}rubygem-%{gem_name}
5
- Version: 1.5.0
6
- Release: 2.eos4
5
+ Version: 1.5.1
6
+ Release: 4.eos4
7
7
  Summary: A package for manipulating network addresses
8
8
  Group: Development/Languages
9
9
  License: Unknown
@@ -18,6 +18,14 @@ BuildArch: noarch
18
18
  %description
19
19
  A package for manipulating network addresses.
20
20
 
21
+ %package chef
22
+ Summary: NetAddr rubygem packaged for Chef client
23
+ Group: Development/Languages
24
+ Requires: chef
25
+ Provides: chef-rubygem(%{gem_name}) = %{version}
26
+ Provides: chef-rubygem-%{gem_name} = %{version}
27
+ %description chef
28
+
21
29
  %package puppet3
22
30
  Summary: NetAddr rubygem packaged for Puppet Enterprise 3.x agents
23
31
  Group: Development/Languages
@@ -44,6 +52,9 @@ install %{SOURCE0} %{buildroot}/
44
52
  %files
45
53
  /%{gem_name}-%{version}.gem
46
54
 
55
+ %files chef
56
+ /%{gem_name}-%{version}.gem
57
+
47
58
  %files puppet3
48
59
  /%{gem_name}-%{version}.gem
49
60
 
@@ -51,15 +62,24 @@ install %{SOURCE0} %{buildroot}/
51
62
  /%{gem_name}-%{version}.gem
52
63
 
53
64
  %post
54
- GEM_OPTS="--no-document --local"
65
+ GEM_OPTS="--no-rdoc --no-ri --local"
55
66
  gem install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
56
67
 
57
68
  %preun
58
69
  gem uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
59
70
 
71
+ %post chef
72
+ GEM=/opt/chef/embedded/bin/gem
73
+ GEM_OPTS="--no-document --local"
74
+ ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
75
+
76
+ %preun chef
77
+ GEM=/opt/chef/embedded/bin/gem
78
+ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
79
+
60
80
  %post puppet3
61
81
  GEM=/opt/puppet/bin/gem
62
- GEM_OPTS="--no-document --local"
82
+ GEM_OPTS="--no-rdoc --no-ri --local"
63
83
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
64
84
 
65
85
  %preun puppet3
@@ -68,7 +88,7 @@ ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
68
88
 
69
89
  %post puppet-aio
70
90
  GEM=/opt/puppetlabs/puppet/bin/gem
71
- GEM_OPTS="--no-document --local"
91
+ GEM_OPTS="--no-rdoc --no-ri --local"
72
92
  ${GEM} install ${GEM_OPTS} /%{gem_name}-%{version}.gem > /dev/null 2>&1
73
93
 
74
94
  %preun puppet-aio
@@ -76,6 +96,12 @@ GEM=/opt/puppetlabs/puppet/bin/gem
76
96
  ${GEM} uninstall %{gem_name} --version '= %{version}' > /dev/null 2>&1
77
97
 
78
98
  %changelog
99
+ * Tue May 24 2016 Jere Julian - 1.5.1-4
100
+ - Add Chef package
101
+
102
+ * Wed Apr 6 2016 Jere Julian - 1.5.0-3
103
+ - Disable install of gem docs
104
+
79
105
  * Fri Oct 30 2015 Jere Julian - 1.5.0-2
80
106
  - Detect the location of the puppet-agent's gem install
81
107
 
@@ -3,17 +3,26 @@ Getting Started
3
3
 
4
4
  .. contents:: :local:
5
5
 
6
- In order to use rbeapi, the EOS command API must be enabled using management api http-commands configuration mode. This library supports eAPI calls over both HTTP and UNIX Domain Sockets. Once the command API is enabled on the destination node, create a configuration file with the node properities.
6
+ In order to use rbeapi, the EOS command API must be enabled using management
7
+ api http-commands configuration mode. This library supports eAPI calls over
8
+ both HTTP and UNIX Domain Sockets. Once the command API is enabled on the
9
+ destination node, create a configuration file with the node properities.
7
10
 
8
- Note: The default search path for the conf file is ~/.eapi.conf followed by /mnt/flash/eapi.conf. This can be overridden by setting EAPI_CONF=<path file conf file> in your environment.
11
+ Note: The default search path for the conf file is ``~/.eapi.conf`` followed by
12
+ ``/mnt/flash/eapi.conf``. This can be overridden by setting
13
+ ``EAPI_CONF=<path/conf_file>`` in your environment.
9
14
 
10
15
  Example eapi.conf File
11
16
  ----------------------
12
17
 
13
- Below is an example of an eAPI conf file. The conf file can contain more than one node. Each node section must be prefaced by connection:<name> where <name> is the name of the connection.
18
+ Below is an example of an eAPI conf file. The conf file can contain more than
19
+ one node. Each node section must be prefaced by connection:<name> where <name>
20
+ is the name of the connection.
14
21
 
15
22
  The following configuration options are available for defining node entries:
16
23
 
24
+ .. code-block:: console
25
+
17
26
  host - The IP address or FQDN of the remote device. If the host parameter is omitted then the connection name is used
18
27
  username - The eAPI username to use for authentication (only required for http or https connections)
19
28
  password - The eAPI password to use for authentication (only required for http or https connections)
@@ -31,104 +40,126 @@ The following configuration options are available for defining node entries:
31
40
  open_timeout - The default number of seconds to wait for the eAPI connection to open. Any number may be used, including Floats for fractional seconds. Default value is 10 seconds.
32
41
  read_timeout - The default number of seconds to wait for one block of eAPI results to be read (via one read(2) call). Any number may be used, including Floats for fractional seconds. Default value is 10 seconds.
33
42
 
34
- Note: See the EOS User Manual found at arista.com for more details on configuring eAPI values.
43
+ Note: See the EOS User Manual found at arista.com for more details on
44
+ configuring eAPI values.
35
45
 
36
46
  All configuration values are optional.
37
47
 
38
- [connection:veos01]
39
- username: eapi
40
- password: password
41
- transport: http
48
+ .. code-block:: console
49
+
50
+ [connection:veos01]
51
+ username: eapi
52
+ password: password
53
+ transport: http
42
54
 
43
- [connection:veos02]
44
- transport: http
55
+ [connection:veos02]
56
+ transport: http
45
57
 
46
- [connection:veos03]
47
- transport: socket
58
+ [connection:veos03]
59
+ transport: socket
48
60
 
49
- [connection:veos04]
50
- host: 172.16.10.1
51
- username: eapi
52
- password: password
53
- enablepwd: itsasecret
54
- port: 1234
55
- transport: https
61
+ [connection:veos04]
62
+ host: 172.16.10.1
63
+ username: eapi
64
+ password: password
65
+ enablepwd: itsasecret
66
+ port: 1234
67
+ transport: https
56
68
 
57
- [connection:localhost]
58
- transport: http_local
69
+ [connection:localhost]
70
+ transport: http_local
59
71
 
60
- The above example shows different ways to define EOS node connections. All configuration options will attempt to use default values if not explicitly defined. If the host parameter is not set for a given entry, then the connection name will be used as the host address.
72
+ The above example shows different ways to define EOS node connections. All
73
+ configuration options will attempt to use default values if not explicitly
74
+ defined. If the host parameter is not set for a given entry, then the
75
+ connection name will be used as the host address.
61
76
 
62
77
  Configuring [connection:localhost]
63
78
  ----------------------------------
64
79
 
65
- The rbeapi library automatically installs a single default configuration entry for connecting to localhost host using a transport of sockets. If using the rbeapi library locally on an EOS node, simply enable the command API to use sockets and no further configuration is needed for rbeapi to function. If you specify an entry in a conf file with the name [connection:localhost], the values in the conf file will overwrite the default.
80
+ The rbeapi library automatically installs a single default configuration entry
81
+ for connecting to localhost host using a transport of sockets. If using the
82
+ rbeapi library locally on an EOS node, simply enable the command API to use
83
+ sockets and no further configuration is needed for rbeapi to function. If you
84
+ specify an entry in a conf file with the name [connection:localhost], the
85
+ values in the conf file will overwrite the default.
66
86
 
67
87
  Using rbeapi
68
88
  ------------
69
89
 
70
- The Ruby Client for eAPI was designed to be easy to use and implement for writing tools and applications that interface with the Arista EOS management plane.
90
+ The Ruby Client for eAPI was designed to be easy to use and implement for
91
+ writing tools and applications that interface with the Arista EOS management
92
+ plane.
71
93
 
72
94
  Creating a connection and sending commands
73
95
  ------------------------------------------
74
96
 
75
- Once EOS is configured properly and the config file created, getting started with a connection to EOS is simple. Below demonstrates a basic connection using rbeapi. For more examples, please see the examples folder.
97
+ Once EOS is configured properly and the config file created, getting started
98
+ with a connection to EOS is simple. Below demonstrates a basic connection using
99
+ rbeapi. For more examples, please see the examples folder.
76
100
 
77
- # start by importing the library
78
- require 'rbeapi/client'
101
+ .. code-block:: console
102
+ # start by importing the library
103
+ require 'rbeapi/client'
79
104
 
80
- # create a node object by specifying the node to work with
81
- node = Rbeapi::Client.connect_to('veos01')
105
+ # create a node object by specifying the node to work with
106
+ node = Rbeapi::Client.connect_to('veos01')
82
107
 
83
- # send one or more commands to the node
84
- node.enable('show hostname')
85
- node.enable('show hostname')
86
- => [{:command=>"show hostname", :result=>{"fqdn"=>"veos01.arista.com", "hostname"=>"veos01"}, :encoding=>"json"}]
108
+ # send one or more commands to the node
109
+ node.enable('show hostname')
110
+ node.enable('show hostname')
111
+ => [{:command=>"show hostname", :result=>{"fqdn"=>"veos01.arista.com", "hostname"=>"veos01"}, :encoding=>"json"}]
87
112
 
88
- # use the config method to send configuration commands
89
- node.config('hostname veos01')
90
- => [{}]
113
+ # use the config method to send configuration commands
114
+ node.config('hostname veos01')
115
+ => [{}]
91
116
 
92
- # multiple commands can be sent by using a list (works for both enable or config)
117
+ # multiple commands can be sent by using a list (works for both enable or config)
93
118
 
94
- node.config(['interface Ethernet1', 'description foo'])
95
- => [{}, {}]
119
+ node.config(['interface Ethernet1', 'description foo'])
120
+ => [{}, {}]
96
121
 
97
- # return the running or startup configuration from the node (output omitted for brevity)
122
+ # return the running or startup configuration from the node (output omitted for brevity)
98
123
 
99
- node.running_config
124
+ node.running_config
100
125
 
101
- node.startup_config
126
+ node.startup_config
102
127
 
103
128
  Using the API
104
129
  -------------
105
130
 
106
- The rbeapi library provides both a client for send and receiving commands over eAPI as well as an API for working directly with EOS resources. The API is designed to be easy and straightforward to use yet also extensible. Below is an example of working with the vlans API
131
+ The rbeapi library provides both a client for send and receiving commands over
132
+ eAPI as well as an API for working directly with EOS resources. The API is
133
+ designed to be easy and straightforward to use yet also extensible. Below is an
134
+ example of working with the vlans API
135
+
136
+ .. code-block:: console
107
137
 
108
- # create a connection to the node
109
- require 'rbeapi/client'
110
- node = Rbeapi::Client.connect_to('veos01')
138
+ # create a connection to the node
139
+ require 'rbeapi/client'
140
+ node = Rbeapi::Client.connect_to('veos01')
111
141
 
112
- # get the instance of the API (in this case vlans)
113
- vlans = node.api('vlans')
142
+ # get the instance of the API (in this case vlans)
143
+ vlans = node.api('vlans')
114
144
 
115
- # return all vlans from the node
116
- vlans.getall
117
- => {"1"=>{:name=>"tester", :state=>"active", :trunk_groups=>[]},
118
- "4"=>{:name=>"VLAN0004", :state=>"active", :trunk_groups=>[]},
119
- "100"=>{:name=>"TEST_VLAN_100", :state=>"active", :trunk_groups=>[]},
120
- "300"=>{:name=>"VLAN0300", :state=>"active", :trunk_groups=>[]}}
145
+ # return all vlans from the node
146
+ vlans.getall
147
+ => {"1"=>{:name=>"tester", :state=>"active", :trunk_groups=>[]},
148
+ "4"=>{:name=>"VLAN0004", :state=>"active", :trunk_groups=>[]},
149
+ "100"=>{:name=>"TEST_VLAN_100", :state=>"active", :trunk_groups=>[]},
150
+ "300"=>{:name=>"VLAN0300", :state=>"active", :trunk_groups=>[]}}
121
151
 
122
- # return a specific vlan from the node
123
- vlans.get(1)
124
- => {:name=>"tester", :state=>"active", :trunk_groups=>[]}
152
+ # return a specific vlan from the node
153
+ vlans.get(1)
154
+ => {:name=>"tester", :state=>"active", :trunk_groups=>[]}
125
155
 
126
- # add a new vlan to the node
127
- vlans.create(400)
128
- => true
156
+ # add a new vlan to the node
157
+ vlans.create(400)
158
+ => true
129
159
 
130
- # set the new vlan name
131
- vlans.set_name(100, value: 'foo')
132
- => true
160
+ # set the new vlan name
161
+ vlans.set_name(100, value: 'foo')
162
+ => true
133
163
 
134
- All API implementations developed by Arista EOS+ CS are found in the rbeapi/api folder. See the examples folder for additional examples.
164
+ All API implementations developed by Arista EOS+ CS are found in the rbeapi/api
165
+ folder. See the examples folder for additional examples.