cisco_node_utils 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +2 -2
- data/README.md +2 -1
- data/cisco_node_utils.gemspec +1 -0
- data/docs/README-develop-node-utils-APIs.md +2 -1
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +2 -2
- data/lib/cisco_node_utils/ace.rb +2 -0
- data/lib/cisco_node_utils/bgp.rb +34 -91
- data/lib/cisco_node_utils/bridge_domain.rb +8 -13
- data/lib/cisco_node_utils/client/nxapi/client.rb +10 -3
- data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +12 -12
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +2 -1
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +5 -15
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +14 -36
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +5 -3
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +25 -15
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +9 -7
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +26 -25
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +11 -3
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +4 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +5 -1
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +8 -8
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +21 -1
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +1 -1
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +5 -4
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +9 -9
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +3 -5
- data/lib/cisco_node_utils/command_reference.rb +11 -1
- data/lib/cisco_node_utils/interface.rb +46 -8
- data/lib/cisco_node_utils/interface_ospf.rb +2 -2
- data/lib/cisco_node_utils/interface_portchannel.rb +2 -2
- data/lib/cisco_node_utils/node.rb +9 -0
- data/lib/cisco_node_utils/ntp_auth_key.rb +1 -1
- data/lib/cisco_node_utils/object_group.rb +75 -0
- data/lib/cisco_node_utils/object_group_entry.rb +143 -0
- data/lib/cisco_node_utils/portchannel_global.rb +2 -2
- data/lib/cisco_node_utils/radius_global.rb +25 -1
- data/lib/cisco_node_utils/router_ospf.rb +3 -3
- data/lib/cisco_node_utils/syslog_server.rb +38 -42
- data/lib/cisco_node_utils/syslog_settings.rb +74 -3
- data/lib/cisco_node_utils/tacacs_global.rb +47 -14
- data/lib/cisco_node_utils/tacacs_server.rb +1 -5
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vpc.rb +1 -4
- data/lib/cisco_node_utils/vtp.rb +4 -2
- data/spec/schema.yaml +3 -0
- data/tests/ciscotest.rb +16 -9
- data/tests/test_ace.rb +2 -0
- data/tests/test_bgp_af.rb +10 -2
- data/tests/test_bgp_neighbor_af.rb +6 -2
- data/tests/test_bridge_domain.rb +7 -0
- data/tests/test_feature.rb +2 -2
- data/tests/test_interface.rb +30 -4
- data/tests/test_node_ext.rb +2 -2
- data/tests/test_object_group.rb +122 -0
- data/tests/test_platform.rb +1 -1
- data/tests/test_portchannel_global.rb +1 -0
- data/tests/test_radius_global.rb +22 -2
- data/tests/test_route_map.rb +11 -8
- data/tests/test_router_bgp.rb +7 -132
- data/tests/test_router_ospf_area.rb +6 -6
- data/tests/test_snmpuser.rb +19 -11
- data/tests/test_syslog_server.rb +11 -31
- data/tests/test_syslog_settings.rb +46 -5
- data/tests/test_tacacs_global.rb +42 -18
- data/tests/test_vpc.rb +3 -0
- data/tests/test_vxlan_vtep_vni.rb +0 -3
- data/tests/yum_package.yaml +5 -0
- metadata +21 -3
@@ -63,7 +63,11 @@ packet_size:
|
|
63
63
|
default_value: 0
|
64
64
|
N6k: *n5k_default_packet_size
|
65
65
|
N7k: *n5k_default_packet_size
|
66
|
-
|
66
|
+
# On recent versions, packet size is fixed,
|
67
|
+
# so this change will take care of the fix but
|
68
|
+
# it could still fail in the older versions.
|
69
|
+
N9k-F: *n3k_default_packet_size
|
70
|
+
N3k-F: *n3k_default_packet_size
|
67
71
|
|
68
72
|
protocol:
|
69
73
|
_exclude: [ios_xr]
|
@@ -7,7 +7,7 @@ _template:
|
|
7
7
|
get_command: "show running-config spanning-tree"
|
8
8
|
|
9
9
|
bd_designated_priority:
|
10
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
10
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
11
11
|
multiple:
|
12
12
|
get_context: ['/^spanning-tree pseudo-information$/']
|
13
13
|
get_value: '/^bridge-domain (.*) designated priority (.*)$/'
|
@@ -16,40 +16,40 @@ bd_designated_priority:
|
|
16
16
|
default_value: []
|
17
17
|
|
18
18
|
bd_forward_time:
|
19
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
19
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
20
20
|
multiple:
|
21
21
|
get_value: '/^spanning-tree bridge-domain (.*) forward-time (.*)$/'
|
22
22
|
set_value: "<state> spanning-tree bridge-domain <range> forward-time <val>"
|
23
23
|
default_value: []
|
24
24
|
|
25
25
|
bd_hello_time:
|
26
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
26
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
27
27
|
multiple:
|
28
28
|
get_value: '/^spanning-tree bridge-domain (.*) hello-time (.*)$/'
|
29
29
|
set_value: "<state> spanning-tree bridge-domain <range> hello-time <val>"
|
30
30
|
default_value: []
|
31
31
|
|
32
32
|
bd_max_age:
|
33
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
33
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
34
34
|
multiple:
|
35
35
|
get_value: '/^spanning-tree bridge-domain (.*) max-age (.*)$/'
|
36
36
|
set_value: "<state> spanning-tree bridge-domain <range> max-age <val>"
|
37
37
|
default_value: []
|
38
38
|
|
39
39
|
bd_priority:
|
40
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
40
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
41
41
|
multiple:
|
42
42
|
get_value: '/^spanning-tree bridge-domain (.*) priority (.*)$/'
|
43
43
|
set_value: "<state> spanning-tree bridge-domain <range> priority <val>"
|
44
44
|
default_value: []
|
45
45
|
|
46
46
|
bd_range:
|
47
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
47
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
48
48
|
kind: string
|
49
49
|
default_only: "2-3967"
|
50
50
|
|
51
51
|
bd_root_priority:
|
52
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
52
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
53
53
|
multiple:
|
54
54
|
get_context: ['/^spanning-tree pseudo-information$/']
|
55
55
|
get_value: '/^bridge-domain (.*) root priority (.*)$/'
|
@@ -78,7 +78,7 @@ bridge_assurance:
|
|
78
78
|
default_value: true
|
79
79
|
|
80
80
|
domain:
|
81
|
-
_exclude: [N9k-F]
|
81
|
+
_exclude: [N3k-F, N9k-F]
|
82
82
|
os_version: 'N3k, N9k:7.0.3.I6.1'
|
83
83
|
kind: int
|
84
84
|
get_value: '/^spanning-tree domain (\d+)$/'
|
@@ -15,8 +15,9 @@ server:
|
|
15
15
|
multiple: true
|
16
16
|
nexus:
|
17
17
|
get_command: "show running-config all | include '^logging server'"
|
18
|
-
|
19
|
-
|
18
|
+
# Returns <ip>, <level>, <port>, <vrf>
|
19
|
+
get_value: '/^(?:logging server )([^\s]+)(?: (\d+))?(?: port (\d+))?(?: use-vrf (\S+))?/'
|
20
|
+
set_value: '<state> logging server <ip> <level> <port> <vrf>'
|
20
21
|
ios_xr:
|
21
22
|
get_command: "show running-config logging"
|
22
23
|
get_value: '/^logging (\S+).*/'
|
@@ -2,8 +2,28 @@
|
|
2
2
|
---
|
3
3
|
_exclude: [ios_xr]
|
4
4
|
|
5
|
+
console:
|
6
|
+
default_value: 2
|
7
|
+
get_command: "show running-config all | include 'logging'"
|
8
|
+
# Returns <state> and <severity>
|
9
|
+
get_value: '/^(no)?\s*logging console\s*(\d)?/'
|
10
|
+
set_value: '<state> logging console <severity>'
|
11
|
+
|
12
|
+
monitor:
|
13
|
+
default_value: 5
|
14
|
+
get_command: "show running-config all | include 'logging'"
|
15
|
+
# Returns <state> and <severity>
|
16
|
+
get_value: '/^(no)?\s*logging monitor\s*(\d)?/'
|
17
|
+
set_value: '<state> logging monitor <severity>'
|
18
|
+
|
19
|
+
source_interface:
|
20
|
+
default_value: ~
|
21
|
+
get_command: "show running-config all | include 'logging'"
|
22
|
+
get_value: '/^logging source-interface\s+(.*)$/'
|
23
|
+
set_value: '<state> logging source-interface <source_interface>'
|
24
|
+
|
5
25
|
timestamp:
|
6
|
-
get_command: "show running-config all | include '
|
26
|
+
get_command: "show running-config all | include 'logging'"
|
7
27
|
get_value: '/^logging timestamp (.*)$/'
|
8
28
|
set_value: '<state> logging timestamp <units>'
|
9
29
|
default_value: 'seconds'
|
@@ -19,6 +19,13 @@ key_format:
|
|
19
19
|
ios_xr:
|
20
20
|
get_command: "show running-config tacacs-server"
|
21
21
|
|
22
|
+
source_interface:
|
23
|
+
default_value: ~
|
24
|
+
get_value: '/^ip tacacs source-interface\s+(.*)$/'
|
25
|
+
set_value: '<state> ip tacacs source-interface <source_interface>'
|
26
|
+
nexus:
|
27
|
+
get_command: "show running-config all | include '^ip tacacs source-interface'"
|
28
|
+
|
22
29
|
timeout:
|
23
30
|
kind: int
|
24
31
|
get_value: '/tacacs-server timeout\s+(\d+)/'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# The current simplified implementation assumes no admin-vdc and that the
|
4
4
|
# default vdc name uses id 1. Full multi-vdc support is TBD.
|
5
5
|
---
|
6
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k, ios_xr]
|
6
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k, ios_xr]
|
7
7
|
|
8
8
|
_template:
|
9
9
|
get_command: 'show run vdc all'
|
@@ -16,7 +16,7 @@ destroy:
|
|
16
16
|
set_value: "no vlan %s"
|
17
17
|
|
18
18
|
fabric_control:
|
19
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
19
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
20
20
|
kind: boolean
|
21
21
|
get_command: "show running-config vlan"
|
22
22
|
get_context: ['/^vlan <vlan>/']
|
@@ -30,6 +30,7 @@ mapped_vni:
|
|
30
30
|
N3k: &mapped_vni_n3_8_9k
|
31
31
|
get_command: 'show running vlan'
|
32
32
|
N9k-F: *mapped_vni_n3_8_9k
|
33
|
+
N3k-F: *mapped_vni_n3_8_9k
|
33
34
|
N9k: *mapped_vni_n3_8_9k
|
34
35
|
N5k: &mapped_vni_n5_6k
|
35
36
|
get_command: 'show running vlan 1-4094'
|
@@ -50,7 +51,7 @@ mapped_vni_requires_nv_overlay:
|
|
50
51
|
default_only: false
|
51
52
|
|
52
53
|
mode:
|
53
|
-
_exclude: [N3k, N9k, N9k-F]
|
54
|
+
_exclude: [N3k, N3k-F, N9k, N9k-F]
|
54
55
|
multiple: true
|
55
56
|
get_command: "show vlan"
|
56
57
|
# TBD: 'show vlan' is problematic and should be converted to use show run
|
@@ -70,7 +71,7 @@ name:
|
|
70
71
|
set_value: "%s name %s ; end"
|
71
72
|
|
72
73
|
pvlan_association:
|
73
|
-
_exclude: [N9k-F]
|
74
|
+
_exclude: [N3k-F, N9k-F]
|
74
75
|
multiple: true
|
75
76
|
get_command: "show vlan private-vlan"
|
76
77
|
get_value: '/^<id>\s+(\d+)/'
|
@@ -79,7 +80,7 @@ pvlan_association:
|
|
79
80
|
default_value: []
|
80
81
|
|
81
82
|
pvlan_type:
|
82
|
-
_exclude: [N9k-F]
|
83
|
+
_exclude: [N3k-F, N9k-F]
|
83
84
|
kind: string
|
84
85
|
get_command: 'show vlan private-vlan type'
|
85
86
|
get_value: '/^<id>\s+(\S+)/'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# vpc
|
2
2
|
---
|
3
|
-
_exclude: [ios_xr, N9k-F]
|
3
|
+
_exclude: [ios_xr, N3k-F, N9k-F]
|
4
4
|
|
5
5
|
_template:
|
6
6
|
get_command: 'show running-config vpc all'
|
@@ -64,7 +64,7 @@ dual_active_exclude_interface_vlan_bridge_domain:
|
|
64
64
|
default_value: 'none'
|
65
65
|
|
66
66
|
fabricpath_emulated_switch_id:
|
67
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
67
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
68
68
|
kind: int
|
69
69
|
set_context: ['terminal dont-ask', 'vpc domain <domain>']
|
70
70
|
get_value: '/^fabricpath switch-id\s+(\d+)$/'
|
@@ -72,7 +72,7 @@ fabricpath_emulated_switch_id:
|
|
72
72
|
default_value: false
|
73
73
|
|
74
74
|
fabricpath_multicast_load_balance:
|
75
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
75
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
76
76
|
kind: boolean
|
77
77
|
get_value: '/^fabricpath multicast load-balance$/'
|
78
78
|
set_value: "<state> fabricpath multicast load-balance"
|
@@ -118,14 +118,14 @@ peer_gateway:
|
|
118
118
|
# Exclude everyone for now till the BD command is fully supported
|
119
119
|
peer_gateway_exclude_bridge_domain:
|
120
120
|
kind: string
|
121
|
-
_exclude: [N3k, N5k, N6k, N7k, N9k-F, N9k]
|
121
|
+
_exclude: [N3k, N5k, N6k, N7k, N3k-F, N9k-F, N9k]
|
122
122
|
set_context: ['terminal dont-ask', 'vpc domain <domain>']
|
123
123
|
get_value: '/^peer-gateway exclude bridge-domain\s+(\S+)/'
|
124
124
|
set_value: "peer-gateway exclude-bridge-domain <range>"
|
125
125
|
default_value: ''
|
126
126
|
|
127
127
|
peer_gateway_exclude_vlan:
|
128
|
-
_exclude: [N3k, N9k-F, N9k]
|
128
|
+
_exclude: [N3k, N3k-F, N9k-F, N9k]
|
129
129
|
kind: string
|
130
130
|
set_context: ['terminal dont-ask', 'vpc domain <domain>']
|
131
131
|
get_value: '/^peer-gateway exclude-vlan\s(\S+)/'
|
@@ -181,11 +181,11 @@ peer_switch:
|
|
181
181
|
default_value: false
|
182
182
|
|
183
183
|
phy_port_vpc_module_pids:
|
184
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
184
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
185
185
|
default_only: 'N7[K7]-(?:F2|F3|F4|M3)'
|
186
186
|
|
187
187
|
port_channel_limit:
|
188
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
188
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
189
189
|
auto_default: false
|
190
190
|
kind: boolean
|
191
191
|
get_value: '/^port-channel limit/'
|
@@ -200,7 +200,7 @@ role_priority:
|
|
200
200
|
|
201
201
|
self_isolation:
|
202
202
|
kind: boolean
|
203
|
-
_exclude: [N3k, N5k, N6k, N9k-F, N9k]
|
203
|
+
_exclude: [N3k, N5k, N6k, N3k-F, N9k-F, N9k]
|
204
204
|
get_value: '/^self-isolation/'
|
205
205
|
set_value: "<state> self-isolation"
|
206
206
|
default_value: false
|
@@ -227,7 +227,7 @@ system_priority:
|
|
227
227
|
# Exclude everyone for now till the track command is fully supported
|
228
228
|
track:
|
229
229
|
kind: int
|
230
|
-
_exclude: [N3k, N5k, N6k, N7k, N9k-F, N9k]
|
230
|
+
_exclude: [N3k, N5k, N6k, N7k, N3k-F, N9k-F, N9k]
|
231
231
|
get_value: '/^track\s+(\d+)/'
|
232
232
|
set_value: "<state> track <val>"
|
233
233
|
default_value: 0
|
@@ -16,8 +16,7 @@ all_vnis:
|
|
16
16
|
get_value: '/^member vni (\d+|\d+-\d+) ?(associate-vrf)?$/'
|
17
17
|
|
18
18
|
ingress_replication:
|
19
|
-
_exclude: [N5k, N6k]
|
20
|
-
os_version: 'N7k:8.1.1'
|
19
|
+
_exclude: [N5k, N6k, N7k]
|
21
20
|
kind: string
|
22
21
|
get_value: '/^ingress-replication protocol (\S+)$/'
|
23
22
|
set_value: '<state> ingress-replication protocol <protocol>'
|
@@ -29,8 +28,7 @@ multicast_group:
|
|
29
28
|
default_value: ''
|
30
29
|
|
31
30
|
peer_list:
|
32
|
-
_exclude: [N5k, N6k]
|
33
|
-
os_version: 'N7k:8.1.1'
|
31
|
+
_exclude: [N5k, N6k, N7k]
|
34
32
|
multiple:
|
35
33
|
get_context:
|
36
34
|
- '/^interface <name>$/i'
|
@@ -51,7 +49,7 @@ suppress_arp:
|
|
51
49
|
default_value: false
|
52
50
|
|
53
51
|
suppress_uuc:
|
54
|
-
_exclude: [N9k-F, N9k]
|
52
|
+
_exclude: [N3k-F, N9k-F, N9k]
|
55
53
|
os_version: 'N7k:8.1.1'
|
56
54
|
kind: boolean
|
57
55
|
get_value: '/^suppress-unknown-unicast$/'
|
@@ -437,13 +437,16 @@ module Cisco
|
|
437
437
|
puts "DEBUG: #{text}" if @@debug
|
438
438
|
end
|
439
439
|
|
440
|
-
KNOWN_PLATFORMS = %w(C3064 C3132 C3172 N3k N5k N6k N7k N9k N9k-F
|
440
|
+
KNOWN_PLATFORMS = %w(C3064 C3132 C3172 N35 N3k N3k-F N5k N6k N7k N9k N9k-F
|
441
|
+
XRv9k)
|
441
442
|
|
442
443
|
def self.platform_to_filter(platform)
|
443
444
|
if KNOWN_PLATFORMS.include?(platform)
|
444
445
|
case platform
|
445
446
|
when 'XRv9k'
|
446
447
|
/XRV9/
|
448
|
+
when 'N35'
|
449
|
+
/N3K-C35/
|
447
450
|
when 'N9k'
|
448
451
|
# For non-fretta n9k platforms we need to
|
449
452
|
# match everything except the trailing -F
|
@@ -451,6 +454,13 @@ module Cisco
|
|
451
454
|
when 'N9k-F'
|
452
455
|
# For fretta n9k we need to include the trailing -F
|
453
456
|
/^N9.*-F$/
|
457
|
+
when 'N3k'
|
458
|
+
# For non-fretta n3k platforms we need to
|
459
|
+
# match everything except the trailing -F
|
460
|
+
/^N3...(?!.*-F)/
|
461
|
+
when 'N3k-F'
|
462
|
+
# For fretta n3k we need to include the trailing -F
|
463
|
+
/^N3.*-F$/
|
454
464
|
else
|
455
465
|
Regexp.new platform.tr('k', '')
|
456
466
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# November 2015, Chris Van Heuveln
|
2
2
|
#
|
3
|
-
# Copyright (c) 2015-
|
3
|
+
# Copyright (c) 2015-2017 Cisco and/or its affiliates.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -51,15 +51,22 @@ module Cisco
|
|
51
51
|
# Regexp to match various link bundle interface variants
|
52
52
|
PORTCHANNEL = Regexp.new('(port-channel|Bundle-Ether)', Regexp::IGNORECASE)
|
53
53
|
|
54
|
-
attr_reader :name
|
54
|
+
attr_reader :name, :state_default
|
55
55
|
|
56
|
-
def initialize(name, instantiate=true)
|
56
|
+
def initialize(name, instantiate=true, default_state=false)
|
57
57
|
fail TypeError unless name.is_a?(String)
|
58
58
|
fail ArgumentError unless name.length > 0
|
59
59
|
@name = name.downcase
|
60
60
|
@smr = config_get('interface', 'stp_mst_range')
|
61
61
|
@svr = config_get('interface', 'stp_vlan_range')
|
62
62
|
@match_found = false
|
63
|
+
# Keep track of default vs non-default state for
|
64
|
+
# interfaces that cannot be created/destroyed.
|
65
|
+
@state_default = nil
|
66
|
+
# Track ethernet but not sub-interfaces
|
67
|
+
if @name[/ethernet/] && !@name[/ethernet.*\.\d+/]
|
68
|
+
@state_default = default_state
|
69
|
+
end
|
63
70
|
create if instantiate
|
64
71
|
end
|
65
72
|
|
@@ -72,10 +79,23 @@ module Cisco
|
|
72
79
|
intf_list = config_get('interface', 'all_interfaces')
|
73
80
|
return hash if intf_list.nil?
|
74
81
|
|
82
|
+
# Massage intf_list data into an array that is easy
|
83
|
+
# to work with.
|
84
|
+
intf_list.collect! { |x| x.strip || x }
|
85
|
+
intf_list.delete('')
|
86
|
+
intf_list = intf_list.join(' ').split('interface')
|
87
|
+
intf_list.delete('')
|
88
|
+
|
75
89
|
intf_list.each do |id|
|
76
|
-
|
90
|
+
int_data = id.strip.split(' ')
|
91
|
+
next if int_data[0].nil?
|
92
|
+
id = int_data[0].downcase
|
77
93
|
next if opt && filter(opt, id)
|
78
|
-
|
94
|
+
# If there are any additional options associated
|
95
|
+
# with this interface then it's in a non-default
|
96
|
+
# state.
|
97
|
+
default_state = int_data.size > 1 ? false : true
|
98
|
+
hash[id] = Interface.new(id, false, default_state)
|
79
99
|
end
|
80
100
|
hash
|
81
101
|
end
|
@@ -141,7 +161,16 @@ module Cisco
|
|
141
161
|
end
|
142
162
|
|
143
163
|
def destroy
|
144
|
-
|
164
|
+
if @name[/ethernet/] && !@name[/ethernet.*\.\d+/]
|
165
|
+
config_set('interface', 'default', name: @name)
|
166
|
+
else
|
167
|
+
config_set('interface', 'destroy', name: @name)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def default?
|
172
|
+
state = config_get('interface', 'default', name: @name)
|
173
|
+
state.nil? ? true : false
|
145
174
|
end
|
146
175
|
|
147
176
|
def pvlan_enable
|
@@ -579,6 +608,7 @@ module Cisco
|
|
579
608
|
end
|
580
609
|
|
581
610
|
def ipv4_dhcp_relay_info_trust=(state)
|
611
|
+
return false if !state && !Feature.dhcp_enabled?
|
582
612
|
Feature.dhcp_enable if state
|
583
613
|
config_set('interface', 'ipv4_dhcp_relay_info_trust',
|
584
614
|
name: @name, state: state ? '' : 'no')
|
@@ -593,6 +623,7 @@ module Cisco
|
|
593
623
|
end
|
594
624
|
|
595
625
|
def ipv4_dhcp_relay_src_addr_hsrp=(state)
|
626
|
+
return false if !state && !Feature.dhcp_enabled?
|
596
627
|
Feature.dhcp_enable if state
|
597
628
|
config_set('interface', 'ipv4_dhcp_relay_src_addr_hsrp',
|
598
629
|
name: @name, state: state ? '' : 'no')
|
@@ -611,8 +642,9 @@ module Cisco
|
|
611
642
|
|
612
643
|
def ipv4_dhcp_relay_src_intf=(val)
|
613
644
|
state = val == default_ipv4_dhcp_relay_src_intf ? 'no' : ''
|
614
|
-
|
645
|
+
return false if state == 'no' && !Feature.dhcp_enabled?
|
615
646
|
Feature.dhcp_enable if state.empty?
|
647
|
+
intf = val == default_ipv4_dhcp_relay_src_intf ? '' : val
|
616
648
|
config_set('interface', 'ipv4_dhcp_relay_src_intf',
|
617
649
|
name: @name, state: state, intf: intf)
|
618
650
|
end
|
@@ -626,6 +658,7 @@ module Cisco
|
|
626
658
|
end
|
627
659
|
|
628
660
|
def ipv4_dhcp_relay_subnet_broadcast=(state)
|
661
|
+
return false if !state && !Feature.dhcp_enabled?
|
629
662
|
Feature.dhcp_enable if state
|
630
663
|
config_set('interface', 'ipv4_dhcp_relay_subnet_broadcast',
|
631
664
|
name: @name, state: state ? '' : 'no')
|
@@ -640,6 +673,7 @@ module Cisco
|
|
640
673
|
end
|
641
674
|
|
642
675
|
def ipv4_dhcp_smart_relay=(state)
|
676
|
+
return false if !state && !Feature.dhcp_enabled?
|
643
677
|
Feature.dhcp_enable if state
|
644
678
|
config_set('interface', 'ipv4_dhcp_smart_relay',
|
645
679
|
name: @name, state: state ? '' : 'no')
|
@@ -654,6 +688,7 @@ module Cisco
|
|
654
688
|
end
|
655
689
|
|
656
690
|
def ipv4_forwarding=(state)
|
691
|
+
return if state == ipv4_forwarding
|
657
692
|
config_set('interface', 'ipv4_forwarding',
|
658
693
|
name: @name, state: state ? '' : 'no')
|
659
694
|
end
|
@@ -788,8 +823,9 @@ module Cisco
|
|
788
823
|
|
789
824
|
def ipv6_dhcp_relay_src_intf=(val)
|
790
825
|
state = val == default_ipv6_dhcp_relay_src_intf ? 'no' : ''
|
791
|
-
|
826
|
+
return false if state == 'no' && !Feature.dhcp_enabled?
|
792
827
|
Feature.dhcp_enable if state.empty?
|
828
|
+
intf = val == default_ipv6_dhcp_relay_src_intf ? '' : val
|
793
829
|
config_set('interface', 'ipv6_dhcp_relay_src_intf',
|
794
830
|
name: @name, state: state, intf: intf)
|
795
831
|
end
|
@@ -1831,6 +1867,8 @@ module Cisco
|
|
1831
1867
|
def switchport_vtp=(vtp_set)
|
1832
1868
|
# TODO: throw UnsupportedError instead of returning false?
|
1833
1869
|
return false unless switchport_vtp_mode_capable?
|
1870
|
+
return false if !vtp_set && !Feature.vtp_enabled?
|
1871
|
+
Feature.vtp_enable if vtp_set
|
1834
1872
|
no_cmd = (vtp_set) ? '' : 'no'
|
1835
1873
|
config_set('interface', 'vtp', name: @name, state: no_cmd)
|
1836
1874
|
end
|