junos-ez-stdlib 0.1.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +6 -14
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +8 -0
  5. data/.travis.yml +18 -0
  6. data/CHANGELOG.md +60 -19
  7. data/Gemfile +7 -0
  8. data/README.md +41 -30
  9. data/Rakefile +6 -0
  10. data/SUGGESTION-BOX/README.md +32 -0
  11. data/docs/Providers/Group.md +61 -0
  12. data/docs/Providers/L2ports.md +1 -1
  13. data/docs/Providers/LAGports.md +57 -0
  14. data/docs/Providers/Vlans.md +1 -1
  15. data/examples/config/config_file.rb +0 -0
  16. data/examples/config/config_template_object.rb +0 -0
  17. data/examples/config/config_template_simple.rb +0 -0
  18. data/examples/config/load_sample.conf +129 -0
  19. data/examples/config/load_sample.set +3 -0
  20. data/examples/config/load_template_main.conf +7 -0
  21. data/examples/config/load_template_object.conf +7 -0
  22. data/examples/config/multi_config.rb +0 -0
  23. data/examples/fs_utils.rb +0 -0
  24. data/examples/lag_port.rb +27 -0
  25. data/examples/re_upgrade.rb +0 -0
  26. data/examples/re_utils.rb +0 -0
  27. data/examples/simple.rb +0 -1
  28. data/examples/st_hosts.rb +0 -0
  29. data/examples/user.rb +0 -0
  30. data/examples/vlans.rb +4 -4
  31. data/junos-ez-stdlib.gemspec +25 -14
  32. data/lib/junos-ez/exceptions.rb +0 -0
  33. data/lib/junos-ez/facts.rb +5 -7
  34. data/lib/junos-ez/facts/chassis.rb +6 -0
  35. data/lib/junos-ez/facts/ifd_style.rb +6 -3
  36. data/lib/junos-ez/facts/personality.rb +6 -6
  37. data/lib/junos-ez/facts/switch_style.rb +11 -2
  38. data/lib/junos-ez/facts/version.rb +24 -9
  39. data/lib/junos-ez/group.rb +206 -0
  40. data/lib/junos-ez/ip_ports.rb +0 -0
  41. data/lib/junos-ez/ip_ports/classic.rb +2 -2
  42. data/lib/junos-ez/l1_ports.rb +0 -0
  43. data/lib/junos-ez/l1_ports/classic.rb +0 -0
  44. data/lib/junos-ez/l1_ports/switch.rb +0 -0
  45. data/lib/junos-ez/l2_ports.rb +18 -9
  46. data/lib/junos-ez/l2_ports/bridge_domain.rb +499 -0
  47. data/lib/junos-ez/l2_ports/vlan.rb +3 -3
  48. data/lib/junos-ez/l2_ports/vlan_l2ng.rb +502 -0
  49. data/lib/junos-ez/lag_ports.rb +268 -0
  50. data/lib/junos-ez/provider.rb +4 -8
  51. data/lib/junos-ez/stdlib.rb +2 -0
  52. data/lib/junos-ez/system.rb +0 -0
  53. data/lib/junos-ez/system/users.rb +5 -7
  54. data/lib/junos-ez/utils/config.rb +0 -0
  55. data/lib/junos-ez/utils/fs.rb +0 -0
  56. data/lib/junos-ez/utils/re.rb +0 -0
  57. data/lib/junos-ez/version.rb +4 -1
  58. data/lib/junos-ez/vlans.rb +4 -1
  59. data/lib/junos-ez/vlans/bridge_domain.rb +7 -3
  60. data/lib/junos-ez/vlans/vlan.rb +4 -3
  61. data/lib/junos-ez/vlans/vlan_l2ng.rb +126 -0
  62. metadata +142 -64
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjZiNjRhZDYwMmQ4N2IxODdhOGM1YzUyNzY4M2Q5MmNkM2JjOTAxZQ==
5
- data.tar.gz: !binary |-
6
- YTA1YzNjNWE4OTgyNTg2M2JkNGFkMzhjMGQ3OWY5MzA1Mjg3ZTA4Nw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NTAxYTA0NTU3Y2RjMDg3ZWU0NTExYjVkNDdjOGJhMDdhNTg5Nzg3NDg5Yzc2
10
- Y2E4OTlkZmY2ZmNjNjRmZGFmOTQxOTMyMTVhYmExYjczZWZkZWYwNGY2YWFl
11
- OWVmZjEzZDJhZWFlYjcxNDI1M2VmOWVmMjY4ZDFkY2QwYWM1ZmE=
12
- data.tar.gz: !binary |-
13
- N2Y1NzgyYjE5MzYzYWQ4ZDliMWY3Zjg3MWVlNGIyNGE5YTU5NDExNzZjMDg4
14
- YzU1NDliNmJjYTgwYzA2Y2UwMmNjZDMxNWU1ZGM0MjZhZDBmZDExYmU1YmZk
15
- NTBhZGE4YjE5ZDRhZTk0ODE1ZGQ2Mzc0MmU3Y2E5NDM2OWJiYjQ=
2
+ SHA1:
3
+ metadata.gz: c697205390d0ed04e57f3c85a19e990953fb4805
4
+ data.tar.gz: e64aa12fab174460cc502e8b441dff3661a7fbad
5
+ SHA512:
6
+ metadata.gz: 4c82a99479059c7349217f6ddc9a0f9292c0b79c65a4539a6c8b626e65d1f402c6aa9d805111efb1d9182b2d820c56e691fbfe3ea47511e7219167e21c2220b4
7
+ data.tar.gz: 2c52b83d9e6f28063d7756be9152a8f0651bc00acf9c537192ca1e9469dde58e9d67d99197c3004b50e9407de58f73dd1bcf2afb89604d98d9c40c6272f66c3b
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .ruby-version
11
+ *.gem
12
+ coverage
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,8 @@
1
+ LineLength:
2
+ Enabled: false
3
+
4
+ Style/ClassAndModuleChildren:
5
+ Enabled: false
6
+
7
+ Documentation:
8
+ Enabled: false
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3-p551
5
+ - 2.0.0-p648
6
+ - 2.1.9
7
+ - 2.2.5
8
+ - 2.3.1
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: 1.9.3-p551
12
+ - rvm: 2.0.0-p648
13
+ fast_finish: true
14
+ before_install: gem update --remote bundler
15
+ install:
16
+ - bundle install --retry=3
17
+ script:
18
+ - bundle exec rake build
@@ -1,62 +1,103 @@
1
1
  # 2013-April
2
2
 
3
3
  0.0.10: 2013-04-26
4
-
4
+
5
5
  Initial release of code into RubyGems. Code tested on EX and SRX-branch. Consider this code
6
6
  as "early-adopter". Comments/feedback is welcome and appreciated.
7
7
 
8
8
  0.0.11: 2013-04-26
9
-
9
+
10
10
  Updated Junos::Ez::RE::Utils
11
11
  #memory changed :procs from Hash to Array
12
12
  #users changed return from Hash to Array
13
-
13
+
14
14
  0.0.12: 2013-04-26
15
-
15
+
16
16
  Updated Junos::Ez::FS:Utils#ls to include :symlink information
17
17
  Adding Junos::Ez::Users::Provider for login management
18
18
  Adding Junos::Ez::UserAuths::Provider for SSH-key management
19
-
19
+
20
20
  0.0.14: 2013-04-28
21
-
21
+
22
22
  Completed initial documentation. Still more work to be done with these files
23
23
  but the "enough to get started" information is now available
24
-
24
+
25
25
  # 2013-May
26
26
 
27
27
  0.0.15: 2013-05-02
28
-
28
+
29
29
  L2ports - added support for framework to read [edit vlans] stanza to recognize interfaces configured
30
30
  there vs. under [edit interfaces]
31
-
31
+
32
32
  IPports - added :acl_in and :acl_out for stateless ACL filtering. added .status method to return
33
33
  runtime status information about the port
34
-
34
+
35
35
  RE::Utils - misc updates, and documentation
36
36
 
37
37
  0.0.16: 2013-05-03
38
-
38
+
39
39
  RE::Utils - added support for license-key management. Renamed "software" methods from "xxx_software"
40
40
  to "software_xxx" to be consistent with other naming usage. Updated docs.
41
-
41
+
42
42
  0.0.17: 2013-05-05
43
-
43
+
44
44
  FS::Utils - updated docs. fixed methods so that all "error" scenarios raise IOError excaptions.
45
-
45
+
46
46
  0.1.0: 2013-05-06
47
-
47
+
48
48
  All docs and code _finished_ for the inital release of code. Always more to do, but at this
49
49
  point, declaring the framework "good for early adopter testing". Looking forward to bug-reports,
50
50
  please open issues against this repo. Thank you!
51
-
51
+
52
52
  0.1.1: 2013-05-29
53
-
53
+
54
54
  Fixed a small bug in fact gathering for hardwaremodel
55
-
55
+
56
56
  # 2013-July
57
57
 
58
58
  0.1.2: 2013-07-04
59
-
59
+
60
60
  Fixed issue#3. Previously this gem would not work with non-VC capable EX switches. Updated
61
61
  the `facts/version.rb` file to handle these devices. Also added a new fact `:vc_capable` that
62
62
  is set to `true` if the EX can support virtual-chassis, and `false` if it cannot.
63
+
64
+ # 2013-Aug
65
+
66
+ 0.2.0:
67
+
68
+ Fixed issue #6. Added support for EX4300 platform. Added new provider for Link Aggregation Group
69
+ resources (LAGports)
70
+
71
+ # 2016-March
72
+
73
+ 1.0.0:
74
+
75
+ Fixed issues
76
+ Issue #17 Add support for OCX device.
77
+ Issue #20 "under development" error is thrown while importing the interface_create recipe from the Chef-Server.
78
+ Issue #22 "netdev_vlan" resource action delete is not working fine while invoking from the JUNOS Chef-Client.
79
+ Issue #23 RPC command error: commit-configuration is getting thrown on Invoking the "netdev_lag" resource from
80
+ JUNOS Chef Client.
81
+ Issue #27 Duplicate declaration of lag configuration in a recipe is giving NoMethodError: undefined method
82
+ `properties' for nil:NilClass.
83
+ Issue #30 Error in rerunning netdev_lag interface.
84
+ Issue #33 undefined method `properties' for nil:NilClass error is thrown if the backup RE is unreachable.
85
+ Issue #35 Error in running chef client from Backup RE.
86
+ Issue #39 Getting 'Junos::Ez::NoProviderError' error on qfx device.
87
+ Issue #42 Raise exception to handle warnings in <error-severity>.
88
+
89
+ Enhancement
90
+ * Add support for configuring l2_interface on MX device.
91
+ * Add support for provider 'group' for configuring JUNOS groups.
92
+
93
+ # 2016-August
94
+
95
+ 1.0.3
96
+ Fixed issues
97
+ Issue #46 Removing references to rake from gemspec
98
+ Issue #47 cannot get the git source code
99
+
100
+ Enhancement
101
+ * Valid project metadata and rake for cleanly building/releasing
102
+ * Test hooks and badges
103
+ * netconf gem pessimistic version constraint to 0.3.1
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'simplecov', require: false, group: :test
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
+ [![Gem Version](https://badge.fury.io/rb/junos-ez-stdlib.svg)](https://badge.fury.io/rb/junos-ez-stdlib)[![Dependency Status](https://gemnasium.com/badges/github.com/Juniper/ruby-junos-ez-stdlib.svg)](https://gemnasium.com/github.com/Juniper/ruby-junos-ez-stdlib)
2
+ [![Build Status](https://travis-ci.org/Juniper/ruby-junos-ez-stdlib.svg?branch=master)](https://travis-ci.org/Juniper/ruby-junos-ez-stdlib)
3
+
1
4
  # OVERVIEW
2
5
 
3
6
  Ruby framework to support Junos OS based device management automation.
4
7
 
5
8
  This is the "standard library" or "core" set of functionality that should work on most/all Junos OS based devices.
6
9
 
7
- This framework is build on top of the NETCONF gem which uses XML as the fundamental data-exchange. So no
8
- "automating the CLI" or using SNMP. The purpose of this framework is to **enable automation development
10
+ This framework is build on top of the NETCONF gem which uses XML as the fundamental data-exchange. So no
11
+ "automating the CLI" or using SNMP. The purpose of this framework is to **enable automation development
9
12
  without requiring specific Junos XML knowledge**.
10
13
 
11
14
  Further documentation can be found in the *docs* subdirectory.
@@ -14,32 +17,32 @@ Further documentation can be found in the *docs* subdirectory.
14
17
 
15
18
  The framework is comprised of these basic eloements:
16
19
 
17
- - Facts:
20
+ - Facts:
18
21
 
19
22
  A Hash of name/value pairs of information auto-collected. Fact values can be Hash structures as well
20
23
  so you can have deeply nested fact data. You can also define your own facts in addition to the "stdlib" facts.
21
24
  The facts are used by the framework to create a platform indepent layer of abstraction. This means
22
25
  that managing a VLAN, for example, is the same regardless of the underlying hardware platofrm (EX, QFX,
23
26
  MX, SRX, ...)
24
-
25
- - Resources:
26
27
 
27
- Resources allow you to easily configure and perform operational functions on specific items within Junos,
28
+ - Resources:
29
+
30
+ Resources allow you to easily configure and perform operational functions on specific items within Junos,
28
31
  for example VLANs, or switch ports. A resource has *properties* that you manipuate as Hash. You can
29
- interact with Junos using resource methods like `read!`, `write!`, `delete!`, `activate!`, `deactivate!`, etc.
32
+ interact with Junos using resource methods like `read!`, `write!`, `delete!`, `activate!`, `deactivate!`, etc.
30
33
  For a complete listing of resource methods, refer to the *docs* directory
31
-
34
+
32
35
  - Providers:
33
36
 
34
37
  Providers allow you to manage a collection of resource, and most commonly, select a resource.
35
38
  The purpose of a provider/resource is to automate the life-cycle of common changes, like adding
36
- VLANs, or ports to a VLAN. A provider also allows you to obtain a `list` of resources
37
- (Array of *names*) or a `catalog` (Hash of resource properties). Providers may include resource
38
- specific functionality, like using complex YAML/Hash data for easy import/export and provisioning
39
+ VLANs, or ports to a VLAN. A provider also allows you to obtain a `list` of resources
40
+ (Array of *names*) or a `catalog` (Hash of resource properties). Providers may include resource
41
+ specific functionality, like using complex YAML/Hash data for easy import/export and provisioning
39
42
  with Junos. If you need the ability to simply apply config-snippets that you do not need to model
40
- as resources (as you might for initial device commissioning), the Utilities library is where you
43
+ as resources (as you might for initial device commissioning), the Utilities library is where you
41
44
  want to start.
42
-
45
+
43
46
  - Utilities:
44
47
 
45
48
  Utilities are simply collections of functions. The **configuration** utilities, for example, will
@@ -47,9 +50,9 @@ The framework is comprised of these basic eloements:
47
50
  for unmanaged provider/resources (like initial configuration of the device). The
48
51
  **routing-engine** utilities, for example, will allow you to easily upgrade software, check
49
52
  memory usage, and do `ping` operations.
50
-
53
+
51
54
  # EXAMPLE USAGE
52
-
55
+
53
56
  ```ruby
54
57
  require 'pp'
55
58
  require 'net/netconf/jnpr'
@@ -60,7 +63,7 @@ unless ARGV[0]
60
63
  exit 1
61
64
  end
62
65
 
63
- # login information for NETCONF session
66
+ # login information for NETCONF session
64
67
  login = { :target => ARGV[0], :username => 'jeremy', :password => 'jeremy1', }
65
68
 
66
69
  ## create a NETCONF object to manage the device and open the connection ...
@@ -71,8 +74,8 @@ ndev.open
71
74
  puts "OK!"
72
75
 
73
76
  ## Now bind providers to the device object. The 'Junos::Ez::Provider' must be first.
74
- ## This will retrieve the device 'facts'. The other providers allow you to define the
75
- ## provider variables; so this example is using 'l1_ports' and 'ip_ports', but you could name
77
+ ## This will retrieve the device 'facts'. The other providers allow you to define the
78
+ ## provider variables; so this example is using 'l1_ports' and 'ip_ports', but you could name
76
79
  ## them what you like, yo!
77
80
 
78
81
  Junos::Ez::Provider( ndev )
@@ -125,7 +128,7 @@ ndev.cu.rollback!
125
128
 
126
129
  ndev.close
127
130
  ```
128
-
131
+
129
132
  # PROVIDERS
130
133
 
131
134
  Providers manage access to individual resources and their associated properties. Providers/resources exists
@@ -137,29 +140,30 @@ documentation on Providers/Resources, see the *docs* directory.
137
140
  - Vlans: VLAN resource management
138
141
  - IPports: IP v4 port management
139
142
  - StaticHosts: Static Hosts [system static-host-mapping ...]
140
- - StaticRoutes: Static Routes [routing-options static ...]
143
+ - StaticRoutes: Static Routes [routing-options static ...]
144
+ - Group: JUNOS groups management
141
145
 
142
146
  # UTILITIES
143
147
 
144
148
  - Config:
145
-
149
+
146
150
  These functions allow you to load config snippets, do commit checks, look at config diffs, etc.
147
- Generally speaking, you would want to use the Providers/Resources framework to manage specific
151
+ Generally speaking, you would want to use the Providers/Resources framework to manage specific
148
152
  items in the config. This utility library is very useful when doing the initial commissioning
149
153
  process, where you do not (cannot) model every aspect of Junos. These utilities can also be
150
154
  used in conjunction with Providers/Resources, specifically around locking/unlocking and committing
151
155
  the configuration.
152
-
156
+
153
157
  - Filesystem:
154
-
158
+
155
159
  These functions provide you "unix-like" commands that return data in Hash forms rather than
156
160
  as string output you'd normally have to screen-scraps. These methods include `ls`, `df`, `pwd`,
157
161
  `cwd`, `cleanup`, and `cleanup!`
158
162
 
159
163
  - Routing-Engine:
160
-
161
- These functions provide a general collection to information and functioanlity for handling
162
- routing-engine (RE) processes. These functions `reboot!`, `shutdown!`, `install_software!`,
164
+
165
+ These functions provide a general collection to information and functioanlity for handling
166
+ routing-engine (RE) processes. These functions `reboot!`, `shutdown!`, `install_software!`,
163
167
  `ping`. Information gathering such as memory-usage, current users, and RE status information
164
168
  is also made available through this collection.
165
169
 
@@ -167,14 +171,21 @@ documentation on Providers/Resources, see the *docs* directory.
167
171
 
168
172
  * gem netconf
169
173
  * Junos OS based products
170
-
171
- # INSTALLATION
174
+
175
+ # INSTALLATION
172
176
 
173
177
  * gem install junos-ez-stdlib
174
178
 
175
179
  # CONTRIBUTORS
180
+ Juniper Networks is actively contributing to and maintaining this repo. Please contact jnpr-community-netdev@juniper.net
181
+ for any queries.
182
+
183
+ Contributors:
184
+ [John Deatherage](https://github.com/routelastresort), [Nitin Kumar](https://github.com/vnitinv),
185
+ [Priyal Jain](https://github.com/jainpriyal), [Ganesh Nalawade](https://github.com/ganeshnalawade)
176
186
 
177
- * Jeremy Schulman, @nwkautomaniac
187
+ Former Contributors:
188
+ [Jeremy Schulman](https://github.com/jeremyschulman)
178
189
 
179
190
  # LICENSES
180
191
 
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,32 @@
1
+ # PLEASE CONTRIBUTE
2
+
3
+ ## IDEAS & SUGGESTIONS
4
+
5
+ If you have a suggestion or idea, please write it up as a separate file and do a *pull request*. Your file will be added to this directory as a separate file so folks can peer-review and crowdsource around it.
6
+
7
+ It would be helpful to include the following information in the file:
8
+
9
+ 1. SYNOPSIS - A brief statement of what is needed
10
+ 2. TARGET PLATFORMS - A list of Junos OS based platforms this would apply to
11
+ 3. TARGET RELEASE - If you have specific Junos OS release requirements, please state them
12
+ 4. TIMELINE - If you have a specific *gotta have it* by date, please let us know
13
+ 5. GORY DETAILS - Please provide as much information you can around the use-case or application
14
+
15
+ Please name your file in the following format:
16
+
17
+ <DATEYYMMDD>_<GITHUB-USER-HANDLE>_<IDEA-NAME>.md
18
+
19
+ For example, let's say I was going to submit something around virtual-routing (VRF), I would name the file:
20
+
21
+ 20130430_jeremyschulman_vrf.md
22
+
23
+ Thank you all for your support and contributions!
24
+
25
+ ## CODE & BUG-FIXES
26
+
27
+ Pull requests are welcome and appreciated !
28
+
29
+ # THANK YOU
30
+
31
+ This framework is built for the commmunity of DevOps and NetDevOps that need to create automation solutions. Your help and participation in the development of this software is essential
32
+
@@ -0,0 +1,61 @@
1
+ # Junos::Ez::Group::Provider
2
+
3
+ Manages JUNOS group properties
4
+
5
+ # EXAMPLE
6
+
7
+ The provider *name* selector is the JUNOS group name, e.g. "service_group".
8
+
9
+ ```ruby
10
+ Junos::Ez::Group::Provider( ndev, :group )
11
+
12
+ grp = ndev.group["service_group"]
13
+
14
+ grp[:format] = 'set'
15
+ grp[:path] = 'services.set'
16
+
17
+ grp.write!
18
+
19
+ ```
20
+
21
+ # PROPERTIES
22
+
23
+ - `:format` - JUNOS configuration format is file. It can be 'xml', 'text' or 'set'. Default is 'xml'
24
+ - `:path` - Path of configuration file that is applied inside JUNOS group hierarchy.
25
+
26
+ # METHODS
27
+
28
+ No additional methods at this time ...
29
+
30
+ # USAGE NOTES
31
+
32
+ Contents of 'service.set' file
33
+
34
+ ````
35
+ % cat services.set
36
+ set system services ftp
37
+ set system services ssh
38
+ set system services netconf ssh
39
+ ````
40
+
41
+ JUNOS group configuration reflected on executing above example.
42
+
43
+ ````
44
+ {master}[edit]
45
+ junos@switch# show groups service_group
46
+ system {
47
+ services {
48
+ ftp;
49
+ ssh;
50
+ netconf {
51
+ ssh;
52
+ }
53
+ }
54
+ }
55
+
56
+ junos@switch# show apply-groups
57
+ apply-groups [ global re0 re1 service_group ];
58
+
59
+ ````
60
+
61
+