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

Add storm_control and dhcp relay props for interface #474

Merged
merged 36 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5491ff2
Add feature ospf enable
Jun 14, 2016
225b679
Merge remote-tracking branch 'upstream/develop' into develop
Jun 15, 2016
6a68639
Merge remote-tracking branch 'upstream/develop' into develop
Jun 21, 2016
366745b
review comments
Jun 22, 2016
f7dd689
Merge remote-tracking branch 'upstream/develop' into develop
Jun 27, 2016
462dffc
Merge remote-tracking branch 'upstream/develop' into develop
Jul 1, 2016
72fff1a
Fix interface_ospf
Jul 6, 2016
8c29b7d
Merge remote-tracking branch 'upstream/develop' into develop
Jul 7, 2016
a70dfcb
Merge remote-tracking branch 'upstream/develop' into develop
Jul 30, 2016
2cd84e7
Merge remote-tracking branch 'upstream/develop' into develop
Aug 5, 2016
9fc2ade
Merge remote-tracking branch 'upstream/develop' into develop
Aug 11, 2016
5481697
Merge remote-tracking branch 'upstream/develop' into develop
Aug 15, 2016
f273c29
Merge remote-tracking branch 'upstream/develop' into develop
Aug 15, 2016
de3ce53
Merge remote-tracking branch 'upstream/develop' into develop
Aug 16, 2016
d7f0031
bug fix for vtp
Aug 16, 2016
c909ee8
bug fix for resilient mode
Aug 16, 2016
19f15a6
version number fix
Aug 16, 2016
67bcbda
review comment
Aug 16, 2016
608aa2f
Merge remote-tracking branch 'upstream/develop' into develop
Aug 16, 2016
e306107
Fix for symmetry not supported
Aug 17, 2016
ab3ea3b
review comments
Aug 17, 2016
756e146
review comment
Aug 17, 2016
7a27075
Merge remote-tracking branch 'upstream/develop' into develop
Aug 18, 2016
cc35a56
Merge remote-tracking branch 'upstream/develop' into develop
Aug 18, 2016
0511f9b
Merge remote-tracking branch 'upstream/develop' into develop
Aug 23, 2016
a74fe9d
Merge remote-tracking branch 'upstream/develop' into develop
Aug 24, 2016
5a75e23
storm-control and dhcp relay for intf
Aug 26, 2016
299b0d3
Merge remote-tracking branch 'upstream/develop' into hsrp
Aug 26, 2016
9b9928c
Merge remote-tracking branch 'upstream/develop' into hsrp
Aug 30, 2016
2c64427
exclude 2 storm control props on n7k due to hw limitation
Aug 30, 2016
7e1b12f
comments added
Aug 31, 2016
befa63a
changelog
Aug 31, 2016
69fa806
typo correct
Sep 1, 2016
aebf9db
cleanup unsupported tests
Sep 1, 2016
aaede51
review comments
Sep 1, 2016
7c675ce
remove features added during the minitest
Sep 1, 2016
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ Changelog

* Extend interface with attributes:
* `bfd_echo`
* `ipv4_dhcp_relay_addr`
* `ipv4_dhcp_relay_info_trust`
* `ipv4_dhcp_relay_src_addr_hsrp`
* `ipv4_dhcp_relay_src_intf`
* `ipv4_dhcp_relay_subnet_broadcast`
* `ipv4_dhcp_smart_relay`
* `ipv6_dhcp_relay_addr`
* `ipv6_dhcp_relay_src_intf`
* `storm_control_broadcast`
* `storm_control_multicast`
* `storm_control_unicast`
* Extend interface_ospf with attributes:
* `bfd`
* `mtu_ignore`
Expand Down
5 changes: 5 additions & 0 deletions lib/cisco_node_utils/cmd_ref/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ bgp:
get_value: '/^feature bgp$/'
set_value: "feature bgp"

dhcp:
kind: boolean
get_value: '/^feature dhcp$/'
set_value: "feature dhcp"

fabric:
_exclude: [N3k, N8k, N9k]
get_command: "show feature-set"
Expand Down
75 changes: 75 additions & 0 deletions lib/cisco_node_utils/cmd_ref/interface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,47 @@ ipv4_arp_timeout:
ipv4_arp_timeout_non_vlan_interfaces:
default_only: ~

ipv4_dhcp_relay_addr:
_exclude: [ios_xr]
multiple:
get_value: '/^ip dhcp relay address (.*) $/'
set_value: "<state> ip dhcp relay address <addr>"
default_value: []

ipv4_dhcp_relay_info_trust:
_exclude: [ios_xr, N5k, N6k]
kind: boolean
get_value: '/^ip dhcp relay information trusted$/'
set_value: "<state> ip dhcp relay information trusted"
default_value: false

ipv4_dhcp_relay_src_addr_hsrp:
_exclude: [ios_xr, N3k, N8k, N9k]
kind: boolean
get_value: '/^ip dhcp relay source-address hsrp$/'
set_value: "<state> ip dhcp relay source-address hsrp"
default_value: false

ipv4_dhcp_relay_src_intf:
_exclude: [ios_xr]
get_value: '/^ip dhcp relay source-interface (.*)$/'
set_value: "<state> ip dhcp relay source-interface <intf>"
default_value: false

ipv4_dhcp_relay_subnet_broadcast:
_exclude: [ios_xr]
kind: boolean
get_value: '/^ip dhcp relay subnet-broadcast$/'
set_value: "<state> ip dhcp relay subnet-broadcast"
default_value: false

ipv4_dhcp_smart_relay:
_exclude: [ios_xr]
kind: boolean
get_value: '/^ip dhcp smart-relay$/'
set_value: "<state> ip dhcp smart-relay"
default_value: false

ipv4_forwarding:
_exclude: [ios_xr]
kind: boolean
Expand Down Expand Up @@ -198,6 +239,19 @@ ipv6_acl_out:
set_value: "<state> ipv6 traffic-filter <acl> out"
default_value: ""

ipv6_dhcp_relay_addr:
_exclude: [ios_xr]
multiple:
get_value: '/^ipv6 dhcp relay address (.*)$/'
set_value: "<state> ipv6 dhcp relay address <addr>"
default_value: []

ipv6_dhcp_relay_src_intf:
_exclude: [ios_xr]
get_value: '/^ipv6 dhcp relay source-interface (.*)$/'
set_value: "<state> ipv6 dhcp relay source-interface <intf>"
default_value: false

mtu_loopback:
kind: boolean
default_only: ~
Expand Down Expand Up @@ -289,6 +343,27 @@ speed:
else:
default_value: 'auto'

storm_control_broadcast:
_exclude: [ios_xr, N7k]
kind: string
get_value: '/^storm-control broadcast level (.*)$/'
set_value: "<state> storm-control broadcast level <level>"
default_value: '100.00'

storm_control_multicast:
_exclude: [ios_xr, N7k]
kind: string
get_value: '/^storm-control multicast level (.*)$/'
set_value: "<state> storm-control multicast level <level>"
default_value: '100.00'

storm_control_unicast:
_exclude: [ios_xr]
kind: string
get_value: '/^storm-control unicast level (.*)$/'
set_value: "<state> storm-control unicast level <level>"
default_value: '100.00'

stp_bpdufilter:
kind: string
get_value: '/^spanning-tree bpdufilter (.*)$/'
Expand Down
14 changes: 14 additions & 0 deletions lib/cisco_node_utils/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ def self.bgp_enabled?
config_get('feature', 'bgp')
end

# ---------------------------
def self.dhcp_enable
return if dhcp_enabled?
config_set('feature', 'dhcp')
end

def self.dhcp_enabled?
config_get('feature', 'dhcp')
rescue Cisco::CliError => e
# cmd will syntax reject when feature is not enabled.
raise unless e.clierror =~ /Syntax error/
return false
end

# ---------------------------
def self.fabric_enable
# install feature-set and enable it
Expand Down
187 changes: 187 additions & 0 deletions lib/cisco_node_utils/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,105 @@ def default_ipv4_arp_timeout
config_get_default('interface', ipv4_arp_timeout_lookup_string)
end

def ipv4_dhcp_relay_addr
config_get('interface', 'ipv4_dhcp_relay_addr', name: @name)
end

def ipv4_dhcp_relay_addr=(list)
cur_list = ipv4_dhcp_relay_addr
# remove the current addresses first
unless cur_list.empty?
cur_list.each do |addr|
config_set('interface', 'ipv4_dhcp_relay_addr',
name: @name, state: 'no', addr: addr)
end
end
Feature.dhcp_enable unless list.empty?
list.each do |addr|
config_set('interface', 'ipv4_dhcp_relay_addr',
name: @name, state: '', addr: addr)
end
end

def default_ipv4_dhcp_relay_addr
config_get_default('interface', 'ipv4_dhcp_relay_addr')
end

def ipv4_dhcp_relay_info_trust
config_get('interface', 'ipv4_dhcp_relay_info_trust', name: @name)
end

def ipv4_dhcp_relay_info_trust=(state)
Feature.dhcp_enable if state
config_set('interface', 'ipv4_dhcp_relay_info_trust',
name: @name, state: state ? '' : 'no')
end

def default_ipv4_dhcp_relay_info_trust
config_get_default('interface', 'ipv4_dhcp_relay_info_trust')
end

def ipv4_dhcp_relay_src_addr_hsrp
config_get('interface', 'ipv4_dhcp_relay_src_addr_hsrp', name: @name)
end

def ipv4_dhcp_relay_src_addr_hsrp=(state)
Feature.dhcp_enable if state
config_set('interface', 'ipv4_dhcp_relay_src_addr_hsrp',
name: @name, state: state ? '' : 'no')
end

def default_ipv4_dhcp_relay_src_addr_hsrp
config_get_default('interface', 'ipv4_dhcp_relay_src_addr_hsrp')
end

def ipv4_dhcp_relay_src_intf
Copy link
Contributor

@mikewiebe mikewiebe Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly you are trying to downcase and insert whitespace? I suggest you just normalize by downcasing and removing whitespace.

irb(main):012:0* intf = "Ethernet 1/1"
=> "Ethernet 1/1"
irb(main):013:0> intf.downcase.delete(' ')
=> "ethernet1/1"
irb(main):014:0> intf = "Ethernet1/1"
=> "Ethernet1/1"
irb(main):015:0> intf.downcase.delete(' ')
=> "ethernet1/1"
irb(main):016:0> intf = "ethernet 1/1"
=> "ethernet 1/1"
irb(main):017:0> intf.downcase.delete(' ')
=> "ethernet1/1"
irb(main):018:0> 

You can do this here and munge it in the type file so the manifest can specify the name in any of these formats.

intf = config_get('interface', 'ipv4_dhcp_relay_src_intf', name: @name)
return intf unless intf
# Normalize by downcasing and removing white space
intf.downcase.delete(' ')
end

def ipv4_dhcp_relay_src_intf=(val)
state = val == default_ipv4_dhcp_relay_src_intf ? 'no' : ''
intf = val == default_ipv4_dhcp_relay_src_intf ? '' : val
Feature.dhcp_enable if state.empty?
config_set('interface', 'ipv4_dhcp_relay_src_intf',
name: @name, state: state, intf: intf)
end

def default_ipv4_dhcp_relay_src_intf
config_get_default('interface', 'ipv4_dhcp_relay_src_intf')
end

def ipv4_dhcp_relay_subnet_broadcast
config_get('interface', 'ipv4_dhcp_relay_subnet_broadcast', name: @name)
end

def ipv4_dhcp_relay_subnet_broadcast=(state)
Feature.dhcp_enable if state
config_set('interface', 'ipv4_dhcp_relay_subnet_broadcast',
name: @name, state: state ? '' : 'no')
end

def default_ipv4_dhcp_relay_subnet_broadcast
config_get_default('interface', 'ipv4_dhcp_relay_subnet_broadcast')
end

def ipv4_dhcp_smart_relay
config_get('interface', 'ipv4_dhcp_smart_relay', name: @name)
end

def ipv4_dhcp_smart_relay=(state)
Feature.dhcp_enable if state
config_set('interface', 'ipv4_dhcp_smart_relay',
name: @name, state: state ? '' : 'no')
end

def default_ipv4_dhcp_smart_relay
config_get_default('interface', 'ipv4_dhcp_smart_relay')
end

def ipv4_forwarding
config_get('interface', 'ipv4_forwarding', name: @name)
end
Expand Down Expand Up @@ -526,6 +625,49 @@ def default_ipv6_acl_out
config_get_default('interface', 'ipv6_acl_out')
end

def ipv6_dhcp_relay_addr
config_get('interface', 'ipv6_dhcp_relay_addr', name: @name)
end

def ipv6_dhcp_relay_addr=(list)
cur_list = ipv6_dhcp_relay_addr
# remove the current addresses first
unless cur_list.empty?
cur_list.each do |addr|
config_set('interface', 'ipv6_dhcp_relay_addr',
name: @name, state: 'no', addr: addr)
end
end
Feature.dhcp_enable unless list.empty?
list.each do |addr|
config_set('interface', 'ipv6_dhcp_relay_addr',
name: @name, state: '', addr: addr)
end
end

def default_ipv6_dhcp_relay_addr
config_get_default('interface', 'ipv6_dhcp_relay_addr')
end

def ipv6_dhcp_relay_src_intf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here and I would also just add a simplified inline comment:

...
  # Normalize by downcasing and removing white space
  inf.downcase.delete(' ')

intf = config_get('interface', 'ipv6_dhcp_relay_src_intf', name: @name)
return intf unless intf
# Normalize by downcasing and removing white space
intf.downcase.delete(' ')
end

def ipv6_dhcp_relay_src_intf=(val)
state = val == default_ipv6_dhcp_relay_src_intf ? 'no' : ''
intf = val == default_ipv6_dhcp_relay_src_intf ? '' : val
Feature.dhcp_enable if state.empty?
config_set('interface', 'ipv6_dhcp_relay_src_intf',
name: @name, state: state, intf: intf)
end

def default_ipv6_dhcp_relay_src_intf
config_get_default('interface', 'ipv6_dhcp_relay_src_intf')
end

def feature_lacp?
config_get('interface', 'feature_lacp')
end
Expand Down Expand Up @@ -649,6 +791,51 @@ def default_shutdown
config_get_default('interface', lookup)
end

def storm_control_broadcast
config_get('interface', 'storm_control_broadcast', name: @name)
end

def storm_control_broadcast=(val)
state = val == default_storm_control_broadcast ? 'no' : ''
level = val == default_storm_control_broadcast ? '' : val
config_set('interface', 'storm_control_broadcast',
name: @name, state: state, level: level)
end

def default_storm_control_broadcast
config_get_default('interface', 'storm_control_broadcast')
end

def storm_control_multicast
config_get('interface', 'storm_control_multicast', name: @name)
end

def storm_control_multicast=(val)
state = val == default_storm_control_multicast ? 'no' : ''
level = val == default_storm_control_multicast ? '' : val
config_set('interface', 'storm_control_multicast',
name: @name, state: state, level: level)
end

def default_storm_control_multicast
config_get_default('interface', 'storm_control_multicast')
end

def storm_control_unicast
config_get('interface', 'storm_control_unicast', name: @name)
end

def storm_control_unicast=(val)
state = val == default_storm_control_unicast ? 'no' : ''
level = val == default_storm_control_unicast ? '' : val
config_set('interface', 'storm_control_unicast',
name: @name, state: state, level: level)
end

def default_storm_control_unicast
config_get_default('interface', 'storm_control_unicast')
end

def stp_bpdufilter
config_get('interface', 'stp_bpdufilter', name: @name)
end
Expand Down
5 changes: 5 additions & 0 deletions tests/test_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def teardown
['no nv overlay evpn',
'no feature bfd',
'no feature bgp',
'no feature dhcp',
'no feature fabric forwarding',
'no feature-set fex',
'no feature itd',
Expand Down Expand Up @@ -92,6 +93,10 @@ def test_bgp
feature('bgp')
end

def test_dhcp
feature('dhcp')
end

def test_fabric_forwarding
if node.product_id[/N(3)/]
assert_nil(Feature.fabric_forwarding_enabled?)
Expand Down
Loading