Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0dcb2b9
Fix interface default issues (#598)
Sep 26, 2018
a3fe991
Fixes for n9k-f and n3k-f (#599)
Oct 12, 2018
4e0e66d
Add 7_0_3_I4_8_ label
mikewiebe Oct 24, 2018
20adf44
Allow node cache to be reset. (#601)
da-ar Nov 21, 2018
b64a643
Add new CLIs for Vxlan Vtep (#600)
Nov 26, 2018
3d11ff5
Fix for route map src proto sorting (#602)
Dec 4, 2018
0d7150e
Add 'redistribute' support to router_ospf_vrf (#604)
chrisvanheuveln Jan 4, 2019
9b3e7ac
interface_service_vni: Create 'all_interfaces' key (#606)
chrisvanheuveln Jan 11, 2019
fc865df
Extend nxapi client with https support (#605)
Thomas-Franklin Jan 15, 2019
aa7b0c8
Minitest fixes (#609)
chrisvanheuveln Jan 17, 2019
15a7429
Fix multisite_border_gateway_interface property (#608)
mikewiebe Jan 17, 2019
b324f5f
Add needed test skips (#610)
mikewiebe Feb 1, 2019
1b5697e
Rel200/fix radius global (#611)
mikewiebe Feb 1, 2019
175beb3
Add C3064 exclude for feature-set fex (#612)
mikewiebe Feb 4, 2019
03d15f9
Fix dhcp_relay_global getter (#613)
mikewiebe Feb 4, 2019
b65bf56
New def values for n6k banner yaml (#614)
chrisvanheuveln Feb 5, 2019
f3149e0
Rel200/release prep (#616)
mikewiebe Feb 5, 2019
22a9cfe
vrf/vlan fixes for n6k test failures (#615)
chrisvanheuveln Feb 5, 2019
73e5ad5
test_feature: n6k: test_nv_overlay needs check for unsupported hardw…
chrisvanheuveln Feb 5, 2019
7be1a20
Minitest: router_bgp fixes for n6k (#618)
chrisvanheuveln Feb 6, 2019
1d9ae35
Add additional props to success matrix (#620)
mikewiebe Feb 7, 2019
5616c63
minitest n6k: test_vni dependency (#619)
chrisvanheuveln Feb 7, 2019
5b7f483
vxlan minitest fixes (#621)
chrisvanheuveln Feb 7, 2019
6050ce1
Remove add_quotes call from getters (#622)
mikewiebe Feb 7, 2019
8e6a92f
Remove add_quotes call from getter
mikewiebe Feb 8, 2019
18d58bd
Remove redundant section
mikewiebe Feb 8, 2019
b2e4a1d
MT: n6k cleanups vrf_af, interface_ospf (#623)
chrisvanheuveln Feb 12, 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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rvm:
- 2.2.2
- 2.1.6
- 2.0.0-p648 # specify non-clang version of ruby
before_install:
- gem install bundler -v '< 2'

script:
- bundle exec rake
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
Changelog
=========

## [v2.0.0]

### New Cisco Resources

### Added
* Extend nxapi client for https support
* `use_ssl` will be true when `transport` is `https`
* now makes use of `port` for custom nxapi ports
* Extend router_ospf_vrf with attribute:
* `redistribute`
* `reset_instance` method to node. Allows a single instance of nodeutils to reset the environment cache.
* Extend vxlan_vtep_vni with attribute:
* `suppress_arp_disable`
* Extend vxlan_vtep with attributes:
* `global_suppress_arp`
* `global_ingress_replication_bgp`
* `global_mcast_group_l2`
* `global_mcast_group_l3`

### Removed
* Removed cache in `node_util.node`, which gave every inheriting class it's own cache.

### Changed

## [v1.10.0]

### New Cisco Resources
Expand Down Expand Up @@ -587,6 +611,7 @@ Cisco::Environment.add_env('default', env)
[git-flow]: https://github.com/petervanderdoes/gitflow-avh
[SimpleCov]: https://github.com/colszowka/simplecov

[v2.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.10.0...v2.0.0
[v1.10.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.9.0...v1.10.0
[v1.9.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.8.0...v1.9.0
[v1.8.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.7.0...v1.8.0
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/bgp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def route_distinguisher=(rd)
# explicit values when removing the rd command. These restrictions are
# not not needed in I3 and newer images.
Feature.nv_overlay_evpn_enable if
Utils.nexus_i2_image || node.product_id[/N7/]
Utils.nexus_i2_image || node.product_id[/N[567]/]

if rd == default_route_distinguisher
return if route_distinguisher.empty?
Expand Down
14 changes: 11 additions & 3 deletions lib/cisco_node_utils/cisco_cmn_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def self.chassis_pid?(ver_regexp)
return true if Platform.chassis['pid'][ver_regexp]
end

def self.fretta?
require_relative 'platform'
Platform.slots.each do |_x, row|
return true if row['pid'][/-R/]
end
false
end

# Helper utility method for ip/prefix format networks.
# For ip/prefix format '1.1.1.1/24' or '2000:123:38::34/64',
# we need to mask the address using the prefix length so that they
Expand Down Expand Up @@ -362,9 +370,9 @@ def self.merge_range(range)
end # merge_range

def self.add_quotes(value)
return value if image_version?(/7.3/)
value = "\"#{value}\"" unless
value.start_with?('"') && value.end_with?('"')
return value if image_version?(/7.3.[0-1]/) || value.nil?
value = "'#{value}'" unless
value.start_with?('"', "'") && value.end_with?('"', "'")
value
end # add_quotes

Expand Down
46 changes: 40 additions & 6 deletions lib/cisco_node_utils/client/nxapi/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# November 2014, Glenn F. Matthews
#
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
# Copyright (c) 2014-2019 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,11 @@ def initialize(**kwargs)
else
# Remote connection. This is primarily expected
# when running e.g. from a Unix server as part of Minitest.
@http = Net::HTTP.new(@host)
@transport = kwargs[:transport] || 'http'
@verify_mode = kwargs[:verify_mode] || 'none'
@port.nil? ? @port = '' : @port = ":#{@port}"
uri = URI.parse("#{@transport}://#{@host}#{@port}")
@http = Net::HTTP.new(uri.host, uri.port)
end
# The default read time out is 60 seconds, which may be too short for
# scaled configuration to apply. Change it to 300 seconds, which is
Expand Down Expand Up @@ -205,14 +209,18 @@ def req(type, command_or_list)
request = build_http_request(type, command)

# send the request and get the response
debug("Sending HTTP request to NX-API at #{@http.address}:\n" \
debug("Sending #{@transport} request to NX-API at #{@http.address}:\n" \
"#{request.to_hash}\n#{request.body}")
read_timeout_check(request)
tries = 2
begin
# Explicitly use http to avoid EOFError
# http://stackoverflow.com/a/23080693
@http.use_ssl = false
if @transport == 'https'
debug('Setting use_ssl to true')
@http.use_ssl = true
@http.verify_mode = handle_verify_mode(@verify_mode)
else
@http.use_ssl = false
end
response = @http.request(request)
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
emsg = 'Connection refused or reset. Is the NX-API feature enabled?'
Expand Down Expand Up @@ -268,6 +276,32 @@ def build_http_request(type, command_string)
end
private :build_http_request

# Returns the OpenSSL verify mode based on the verify_mode arguments
#
# @raise if verify_mode param is not `peer`, `client-once`, `fail-no-peer`
# or `none`
#
# @param String verify mode to use
#
# @return OpenSSL::SSL verification mode
def handle_verify_mode(verify_mode)
case verify_mode
when 'peer'
OpenSSL::SSL::VERIFY_PEER
when 'client-once'
OpenSSL::SSL::VERIFY_CLIENT_ONCE
when 'fail-no-peer'
OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
when 'none'
OpenSSL::SSL::VERIFY_NONE
else
fail "#{verify_mode} is not a valid mode, " \
'valid modes are: "none", "peer", ' \
'"client-once", "fail-no-peer"'
end
end
private :handle_verify_mode

def handle_http_response(response)
debug("HTTP Response: #{response.message}\n#{response.body}")
case response
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/cmd_ref/acl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ all_acls:

fragments:
# Note: The ACL 'fragments' keyword is independent of ACE 'fragments'
_exclude: [N5k, N6k]
_exclude: [N5k, N6k, N3k-F, N9k-F]
get_value: '/fragments (\S+)$/'
set_value: '<state> fragments <action>'
default_value: ~
Expand Down
6 changes: 5 additions & 1 deletion lib/cisco_node_utils/cmd_ref/banner.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# banner
---
motd:
default_value: "User Access Verification\n"
N5k: &N6000
default_value: "Nexus 6000 Switch\n"
N6k: *N6000
else:
default_value: "User Access Verification\n"
get_command: 'show banner motd'
get_value: '/^.*$/m'
set_value: '<state> banner motd <motd>'
9 changes: 8 additions & 1 deletion lib/cisco_node_utils/cmd_ref/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ fabric_forwarding:
get_value: '/^feature fabric forwarding$/'
set_value: "feature fabric forwarding"

fabricpath:
_exclude: [N3k, N3k-F, N9k-F, N9k]
get_command: "show feature-set"
get_value: '/^fabricpath[\s\d]+(\w+)/'
set_value: "<state> feature-set fabricpath"

fex:
_exclude: [C3064, C3132, N5k, N6k, N3k-F, N9k-F]
_exclude: [C3048, C3064, C3132, N5k, N6k, N3k-F, N9k-F]
get_command: "show feature-set"
get_value: '/^fex[\s\d]+(\w+)/'
set_value: "<state> feature-set fex"
Expand Down Expand Up @@ -113,6 +119,7 @@ vni:
set_value: 'feature vn-segment-vlan-based'

vtp:
_exclude: [N3k-F, N9k-F]
kind: boolean
get_value: '/^feature vtp$/'
set_value: "<state> feature vtp"
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/cmd_ref/interface_ospf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bfd:
# no config at all so need to grab the optional
# match to get the whole config for checking
# the mode
get_value: '/^\s*ip ospf bfd *(?:\S+)?$/'
get_value: '/^\s*ip ospf bfd *(?:\S*)$/'
set_value: '%s ip ospf bfd %s'
default_value: ~

Expand Down
5 changes: 5 additions & 0 deletions lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ _template:
- 'interface <name>'
- 'service instance <sid> vni'

all_interfaces:
multiple:
get_context: ~
get_value: '/^interface (.*)/'

all_service_vni_ids:
multiple:
get_context:
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/cmd_ref/inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ versionid:
nexus:
get_value: ["name \"Chassis\"", "vendorid"]
N5k: &vendorid5k
get_value: ["name Chassis", "serialnum"]
get_value: ["name Chassis", "vendorid"]
N6k: *vendorid5k
7 changes: 7 additions & 0 deletions lib/cisco_node_utils/cmd_ref/ospf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ process_initialized:
get_command: "show ip ospf stat"
get_value: '/^No SAP is registered/' # Ospf is not initialized when seen

redistribute:
# no support yet for redistribute maximum-prefix
multiple: true
get_value: '/^redistribute (\S+ ?\S+?) route-map (\S+)$/'
set_value: '<state> redistribute <protocol> route-map <route_map>'
default_value: []

router:
multiple: true
get_command: "show running ospf"
Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/cmd_ref/route_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ set_distance_local:

# there is more than one space before delete on some platforms
set_extcomm_list:
get_value: '/^set extcomm-list (\S+)(?:\s+)? delete$/'
get_value: '/^set extcomm-list (\S+)\s+delete$/'
set_value: "<state> set extcomm-list <list> delete"
default_value: false

Expand Down
2 changes: 1 addition & 1 deletion lib/cisco_node_utils/cmd_ref/vtp.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vtp
---
_exclude: [ios_xr]
_exclude: [ios_xr, N3k-F, N9k-F]

# VTP behaves differently across the various Nexus platforms and as a
# result it's not currently possible to use a single 'show running'
Expand Down
30 changes: 30 additions & 0 deletions lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ all_interfaces:
get_context: ~
get_value: '/^interface (.*)$/'

global_ingress_replication_bgp:
_exclude: [N3k-F, N5k, N6k, N7k, N9k-F]
os_version: 'N9k:9.2'
kind: boolean
get_value: '/^global ingress-replication protocol bgp$/'
set_value: '<state> global ingress-replication protocol bgp'
default_value: false

global_mcast_group_l2:
_exclude: [N3k-F, N5k, N6k, N7k]
os_version: 'N9k, N9k-F:9.2'
get_value: '/^global mcast-group (\S+) L2$/'
set_value: '<state> global mcast-group <ip> L2'
default_value: ~

global_mcast_group_l3:
_exclude: [N3k-F, N5k, N6k, N7k, N9k-F]
os_version: 'N9k:9.2'
get_value: '/^global mcast-group (\S+) L3$/'
set_value: '<state> global mcast-group <ip> L3'
default_value: ~

global_suppress_arp:
_exclude: [N3k-F, N5k, N6k, N7k]
os_version: 'N9k, N9k-F:9.2'
kind: boolean
get_value: '/^global suppress-arp$/'
set_value: '<state> global suppress-arp'
default_value: false

host_reachability:
get_value: '/^host-reachability protocol (\S+)/'
set_value: '<state> host-reachability protocol <proto>'
Expand Down
11 changes: 9 additions & 2 deletions lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all_vnis:
get_value: '/^member vni (\d+|\d+-\d+) ?(associate-vrf)?$/'

ingress_replication:
_exclude: [N5k, N6k, N7k]
_exclude: [N3k-F, N5k, N6k, N7k, N9k-F]
kind: string
get_value: '/^ingress-replication protocol (\S+)$/'
set_value: '<state> ingress-replication protocol <protocol>'
Expand All @@ -35,7 +35,7 @@ multisite_ingress_replication:
default_value: false

peer_list:
_exclude: [N5k, N6k, N7k]
_exclude: [N3k-F, N5k, N6k, N7k, N9k-F]
multiple:
get_context:
- '/^interface <name>$/i'
Expand All @@ -55,6 +55,13 @@ suppress_arp:
set_value: '<state> suppress-arp'
default_value: false

suppress_arp_disable:
_exclude: [N3k-F, N5k, N6k, N7k]
os_version: 'N9k, N9k-F:9.2'
get_value: '/^suppress-arp disable$/'
set_value: '<state> suppress-arp disable'
default_value: ~

suppress_uuc:
_exclude: [N3k-F, N9k-F, N9k]
os_version: 'N7k:8.1.1'
Expand Down
4 changes: 2 additions & 2 deletions lib/cisco_node_utils/command_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ def debug(text)
puts "DEBUG: #{text}" if @@debug
end

KNOWN_PLATFORMS = %w(C3064 C3132 C3172 N35 N3k N3k-F N5k N6k N7k N9k N9k-F
XRv9k)
KNOWN_PLATFORMS = %w(C3048 C3064 C3132 C3172 N35 N3k N3k-F N5k N6k N7k N9k
N9k-F XRv9k)

def self.platform_to_filter(platform)
if KNOWN_PLATFORMS.include?(platform)
Expand Down
6 changes: 1 addition & 5 deletions lib/cisco_node_utils/dhcp_relay_global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def default_ipv4_src_addr_hsrp

def ipv4_src_intf
intf = config_get('dhcp_relay_global', 'ipv4_src_intf')
# Normalize by downcasing and removing white space
intf = intf.downcase.delete(' ') if intf
intf
end
Expand Down Expand Up @@ -207,10 +206,7 @@ def default_ipv4_sub_option_circuit_id_custom
def ipv4_sub_option_circuit_id_string
str = config_get('dhcp_relay_global', 'ipv4_sub_option_circuit_id_string')
# Normalize by removing white space and add quotes
if str
str.strip!
str = Utils.add_quotes(str)
end
str.strip! if str.kind_of?(String)
str
end

Expand Down
Loading