cisco_node_utils 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -1
  3. data/Gemfile +1 -1
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/cisco_node_utils.gemspec +1 -1
  7. data/docs/README-develop-node-utils-APIs.md +2 -0
  8. data/docs/README-maintainers.md +45 -80
  9. data/lib/cisco_node_utils/ace.rb +24 -43
  10. data/lib/cisco_node_utils/bfd_global.rb +1 -0
  11. data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
  12. data/lib/cisco_node_utils/bgp_neighbor.rb +8 -5
  13. data/lib/cisco_node_utils/bgp_neighbor_af.rb +8 -6
  14. data/lib/cisco_node_utils/cisco_cmn_utils.rb +40 -0
  15. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +1 -1
  16. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +8 -4
  17. data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
  18. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +9 -4
  19. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +8 -3
  20. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +2 -1
  21. data/lib/cisco_node_utils/cmd_ref/feature.yaml +5 -0
  22. data/lib/cisco_node_utils/cmd_ref/interface.yaml +8 -0
  23. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +7 -3
  24. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +3 -3
  25. data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
  26. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +13 -0
  27. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +10 -2
  28. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +6 -1
  29. data/lib/cisco_node_utils/cmd_ref/route_map.yaml +8 -0
  30. data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
  31. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +2 -1
  32. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +22 -3
  33. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +2 -1
  34. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +6 -3
  35. data/lib/cisco_node_utils/cmd_ref/yum.yaml +48 -4
  36. data/lib/cisco_node_utils/command_reference.rb +5 -2
  37. data/lib/cisco_node_utils/feature.rb +14 -1
  38. data/lib/cisco_node_utils/interface.rb +13 -0
  39. data/lib/cisco_node_utils/interface_channel_group.rb +33 -25
  40. data/lib/cisco_node_utils/itd_device_group.rb +17 -37
  41. data/lib/cisco_node_utils/itd_service.rb +9 -32
  42. data/lib/cisco_node_utils/node.rb +12 -4
  43. data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
  44. data/lib/cisco_node_utils/ntp_config.rb +19 -1
  45. data/lib/cisco_node_utils/ntp_server.rb +28 -27
  46. data/lib/cisco_node_utils/route_map.rb +33 -51
  47. data/lib/cisco_node_utils/snmpuser.rb +2 -2
  48. data/lib/cisco_node_utils/span_session.rb +149 -0
  49. data/lib/cisco_node_utils/upgrade.rb +21 -17
  50. data/lib/cisco_node_utils/version.rb +2 -2
  51. data/lib/cisco_node_utils/vlan.rb +1 -1
  52. data/lib/cisco_node_utils/vpc.rb +40 -0
  53. data/lib/cisco_node_utils/yum.rb +136 -13
  54. data/spec/schema.yaml +2 -0
  55. data/tests/ciscotest.rb +36 -0
  56. data/tests/test_ace.rb +6 -0
  57. data/tests/test_bfd_global.rb +1 -7
  58. data/tests/test_bgp_af.rb +2 -2
  59. data/tests/test_bgp_af_aa.rb +108 -0
  60. data/tests/test_bgp_neighbor.rb +2 -1
  61. data/tests/test_bgp_neighbor_af.rb +6 -6
  62. data/tests/test_dhcp_relay_global.rb +1 -0
  63. data/tests/test_interface.rb +18 -2
  64. data/tests/test_interface_channel_group.rb +47 -0
  65. data/tests/test_interface_svi.rb +1 -1
  66. data/tests/test_ntp_auth_key.rb +77 -0
  67. data/tests/test_ntp_config.rb +51 -4
  68. data/tests/test_ntp_server.rb +69 -9
  69. data/tests/test_overlay_global.rb +1 -0
  70. data/tests/test_route_map.rb +13 -24
  71. data/tests/test_router_bgp.rb +14 -9
  72. data/tests/test_span_session.rb +155 -0
  73. data/tests/test_stp_global.rb +1 -0
  74. data/tests/test_upgrade.rb +2 -3
  75. data/tests/test_vlan.rb +24 -3
  76. data/tests/test_vlan_private.rb +1 -1
  77. data/tests/test_vpc.rb +42 -17
  78. data/tests/test_vxlan_vtep.rb +1 -0
  79. data/tests/test_vxlan_vtep_vni.rb +5 -1
  80. data/tests/test_yum.rb +7 -30
  81. data/tests/yum_package.yaml +20 -0
  82. metadata +13 -3
@@ -207,12 +207,14 @@ match_mac_list:
207
207
  default_value: []
208
208
 
209
209
  match_metric:
210
+ os_version: 'N9k-F:7.0.3.F2.1'
210
211
  get_value: '/^match metric (.*)$/'
211
212
  set_value: "<state> match metric <metric>"
212
213
  default_value: []
213
214
 
214
215
  match_ospf_area:
215
216
  _exclude: [N5k, N6k, N7k, N9k-F]
217
+ os_version: 'N3k, N9k:7.0.3.I5.1'
216
218
  get_value: '/^match ospf-area (.*)$/'
217
219
  set_value: "<state> match ospf-area <area>"
218
220
  default_value: []
@@ -303,6 +305,7 @@ set_comm_list:
303
305
  default_value: false
304
306
 
305
307
  set_community:
308
+ os_version: 'N9k:7.0.3.I5.1'
306
309
  get_value: '/^set community(?:\s+.*)?$/'
307
310
  set_value: "<state> set community <string>"
308
311
 
@@ -363,6 +366,7 @@ set_extcomm_list:
363
366
  default_value: false
364
367
 
365
368
  set_extcommunity_4bytes:
369
+ os_version: 'N9k-F:7.0.3.F2.1'
366
370
  get_value: '/^set extcommunity 4byteas-generic (.*)$/'
367
371
  set_value: "<state> set extcommunity 4byteas-generic <string>"
368
372
 
@@ -438,6 +442,7 @@ set_ipv4_next_hop:
438
442
 
439
443
  set_ipv4_next_hop_load_share:
440
444
  _exclude: [N5k, N6k]
445
+ os_version: 'N9k-F:7.0.3.F2.1; N9k:7.0.3.I5.1'
441
446
  default_value: false
442
447
 
443
448
  set_ipv4_next_hop_peer_addr:
@@ -448,6 +453,7 @@ set_ipv4_next_hop_peer_addr:
448
453
 
449
454
  set_ipv4_next_hop_redist:
450
455
  kind: boolean
456
+ os_version: 'N3k, N9k:7.0.3.I5.1'
451
457
  get_value: '/^set ip next-hop redist-unchanged$/'
452
458
  set_value: "<state> set ip next-hop redist-unchanged"
453
459
  default_value: false
@@ -487,6 +493,7 @@ set_ipv6_next_hop:
487
493
 
488
494
  set_ipv6_next_hop_load_share:
489
495
  _exclude: [N5k, N6k]
496
+ os_version: 'N9k-F:7.0.3.F2.1; N9k:7.0.3.I5.1'
490
497
  default_value: false
491
498
 
492
499
  set_ipv6_next_hop_peer_addr:
@@ -497,6 +504,7 @@ set_ipv6_next_hop_peer_addr:
497
504
 
498
505
  set_ipv6_next_hop_redist:
499
506
  kind: boolean
507
+ os_version: 'N3k, N9k:7.0.3.I5.1'
500
508
  get_value: '/^set ipv6 next-hop redist-unchanged$/'
501
509
  set_value: "<state> set ipv6 next-hop redist-unchanged"
502
510
  default_value: false
@@ -0,0 +1,65 @@
1
+ # SPAN session
2
+ ---
3
+ _exclude: [N5k, N6k, N7k]
4
+
5
+ _template:
6
+ get_command: "show running monitor all"
7
+ get_context: ["monitor session <id>(?: .*)?"]
8
+ set_context: ["monitor session <id>"]
9
+
10
+ all_sessions:
11
+ multiple:
12
+ get_context: ~
13
+ get_value: '/^monitor session (\d+)/'
14
+
15
+ create:
16
+ set_context: ~
17
+ set_value: 'monitor session <id>'
18
+
19
+ description:
20
+ kind: string
21
+ get_value: '/^description (.*)/'
22
+ set_value: '<state> description <description>'
23
+ default_value: ''
24
+
25
+ destination:
26
+ kind: string
27
+ get_value: '/^destination interface (\S+)$/'
28
+ set_value: '<state> destination interface <intf_name>'
29
+
30
+ destroy:
31
+ set_context: ~
32
+ set_value: 'no monitor session <id>'
33
+
34
+ session_id:
35
+ kind: int
36
+ default_value: false
37
+ get_context: ~
38
+ get_value: '/^monitor session (\d+)/'
39
+ set_context: ~
40
+ set_value: '<state> monitor session <id> <type> <val>'
41
+
42
+ shutdown:
43
+ kind: boolean
44
+ default_value: true
45
+ get_value: '/^no shut$/'
46
+ set_value: '<state> shut'
47
+
48
+ source_interfaces:
49
+ multiple:
50
+ get_value: '/^source interface (\S+) (\w+)$/'
51
+ set_value: '<state> source interface <int_name> <direction>'
52
+ default_value: []
53
+
54
+ source_vlans:
55
+ get_value: '/^source vlan (\S+) (\w+)$/'
56
+ set_value: '<state> source vlan <vlans> <direction>'
57
+ default_value: []
58
+
59
+ type:
60
+ kind: string
61
+ default_value: 'local'
62
+ get_context: ~
63
+ get_value: '/^monitor session \d+ type (\S+)$/'
64
+ set_context: ~
65
+ set_value: 'monitor session <id> type <type>'
@@ -78,7 +78,8 @@ bridge_assurance:
78
78
  default_value: true
79
79
 
80
80
  domain:
81
- _exclude: [N3k, N9k-F, N9k]
81
+ _exclude: [N9k-F]
82
+ os_version: 'N3k, N9k:7.0.3.I6.1'
82
83
  kind: int
83
84
  get_value: '/^spanning-tree domain (\d+)$/'
84
85
  set_value: "<state> spanning-tree domain <domain>"
@@ -7,6 +7,12 @@ _template:
7
7
  get_context: ['/^vpc domain\s*(\d+)$/']
8
8
  set_context: ['vpc domain <domain>']
9
9
 
10
+ arp_synchronize:
11
+ kind: boolean
12
+ default_value: false
13
+ get_value: '/^ip arp synchronize/'
14
+ set_value: "<state> ip arp synchronize"
15
+
10
16
  auto_recovery:
11
17
  kind: boolean
12
18
  _exclude: [N5k, N6k]
@@ -89,12 +95,19 @@ graceful_consistency_check:
89
95
  default_value: true
90
96
 
91
97
  layer3_peer_routing:
98
+ os_version: 'N3k, N9k:7.0.3.I6.1'
92
99
  kind: boolean
93
- _exclude: [N3k, N9k-F, N9k]
94
100
  get_value: '/^layer3 peer-router$/'
95
101
  set_value: "<state> layer3 peer-router"
96
102
  default_value: false
97
103
 
104
+ nd_synchronize:
105
+ kind: boolean
106
+ set_context: ['terminal dont-ask', 'vpc domain <domain>']
107
+ get_value: '/^ipv6 nd synchronize/'
108
+ set_value: "<state> ipv6 nd synchronize"
109
+ default_value: false
110
+
98
111
  peer_gateway:
99
112
  kind: boolean
100
113
  set_context: ['terminal dont-ask', 'vpc domain <domain>']
@@ -160,6 +173,13 @@ peer_keepalive_vrf:
160
173
  get_value: '/^peer-keepalive .*vrf (\S+)/'
161
174
  default_value: 'management'
162
175
 
176
+ peer_switch:
177
+ kind: boolean
178
+ set_context: ['terminal dont-ask', 'vpc domain <domain>']
179
+ get_value: '/^peer-switch/'
180
+ set_value: "<state> peer-switch"
181
+ default_value: false
182
+
163
183
  phy_port_vpc_module_pids:
164
184
  _exclude: [N3k, N5k, N6k, N9k-F, N9k]
165
185
  default_only: 'N7[K7]-(?:F2|F3|F4|M3)'
@@ -186,8 +206,8 @@ self_isolation:
186
206
  default_value: false
187
207
 
188
208
  shutdown:
209
+ os_version: 'N3k, N9k:7.0.3.I6.1'
189
210
  kind: boolean
190
- _exclude: [N3k, N9k-F, N9k]
191
211
  get_value: '/^shutdown/'
192
212
  set_value: "<state> shutdown"
193
213
  default_value: false
@@ -211,4 +231,3 @@ track:
211
231
  get_value: '/^track\s+(\d+)/'
212
232
  set_value: "<state> track <val>"
213
233
  default_value: 0
214
-
@@ -50,7 +50,8 @@ source_intf:
50
50
  default_value: ''
51
51
 
52
52
  source_intf_hold_down_time:
53
- _exclude: [N5k, N6k, N7k]
53
+ _exclude: [N5k, N6k]
54
+ os_version: 'N7k:8.1.1'
54
55
  kind: int
55
56
  get_value: '/^source-interface hold-down-time (\d+)$/'
56
57
  set_value: '<state> source-interface hold-down-time <time>'
@@ -16,7 +16,8 @@ all_vnis:
16
16
  get_value: '/^member vni (\d+|\d+-\d+) ?(associate-vrf)?$/'
17
17
 
18
18
  ingress_replication:
19
- _exclude: [N5k, N6k, N7k]
19
+ _exclude: [N5k, N6k]
20
+ os_version: 'N7k:8.1.1'
20
21
  kind: string
21
22
  get_value: '/^ingress-replication protocol (\S+)$/'
22
23
  set_value: '<state> ingress-replication protocol <protocol>'
@@ -28,7 +29,8 @@ multicast_group:
28
29
  default_value: ''
29
30
 
30
31
  peer_list:
31
- _exclude: [N5k, N6k, N7k]
32
+ _exclude: [N5k, N6k]
33
+ os_version: 'N7k:8.1.1'
32
34
  multiple:
33
35
  get_context:
34
36
  - '/^interface <name>$/i'
@@ -49,7 +51,8 @@ suppress_arp:
49
51
  default_value: false
50
52
 
51
53
  suppress_uuc:
52
- _exclude: [N7k, N9k-F, N9k]
54
+ _exclude: [N9k-F, N9k]
55
+ os_version: 'N7k:8.1.1'
53
56
  kind: boolean
54
57
  get_value: '/^suppress-unknown-unicast$/'
55
58
  set_value: '<state> suppress-unknown-unicast'
@@ -1,12 +1,26 @@
1
1
  # yum
2
2
  ---
3
- _exclude: [ios_xr]
3
+ _exclude: [ios_xr, N5k, N6k, N7k]
4
+
5
+ activate:
6
+ set_value: "install activate <pkg>"
7
+
8
+ add:
9
+ set_value: "install add <pkg> <vrf>"
10
+
11
+ commit:
12
+ set_value: "install commit <pkg>"
4
13
 
5
14
  deactivate:
6
- set_value: "install deactivate %s"
15
+ set_value: "install deactivate <pkg>"
7
16
 
8
17
  install:
9
- set_value: "install add %s %s activate"
18
+ set_value: "install add <pkg> <vrf> activate"
19
+
20
+ pkg_name:
21
+ kind: string
22
+ get_command: "show install pkg-info <pkg>"
23
+ get_value: '/Name\s+:\s+(\S+)/i'
10
24
 
11
25
  query:
12
26
  multiple: true
@@ -14,11 +28,41 @@ query:
14
28
  # pass in the pkg name, retrieve version
15
29
  get_value: '/^%s\S*\s+(\S+)\s+(?:installed|@\S+)/'
16
30
 
31
+ query_activated:
32
+ kind: boolean
33
+ get_command: "show install pkg-info <pkg>"
34
+ get_value: '/Patch\s+State\s+:\s+Active/i'
35
+
36
+ query_added:
37
+ kind: boolean
38
+ get_command: "show install pkg-info <pkg>"
39
+ get_value: '/Name\s+:\s+\S+/i'
40
+
17
41
  query_all:
18
42
  multiple: true
19
43
  get_command: "show install packages"
20
44
  get_value: '/^(\S+)\s+(\S+)\s+(\S+)$/'
21
45
  default_value: []
22
46
 
47
+ query_committed:
48
+ multiple: true
49
+ get_command: "show install committed"
50
+ get_value: '/<pkg>/'
51
+
52
+ query_inactive:
53
+ kind: boolean
54
+ get_command: "show install pkg-info <pkg>"
55
+ get_value: '/Patch\s+State\s+:\s+Inactive/i'
56
+
57
+ query_removed:
58
+ kind: boolean
59
+ get_command: "show install pkg-info <pkg>"
60
+ get_value: '/Name\s+:\s+\S+/i'
61
+
62
+ query_state:
63
+ kind: string
64
+ get_command: "show install pkg-info <pkg>"
65
+ get_value: '/Patch\s+State\s+:\s+(\S+)/i'
66
+
23
67
  remove:
24
- set_value: "install remove %s forced"
68
+ set_value: "install remove <pkg> forced"
@@ -19,7 +19,7 @@ module Cisco
19
19
  # Control a reference for an attribute.
20
20
  class CmdRef
21
21
  attr_reader :feature, :name, :hash
22
- attr_reader :auto_default, :multiple, :kind, :default_only
22
+ attr_reader :auto_default, :multiple, :kind, :default_only, :os_version
23
23
  alias_method :auto_default?, :auto_default
24
24
  alias_method :default_only?, :default_only
25
25
  alias_method :multiple?, :multiple
@@ -28,7 +28,7 @@ module Cisco
28
28
  data_format context value
29
29
  get_data_format get_command get_context get_value
30
30
  set_data_format set_context set_value
31
- auto_default multiple kind)
31
+ auto_default multiple kind os_version)
32
32
 
33
33
  def self.keys
34
34
  KEYS
@@ -48,6 +48,7 @@ module Cisco
48
48
  @default_only = false
49
49
  @multiple = false
50
50
  @kind = nil
51
+ @os_version = nil
51
52
 
52
53
  values_to_hash(values, file)
53
54
 
@@ -86,6 +87,8 @@ module Cisco
86
87
  when 'kind'
87
88
  fail "Unknown 'kind': '#{value}'" unless KINDS.include?(value)
88
89
  @kind = value.to_sym
90
+ when 'os_version'
91
+ @os_version = value
89
92
  else
90
93
  # default_value overrides default_only
91
94
  @default_only = false if key == 'default_value'
@@ -1,6 +1,6 @@
1
1
  # January 2016, Robert W Gries
2
2
  #
3
- # Copyright (c) 2015-2016 Cisco and/or its affiliates.
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.
@@ -147,6 +147,19 @@ module Cisco
147
147
  return false
148
148
  end
149
149
 
150
+ def self.lacp_enable
151
+ return if lacp_enabled?
152
+ config_set('feature', 'lacp')
153
+ end
154
+
155
+ def self.lacp_enabled?
156
+ config_get('feature', 'lacp')
157
+ rescue Cisco::CliError => e
158
+ # cmd will syntax reject when feature is not enabled.
159
+ raise unless e.clierror =~ /Syntax error/
160
+ return false
161
+ end
162
+
150
163
  # ---------------------------
151
164
  def self.nv_overlay_enable
152
165
  # Note: vdc platforms restrict this feature to F3 or newer linecards
@@ -1988,5 +1988,18 @@ module Cisco
1988
1988
  end
1989
1989
  end
1990
1990
  end
1991
+
1992
+ def purge_config=(val)
1993
+ return unless val
1994
+ fail ArgumentError,
1995
+ 'purge_config is only supported on Ethernet interfaces' unless
1996
+ @name[/ethernet/]
1997
+ config_set('interface', 'purge_config', name: @name) if val
1998
+ end
1999
+
2000
+ def purge_config
2001
+ state = config_get('interface', 'purge_config', name: @name)
2002
+ state.nil? ? true : false
2003
+ end
1991
2004
  end # Class
1992
2005
  end # Module
@@ -15,6 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require_relative 'node_util'
18
+ require_relative 'feature'
18
19
 
19
20
  # Add some interface-specific constants to the Cisco namespace
20
21
  module Cisco
@@ -60,39 +61,46 @@ module Cisco
60
61
  # PROPERTIES #
61
62
  ########################################################
62
63
 
63
- def channel_group
64
- config_get('interface_channel_group', 'channel_group', @get_args)
65
- end
66
-
67
- def channel_group=(group)
68
- # 'force' is needed by NXOS to handle the case where a port-channel
69
- # interface is created prior to the channel-group cli; in which case
70
- # the properties of the port-channel interface will be different from
71
- # the ethernet interface. 'force' is not needed if the port-channel is
72
- # created as a result of the channel-group cli but since it does no
73
- # harm we will use it every time.
74
- # IOS XR simply ignores 'force'
75
- if group
76
- state = ''
77
- force = 'force'
64
+ def channel_group_mode
65
+ match = config_get('interface_channel_group', 'channel_group', @get_args)
66
+ return match unless match
67
+ mode = match[1].nil? ? default_channel_group_mode : match[1]
68
+ mode
69
+ end
70
+
71
+ def channel_group_mode_set(group, mode=false)
72
+ cgroup = channel_group
73
+ set_args_keys(state: 'no', group: cgroup, force: '', mode: '', val: '')
74
+ config_set('interface_channel_group', 'channel_group', @set_args) if
75
+ cgroup
76
+ return unless group
77
+ mode = false if mode && mode.to_str == 'on'
78
+ if mode
79
+ Cisco::Feature.lacp_enable
80
+ set_args_keys(state: '', group: group, force: 'force',
81
+ mode: 'mode', val: mode)
82
+ config_set('interface_channel_group', 'channel_group', @set_args)
78
83
  else
79
- state = 'no'
80
- group = force = ''
84
+ set_args_keys(state: '', group: group, force: 'force',
85
+ mode: '', val: '')
86
+ config_set('interface_channel_group', 'channel_group', @set_args)
81
87
  end
82
- config_set('interface_channel_group', 'channel_group',
83
- set_args_keys(state: state, group: group, force: force))
84
- rescue Cisco::CliError => e
85
- # Some XR platforms do not support channel-group configuration
86
- # on some OS versions. Since this is an OS version difference and not
87
- # a platform difference, we can't handle this in the YAML.
88
- raise unless e.message[/the entered commands do not exist/]
89
- raise Cisco::UnsupportedError.new('interface', 'channel_group')
88
+ end
89
+
90
+ def channel_group
91
+ match = config_get('interface_channel_group', 'channel_group', @get_args)
92
+ return match unless match
93
+ match[0].to_i
90
94
  end
91
95
 
92
96
  def default_channel_group
93
97
  config_get_default('interface_channel_group', 'channel_group')
94
98
  end
95
99
 
100
+ def default_channel_group_mode
101
+ config_get_default('interface_channel_group', 'channel_group_mode')
102
+ end
103
+
96
104
  # ----------------------------
97
105
  def description
98
106
  config_get('interface_channel_group', 'description', @get_args)