Skip to content

Commit

Permalink
Bfd for bgp_neighbor (#419)
Browse files Browse the repository at this point in the history
* errors fixed

* interval array change

* missing ipv6 default

* remove name

* add exclude for interval

* Add comments

* Review comment fixes

* bfd prop added to bgp_neighbor

* CHANGELOG

* review comment

* rview comments
  • Loading branch information
saichint authored and chrisvanheuveln committed Jun 2, 2016
1 parent 8740129 commit c07024e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Changelog
* Bidirectional Forwarding Detection
* bfd (@saichint)

### Added

* Extend cisco_bgp_neighbor with attributes:
* `bfd`

## [v1.3.1]

### Changed
Expand Down
14 changes: 14 additions & 0 deletions lib/cisco_node_utils/bgp_neighbor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
@set_args = @set_args.merge!(hash) unless hash.empty?
end

def bfd=(val)
set_args_keys(state: (val) ? '' : 'no')
Feature.bfd_enable
config_set('bgp_neighbor', 'bfd', @set_args)
end

def bfd
config_get('bgp_neighbor', 'bfd', @get_args)
end

def default_bfd
config_get_default('bgp_neighbor', 'bfd')
end

def description=(desc)
fail TypeError unless desc.is_a?(String)
desc.strip!
Expand Down
7 changes: 7 additions & 0 deletions lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ all_neighbors:
- "(?)vrf <vrf>"
get_value: '/^neighbor (\S+)$/'

bfd:
_exclude: [ios_xr]
kind: boolean
get_value: '/^bfd$/'
set_value: '<state> bfd'
default_value: false

capability_negotiation:
_exclude: [ios_xr]
auto_default: false
Expand Down
20 changes: 20 additions & 0 deletions tests/test_bgp_neighbor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@ def test_dynamic_capability
end
end

def test_bfd
%w(default test_vrf).each do |vrf|
neighbor = create_neighbor(vrf)
if validate_property_excluded?('bgp_neighbor', 'bfd')
assert_nil(neighbor.bfd)
assert_nil(neighbor.default_bfd)
assert_raises(Cisco::UnsupportedError) do
neighbor.bfd = true
end
else
check = [false, true, neighbor.default_bfd]
check.each do |value|
neighbor.bfd = value
assert_equal(value, neighbor.bfd)
end
end
neighbor.destroy
end
end

def test_ebgp_multihop
%w(default test_vrf).each do |vrf|
neighbor = create_neighbor(vrf)
Expand Down

0 comments on commit c07024e

Please sign in to comment.