Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWE-2449 upgrade junos gem #4

Open
wants to merge 51 commits into
base: fix-diff+no-rake
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fbc1bd8
Update bridge_domain.rb
Jainpriyal Jun 26, 2015
bb13799
adding support for l2_interface
Jainpriyal Jul 15, 2015
c98a309
Merge pull request #24 from Jainpriyal/master
Jul 15, 2015
409b3d0
vlan delete
Jainpriyal Jul 15, 2015
ac17b82
Merge pull request #25 from Jainpriyal/master
Jul 20, 2015
7c6e64a
lags for gigether interface
Jainpriyal Jul 22, 2015
4d9d3aa
Merge pull request #26 from Jainpriyal/master
Aug 6, 2015
f99f9b8
solving duplicate declaration
Jainpriyal Aug 11, 2015
6b1a31b
netdev_group template add
Aug 19, 2015
fd19c21
Update group.rb
Aug 19, 2015
75d0744
Merge pull request #29 from ganeshnalawade/master
Aug 19, 2015
64102ba
Merge pull request #28 from Jainpriyal/master
Aug 20, 2015
e3175ce
solving rerunning lag_interface
Jainpriyal Sep 8, 2015
6be70fd
Merge pull request #31 from Jainpriyal/master
Jainpriyal Sep 22, 2015
b157b99
modified addition of tagged vlans
Jainpriyal Sep 24, 2015
e7a6397
Merge pull request #32 from Jainpriyal/master
Oct 9, 2015
7891bff
resolving PR-1131912, for backup RE
Jainpriyal Nov 5, 2015
bfa1380
resolving dual RE issue
Jainpriyal Nov 20, 2015
a5eeb6f
Fix Issue #33
Nov 20, 2015
6f41172
Merge pull request #34 from ganeshnalawade/master
Nov 23, 2015
4ec8f8a
Merge pull request #36 from Jainpriyal/master
Nov 26, 2015
6916b2f
adding fix for qfx devices
Jainpriyal Dec 4, 2015
45b0313
resolving qfx issue
Jainpriyal Dec 4, 2015
91d6d41
Merge pull request #38 from Jainpriyal/master
Dec 4, 2015
d125350
Fix issue #28
Dec 23, 2015
898294b
Merge pull request #41 from ganeshnalawade/master
Dec 23, 2015
2bccc42
Fix issue #42
Feb 11, 2016
b265b38
Merge pull request #43 from ganeshnalawade/master
Feb 11, 2016
182687a
Update group.rb
ganeshrn Feb 26, 2016
d6a01ae
Update to version 1.0.0
Mar 11, 2016
177d33c
Remove swp file
Mar 11, 2016
8713454
Merge pull request #45 from ganeshnalawade/master
ydnath Mar 11, 2016
bccfc61
Update junos-ez-stdlib.gemspec
ganeshrn Mar 11, 2016
e23437c
Update to version 1.0.0
ganeshrn Mar 11, 2016
0d1ecb1
Update CHANGELOG.md
ganeshrn Mar 11, 2016
19db7e9
required Gemspec lines, etc. - pushing 1.0.0
routelastresort Aug 2, 2016
3c66241
updated files metadata + version bump
routelastresort Aug 2, 2016
234a380
project metadata, test hooks, badges
routelastresort Aug 2, 2016
c44edc2
pessimistic version bump
routelastresort Aug 2, 2016
634aff8
Change GitHub handle
ganeshrn Apr 20, 2017
20bcbf0
Merge pull request #57 from ganeshrn/change_github_handle
vnitinv Apr 20, 2017
7e7e954
Fix diff? method for newer JunOS versions
lucasmpb Apr 3, 2018
4244f4f
fix security vulnerability
vnitinv Apr 13, 2018
9e4654f
Merge pull request #59 from vnitinv/rubocop-security-vulnerability
ydnath Apr 13, 2018
5bbab24
Merge pull request #58 from packethost/fix-diff
ydnath Apr 13, 2018
19f92e2
Added PTX product model.
Oct 8, 2018
834a9ae
Normally, REs are expected to be named as RE0 or RE1. But on some ver…
Dec 23, 2018
e688693
Merge pull request #60 from mahant3sh/master
ydnath Dec 23, 2018
0242302
Removing references to rake from gemspec
Mar 17, 2016
31b7693
Fix diff? method for newer JunOS versions
lucasmpb Apr 3, 2018
1c75e0a
Merge branch 'fix-diff+no-rake' into SWE-2449-upgrade-junos-gem
hwnjng Jul 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
.ruby-version
*.gem
coverage
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LineLength:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Documentation:
Enabled: false
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sudo: false
language: ruby
rvm:
- 1.9.3-p551
- 2.0.0-p648
- 2.1.9
- 2.2.5
- 2.3.1
matrix:
allow_failures:
- rvm: 1.9.3-p551
- rvm: 2.0.0-p648
fast_finish: true
before_install: gem update --remote bundler
install:
- bundle install --retry=3
script:
- bundle exec rake build
76 changes: 55 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,103 @@
# 2013-April

0.0.10: 2013-04-26

Initial release of code into RubyGems. Code tested on EX and SRX-branch. Consider this code
as "early-adopter". Comments/feedback is welcome and appreciated.

0.0.11: 2013-04-26

Updated Junos::Ez::RE::Utils
#memory changed :procs from Hash to Array
#users changed return from Hash to Array

0.0.12: 2013-04-26

Updated Junos::Ez::FS:Utils#ls to include :symlink information
Adding Junos::Ez::Users::Provider for login management
Adding Junos::Ez::UserAuths::Provider for SSH-key management

0.0.14: 2013-04-28

Completed initial documentation. Still more work to be done with these files
but the "enough to get started" information is now available

# 2013-May

0.0.15: 2013-05-02

L2ports - added support for framework to read [edit vlans] stanza to recognize interfaces configured
there vs. under [edit interfaces]

IPports - added :acl_in and :acl_out for stateless ACL filtering. added .status method to return
runtime status information about the port

RE::Utils - misc updates, and documentation

0.0.16: 2013-05-03

RE::Utils - added support for license-key management. Renamed "software" methods from "xxx_software"
to "software_xxx" to be consistent with other naming usage. Updated docs.

0.0.17: 2013-05-05

FS::Utils - updated docs. fixed methods so that all "error" scenarios raise IOError excaptions.

0.1.0: 2013-05-06

All docs and code _finished_ for the inital release of code. Always more to do, but at this
point, declaring the framework "good for early adopter testing". Looking forward to bug-reports,
please open issues against this repo. Thank you!

0.1.1: 2013-05-29

Fixed a small bug in fact gathering for hardwaremodel

# 2013-July

0.1.2: 2013-07-04

Fixed issue#3. Previously this gem would not work with non-VC capable EX switches. Updated
the `facts/version.rb` file to handle these devices. Also added a new fact `:vc_capable` that
is set to `true` if the EX can support virtual-chassis, and `false` if it cannot.

# 2013-Aug

0.2.0: *in progres*
0.2.0:

Fixed issue #6. Added support for EX4300 platform. Added new provider for Link Aggregation Group
resources (LAGports)

# 2016-March

1.0.0:

Fixed issues
Issue #17 Add support for OCX device.
Issue #20 "under development" error is thrown while importing the interface_create recipe from the Chef-Server.
Issue #22 "netdev_vlan" resource action delete is not working fine while invoking from the JUNOS Chef-Client.
Issue #23 RPC command error: commit-configuration is getting thrown on Invoking the "netdev_lag" resource from
JUNOS Chef Client.
Issue #27 Duplicate declaration of lag configuration in a recipe is giving NoMethodError: undefined method
`properties' for nil:NilClass.
Issue #30 Error in rerunning netdev_lag interface.
Issue #33 undefined method `properties' for nil:NilClass error is thrown if the backup RE is unreachable.
Issue #35 Error in running chef client from Backup RE.
Issue #39 Getting 'Junos::Ez::NoProviderError' error on qfx device.
Issue #42 Raise exception to handle warnings in <error-severity>.

Enhancement
* Add support for configuring l2_interface on MX device.
* Add support for provider 'group' for configuring JUNOS groups.

# 2016-August

1.0.3
Fixed issues
Issue #46 Removing references to rake from gemspec
Issue #47 cannot get the git source code

Enhancement
* Valid project metadata and rake for cleanly building/releasing
* Test hooks and badges
* netconf gem pessimistic version constraint to 0.3.1
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

gem 'simplecov', require: false, group: :test
72 changes: 41 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[![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)
[![Build Status](https://travis-ci.org/Juniper/ruby-junos-ez-stdlib.svg?branch=master)](https://travis-ci.org/Juniper/ruby-junos-ez-stdlib)

# OVERVIEW

Ruby framework to support Junos OS based device management automation.

This is the "standard library" or "core" set of functionality that should work on most/all Junos OS based devices.

This framework is build on top of the NETCONF gem which uses XML as the fundamental data-exchange. So no
"automating the CLI" or using SNMP. The purpose of this framework is to **enable automation development
This framework is build on top of the NETCONF gem which uses XML as the fundamental data-exchange. So no
"automating the CLI" or using SNMP. The purpose of this framework is to **enable automation development
without requiring specific Junos XML knowledge**.

Further documentation can be found in the *docs* subdirectory.
Expand All @@ -14,42 +17,42 @@ Further documentation can be found in the *docs* subdirectory.

The framework is comprised of these basic eloements:

- Facts:
- Facts:

A Hash of name/value pairs of information auto-collected. Fact values can be Hash structures as well
so you can have deeply nested fact data. You can also define your own facts in addition to the "stdlib" facts.
The facts are used by the framework to create a platform indepent layer of abstraction. This means
that managing a VLAN, for example, is the same regardless of the underlying hardware platofrm (EX, QFX,
MX, SRX, ...)

- Resources:

Resources allow you to easily configure and perform operational functions on specific items within Junos,
- Resources:

Resources allow you to easily configure and perform operational functions on specific items within Junos,
for example VLANs, or switch ports. A resource has *properties* that you manipuate as Hash. You can
interact with Junos using resource methods like `read!`, `write!`, `delete!`, `activate!`, `deactivate!`, etc.
interact with Junos using resource methods like `read!`, `write!`, `delete!`, `activate!`, `deactivate!`, etc.
For a complete listing of resource methods, refer to the *docs* directory

- Providers:

Providers allow you to manage a collection of resource, and most commonly, select a resource.
The purpose of a provider/resource is to automate the life-cycle of common changes, like adding
VLANs, or ports to a VLAN. A provider also allows you to obtain a `list` of resources
(Array of *names*) or a `catalog` (Hash of resource properties). Providers may include resource
specific functionality, like using complex YAML/Hash data for easy import/export and provisioning
VLANs, or ports to a VLAN. A provider also allows you to obtain a `list` of resources
(Array of *names*) or a `catalog` (Hash of resource properties). Providers may include resource
specific functionality, like using complex YAML/Hash data for easy import/export and provisioning
with Junos. If you need the ability to simply apply config-snippets that you do not need to model
as resources (as you might for initial device commissioning), the Utilities library is where you
as resources (as you might for initial device commissioning), the Utilities library is where you
want to start.

- Utilities:

Utilities are simply collections of functions. The **configuration** utilities, for example, will
allow you to easily push config snippets in "curly-brace", "set", or XML formats. Very useful
for unmanaged provider/resources (like initial configuration of the device). The
**routing-engine** utilities, for example, will allow you to easily upgrade software, check
memory usage, and do `ping` operations.

# EXAMPLE USAGE

```ruby
require 'pp'
require 'net/netconf/jnpr'
Expand All @@ -60,7 +63,7 @@ unless ARGV[0]
exit 1
end

# login information for NETCONF session
# login information for NETCONF session
login = { :target => ARGV[0], :username => 'jeremy', :password => 'jeremy1', }

## create a NETCONF object to manage the device and open the connection ...
Expand All @@ -71,8 +74,8 @@ ndev.open
puts "OK!"

## Now bind providers to the device object. The 'Junos::Ez::Provider' must be first.
## This will retrieve the device 'facts'. The other providers allow you to define the
## provider variables; so this example is using 'l1_ports' and 'ip_ports', but you could name
## This will retrieve the device 'facts'. The other providers allow you to define the
## provider variables; so this example is using 'l1_ports' and 'ip_ports', but you could name
## them what you like, yo!

Junos::Ez::Provider( ndev )
Expand Down Expand Up @@ -125,7 +128,7 @@ ndev.cu.rollback!

ndev.close
```

# PROVIDERS

Providers manage access to individual resources and their associated properties. Providers/resources exists
Expand All @@ -137,45 +140,52 @@ documentation on Providers/Resources, see the *docs* directory.
- Vlans: VLAN resource management
- IPports: IP v4 port management
- StaticHosts: Static Hosts [system static-host-mapping ...]
- StaticRoutes: Static Routes [routing-options static ...]
- StaticRoutes: Static Routes [routing-options static ...]
- Group: JUNOS groups management

# UTILITIES

- Config:

These functions allow you to load config snippets, do commit checks, look at config diffs, etc.
Generally speaking, you would want to use the Providers/Resources framework to manage specific
Generally speaking, you would want to use the Providers/Resources framework to manage specific
items in the config. This utility library is very useful when doing the initial commissioning
process, where you do not (cannot) model every aspect of Junos. These utilities can also be
used in conjunction with Providers/Resources, specifically around locking/unlocking and committing
the configuration.

- Filesystem:

These functions provide you "unix-like" commands that return data in Hash forms rather than
as string output you'd normally have to screen-scraps. These methods include `ls`, `df`, `pwd`,
`cwd`, `cleanup`, and `cleanup!`

- Routing-Engine:
These functions provide a general collection to information and functioanlity for handling
routing-engine (RE) processes. These functions `reboot!`, `shutdown!`, `install_software!`,

These functions provide a general collection to information and functioanlity for handling
routing-engine (RE) processes. These functions `reboot!`, `shutdown!`, `install_software!`,
`ping`. Information gathering such as memory-usage, current users, and RE status information
is also made available through this collection.

# DEPENDENCIES

* gem netconf
* Junos OS based products
# INSTALLATION

# INSTALLATION

* gem install junos-ez-stdlib

# CONTRIBUTORS
Juniper Networks is actively contributing to and maintaining this repo. Please contact [email protected]
for any queries.

Contributors:
[John Deatherage](https://github.com/routelastresort), [Nitin Kumar](https://github.com/vnitinv),
[Priyal Jain](https://github.com/jainpriyal), [Ganesh Nalawade](https://github.com/ganeshrn)

* Jeremy Schulman, @nwkautomaniac
* Ganesh Nalawade, @ganesh634
Former Contributors:
[Jeremy Schulman](https://github.com/jeremyschulman)

# LICENSES

Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: :spec
Loading