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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba7acf3a46bb0cf8f326a897be60772cd439502
4
- data.tar.gz: 7ae172b66301e5eae043eb734859db8e29887857
3
+ metadata.gz: ace0b0c19f37f945e6c481025338abfb66cde8df
4
+ data.tar.gz: 78a76f33ab99686867a1617ead012558e1953155
5
5
  SHA512:
6
- metadata.gz: c06271bf71dffbb98af27a6efb3ea84dca3ec1015d121c8ee20e5cdacdcbd24e3508d5cc1897a3825b3162ffb58ae8976049e74a0016287da78d16bd84e03d98
7
- data.tar.gz: 67820cc10ad107c46218306356d7ed17467886196285896897b69400e8de773dde60a3a98a3ca09d4693c9b2d9bbb471e1a73f6365b99322f44522daa338dbf2
6
+ metadata.gz: 49002da692d4ddab28b3b5bb9ea3377fd5cfd75675f4723457f59cccb544e394daa658b37aa35848e808f516b02be4bc1714c8900947d757fd6a9cf6d6ea125c
7
+ data.tar.gz: a51f24fa6e47835dbd0a1f8b7fb9b79e3fcd740f89ad4158c54fc86e61d40bf61b8f634f63724ed8570053de12bd8f1d446ffca55a10768bbf51c003e8f2586a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,65 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## [v1.7.0]
5
+
6
+ ### New feature support
7
+
8
+ #### Cisco Resources
9
+ * span_session (@tomcooperca)
10
+ * bgp_af_aggr_addr (@saichint)
11
+
12
+ ### Added
13
+ * Extend vpc with attributes:
14
+ * `peer_switch`
15
+ * `arp_synchronize`
16
+ * `nd_synchronize`
17
+
18
+ * Extend interface with attributes:
19
+ * `purge_config`
20
+
21
+ * Extend interface_channel_group with attributes:
22
+ * `channel_group_mode`
23
+
24
+ * Extend ntp_config with attributes:
25
+ * `authenticate`
26
+ * `trusted_key`
27
+
28
+ * Extend ntp_server with attributes:
29
+ * `key`
30
+ * `maxpoll`
31
+ * `minpoll`
32
+ * `vrf`
33
+
34
+ * Added ntp_auth_key with attributes:
35
+ * `algorithm`
36
+ * `key`
37
+ * `mode`
38
+ * `password`
39
+
40
+ * Extend upgrade with attributes:
41
+ * `package`
42
+
43
+ ### Changed
44
+ * ntp_server initialize now uses options hash
45
+ * Prior to this release ntp_server accepted positional arguments for id and
46
+ prefer. New behavior is to pass attributes as a hash.
47
+
48
+ Example:
49
+ ```
50
+ options = { 'name' => id, 'key' => '999', 'prefer' => 'true',
51
+ 'minpoll' => '5', 'maxpoll' => '8', 'vrf' => 'red' }
52
+ Cisco::NtpServer.new(options, true)
53
+ ```
54
+
55
+ * Modified upgrade to support additional URI
56
+
57
+ * Modified upgrade attribute to drop version check
58
+
59
+ ### Removed
60
+
61
+ ### Resolved Issues
62
+
4
63
  ## [v1.6.0]
5
64
 
6
65
  ### New feature support
@@ -419,6 +478,7 @@ Changelog
419
478
  [git-flow]: https://github.com/petervanderdoes/gitflow-avh
420
479
  [SimpleCov]: https://github.com/colszowka/simplecov
421
480
 
481
+ [v1.7.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.6.0...v1.7.0
422
482
  [v1.6.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.5.0...v1.6.0
423
483
  [v1.5.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.4.1...v1.5.0
424
484
  [v1.4.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.4.0...v1.4.1
@@ -428,4 +488,3 @@ Changelog
428
488
  [v1.1.0]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.1...v1.1.0
429
489
  [v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1
430
490
  [v1.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v0.9.0...v1.0.0
431
-
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ gemspec
6
6
  # These are optional dependencies in the Gem itself,
7
7
  # but we need them for Bundler to use.
8
8
  gem 'net_http_unix'
9
- gem 'grpc'
9
+ gem 'grpc', '= 1.2.5'
10
10
  gem 'pry'
data/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright (c) 2014-2015 Cisco and/or its affiliates.
189
+ Copyright (c) 2014-2017 Cisco and/or its affiliates.
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -216,7 +216,7 @@ See [CHANGELOG](CHANGELOG.md) for a list of changes.
216
216
  ## <a name="license_info">License Information</a>
217
217
 
218
218
 
219
- Copyright (c) 2013-2016 Cisco and/or its affiliates.
219
+ Copyright (c) 2013-2017 Cisco and/or its affiliates.
220
220
 
221
221
  Licensed under the Apache License, Version 2.0 (the "License");
222
222
  you may not use this file except in compliance with the License.
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = CiscoNodeUtils::VERSION
9
9
  spec.authors = ['Rob Gries', 'Alex Hunsberger', 'Glenn Matthews',
10
10
  'Chris Van Heuveln', 'Rich Wellum', 'Mike Wiebe',
11
- 'Jie Yang']
11
+ 'Jie Yang', 'Sai Chintalapudi']
12
12
  spec.email = 'cisco_agent_gem@cisco.com'
13
13
  spec.summary = 'Utilities for management of Cisco network nodes'
14
14
  spec.description = <<-EOF
@@ -159,6 +159,7 @@ The following basic command_reference parameters will be defined for each resour
159
159
  4. `default_value:` This is typically the "factory" default state of the property, expressed as an actual value (true, 12, "off", etc)
160
160
  5. `kind:` The data type of this property. If omitted, the property will be a string by default. Commonly used values for this property are `int` and `boolean`.
161
161
  6. `multiple:` By default a property is assumed to be found once or not at all by the `get_command`/`get_value` lookup, and an error will be raised if multiple matches are found. If multiple matches are valid and expected, you must set `multiple: true` for this property.
162
+ 7. `os_version:` This command_reference parameter is used to specify the product family and minimum os version within that product family required to support the property. Any version that is greater then or equal to the specified os version within the product family will be supported. If nothing is specified, the property is assumed to be supported on all version of software. This is a test_only feature and is ignored outside the context of the minitests and must be used in conjunction with the skip_incompat_version? API defined in the ciscotest.rb file.
162
163
 
163
164
  There are additional YAML command parameters available which are not covered by this document. Please see the [README_YAML.md](../lib/cisco_node_utils/cmd_ref/README_YAML.md) document for more information on the structure and semantics of these files.
164
165
  The properties in this example require additional context for their `get_value` and `set_value` because they need to differentiate between different eigrp instances. This is done with the `context` parameter. (For more complex properties, you can define `get_context` and `set_context` separately if needed.) Most properties will also have a default value.
@@ -177,6 +178,7 @@ The properties in this example require additional context for their `get_value`
177
178
  feature:
178
179
  # feature eigrp must be enabled before configuring router eigrp
179
180
  kind: boolean
181
+ os_version: 'N3k, N9k:7.0.3.I2.1; N7k:8.1.1'
180
182
  get_command: 'show running eigrp all'
181
183
  get_value: 'feature eigrp'
182
184
  set_value: '<state> feature eigrp'
@@ -10,102 +10,67 @@ Guidelines for the core maintainers of the cisco-network-node-utils project - ab
10
10
  * Are new minitests added? Do they provide sufficient coverage and consistent results?
11
11
  * Do minitests pass on all supported platforms
12
12
 
13
- ## Setting up git-flow
13
+ ## Release Process Checklist
14
14
 
15
- If you don't already have [`git-flow`](https://github.com/petervanderdoes/gitflow/) installed, install it.
15
+ When we are considering publishing a new release, all of the following steps must be carried out.
16
+ * NOTE: Use the latest code base in `develop`
16
17
 
17
- Either run `git flow init` from the repository root directory, or manually edit your `.git/config` file. Either way, when done, you should have the following in your config:
18
+ ### Pre-Merge to `master` branch:
18
19
 
19
- ```ini
20
- [gitflow "branch"]
21
- master = master
22
- develop = develop
23
- [gitflow "prefix"]
24
- feature = feature/
25
- release = release/
26
- hotfix = hotfix/
27
- support = support/
28
- versiontag = v
29
- ```
30
-
31
- Most of these are default for git-flow except for the `versiontag` setting.
32
-
33
- ## Release Checklist
34
-
35
- When we are considering publishing a new release, all of the following steps must be carried out (using the latest code base in `develop`):
36
-
37
- 1. Review cisco_node_utils.gemspec
38
- * Is the data still relevant?
39
- * Do the version dependencies need to be updated? (e.g. rubocop)
40
-
41
- 2. Run full minitest suite with various Ruby versions and hardware platforms:
42
- * Ruby versions:
43
- - REQUIRED: the Ruby version(s) bundled with Chef and Puppet (currently 2.1.6)
44
- - OPTIONAL: any/all other Ruby major versions currently supported by this gem (2.0, 2.2.2)
45
- * Platforms (all with latest released software or release candidate)
46
- - N30xx
47
- - N31xx
48
- - N56xx
49
- - N6xxx
50
- - N7xxx
51
- - N9xxx
52
-
53
- 3. Triage any minitest failures.
54
-
55
- 4. Check code coverage results from minitest to see if there are any critical gaps in coverage.
56
-
57
- 5. Build gem and test it in combination with the latest released Puppet module (using Beaker and demo manifests) to make sure no backward compatibility issues have been introduced.
58
-
59
- 6. Make sure CHANGELOG.md accurately reflects all changes since the last release.
60
- * Add any significant changes that weren't documented in the changelog
61
- * Clean up any entries that are overly verbose, unclear, or otherwise could be improved.
62
-
63
- ## Release Process
64
-
65
- When the release checklist above has been fully completed, the process for publishing a new release is as follows:
66
-
67
- 1. Create a release branch. Follow [semantic versioning](http://semver.org):
20
+ 1. Pull release branch based on the `develop` branch.
68
21
  * 0.0.x - a bugfix release
69
22
  * 0.x.0 - new feature(s)
70
23
  * x.0.0 - backward-incompatible change (if unvoidable!)
71
24
 
72
- ```
73
- git flow release start 1.0.1
74
- ```
75
-
76
- 2. In the newly created release branch, update `CHANGELOG.md` (this *should* be automatic if you have installed the Git hooks for this repository):
77
-
78
- ```diff
79
- Changelog
80
- =========
81
-
82
- -(unreleased)
83
- -------------
84
- +1.0.1
85
- +-----
86
- ```
87
-
88
- and also update `version.rb`:
89
-
25
+ 1. Run full minitest regression on [supported platforms.](https://github.com/cisco/cisco-network-node-utils#overview)
26
+ * Fix All Bugs.
27
+ * Make sure proper test case skips are in place for unsupported platforms.
28
+
29
+ 1. Build gem and test it in combination with the latest released Puppet module (using Beaker and demo manifests) to make sure no backward compatibility issues have been introduced.
30
+
31
+ 1. Update [changelog.](https://github.com/cisco/cisco-network-node-utils/blob/develop/CHANGELOG.md)
32
+ * Make sure CHANGELOG.md accurately reflects all changes since the last release.
33
+ * Add any significant changes that weren't documented in the changelog
34
+ * Clean up any entries that are overly verbose, unclear, or otherwise could be improved.
35
+ * Create markdown release tag.
36
+ * [Example](https://github.com/cisco/cisco-network-node-utils/blob/develop/CHANGELOG.md#v120)
37
+ * Add compare versions
38
+ ```diff
39
+ ...
40
+ +[v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1
41
+ [v1.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v0.9.0...v1.0.0
42
+ ```
43
+ * Indicate new platform support (if any) for exisiting providers.
44
+
45
+ 1. Update [cisco_node_utils.gemspec](https://github.com/cisco/cisco-network-node-utils/blob/develop/cisco_node_utils.gemspec) if needed.
46
+ * Is the data still relevant?
47
+ * Do the version dependencies need to be updated? (e.g. rubocop)
48
+
49
+ 1. Update [version.rb](https://github.com/cisco/cisco-network-node-utils/blob/develop/lib/cisco_node_utils/version.rb) file.
90
50
  ```diff
91
51
  - VERSION = '1.0.0'
92
52
  + VERSION = '1.0.1'
93
53
  ```
94
54
 
95
- 3. Finish the release and push it to GitHub:
55
+ 1. Scrub README Docs.
56
+ * Update references to indicate new platorm support where applicable.
57
+ * Update nxos release information where applicable.
96
58
 
97
- ```
98
- git flow release finish 1.0.1
99
- git push origin master
100
- git push origin develop
101
- git push --tags
102
- ```
59
+ 1. Open pull request from release branch against the `master` branch.
60
+ * Merge after approval.
61
+
62
+ ### Post-Merge to `master` branch:
103
63
 
104
- 4. Add release notes on GitHub, for example `https://github.com/cisco/cisco-network-node-utils/releases/new?tag=v1.0.1`. Usually this will just be a copy-and-paste of the relevant section of the `CHANGELOG.md`.
64
+ 1. Create annotated git tag for the release.
65
+ * [HowTo](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags)
105
66
 
106
- 5. Publish the new gem version to rubygems.org:
67
+ 2. Draft a [new release](https://github.com/cisco/cisco-network-node-utils/releases) on github.
107
68
 
69
+ 3. Publish the gem to rubygems.org. (Replace `x.x.x` with actual gem version)
108
70
  ```
109
71
  gem build cisco_node_utils.gemspec
110
- gem push cisco_node_utils-0.9.0.gem
72
+ gem push cisco_node_utils-x.x.x.gem
111
73
  ```
74
+ 4. Merge `master` branch back into `develop` branch.
75
+ * Resolve any merge conflicts
76
+ * Optional: Delete release branch (May want to keep for reference)
@@ -139,33 +139,6 @@ module Cisco
139
139
  config_set('acl', cmd, @set_args)
140
140
  end
141
141
 
142
- # UTILITY FUNCTIONS
143
- # -----------------
144
-
145
- # extract value of property from ace
146
- def extract_value(prop, prefix=nil)
147
- prefix = prop if prefix.nil?
148
- ace_match = ace_get
149
-
150
- # matching ace not found
151
- return nil if ace_match.nil? # no matching ace found
152
-
153
- # property not defined for matching ace
154
- return nil unless ace_match.names.include?(prop)
155
-
156
- # extract and return value that follows prefix + <space>
157
- regexp = Regexp.new("#{Regexp.escape(prefix)} (?<extracted>.*)")
158
- value_match = regexp.match(ace_match[prop])
159
- return nil if value_match.nil?
160
- value_match[:extracted]
161
- end
162
-
163
- # prepend property name prefix/keyword to value
164
- def attach_prefix(val, prop, prefix=nil)
165
- prefix = prop.to_s if prefix.nil?
166
- @set_args[prop] = val.to_s.empty? ? val : "#{prefix} #{val}"
167
- end
168
-
169
142
  # PROPERTIES
170
143
  # ----------
171
144
  def seqno
@@ -272,67 +245,75 @@ module Cisco
272
245
  end
273
246
 
274
247
  def precedence
275
- extract_value('precedence')
248
+ Utils.extract_value(ace_get, 'precedence')
276
249
  end
277
250
 
278
251
  def precedence=(precedence)
279
- attach_prefix(precedence, :precedence)
252
+ @set_args[:precedence] = Utils.attach_prefix(precedence, :precedence)
280
253
  end
281
254
 
282
255
  def dscp
283
- extract_value('dscp')
256
+ Utils.extract_value(ace_get, 'dscp')
284
257
  end
285
258
 
286
259
  def dscp=(dscp)
287
- attach_prefix(dscp, :dscp)
260
+ @set_args[:dscp] = Utils.attach_prefix(dscp, :dscp)
288
261
  end
289
262
 
290
263
  def time_range
291
- extract_value('time_range', 'time-range')
264
+ Utils.extract_value(ace_get, 'time_range', 'time-range')
292
265
  end
293
266
 
294
267
  def time_range=(time_range)
295
- attach_prefix(time_range, :time_range, 'time-range')
268
+ @set_args[:time_range] = Utils.attach_prefix(time_range,
269
+ :time_range,
270
+ 'time-range')
296
271
  end
297
272
 
298
273
  def packet_length
299
- extract_value('packet_length', 'packet-length')
274
+ Utils.extract_value(ace_get, 'packet_length', 'packet-length')
300
275
  end
301
276
 
302
277
  def packet_length=(packet_length)
303
- attach_prefix(packet_length, :packet_length, 'packet-length')
278
+ @set_args[:packet_length] = Utils.attach_prefix(packet_length,
279
+ :packet_length,
280
+ 'packet-length')
304
281
  end
305
282
 
306
283
  def ttl
307
- extract_value('ttl')
284
+ Utils.extract_value(ace_get, 'ttl')
308
285
  end
309
286
 
310
287
  def ttl=(ttl)
311
- attach_prefix(ttl, :ttl)
288
+ @set_args[:ttl] = Utils.attach_prefix(ttl, :ttl)
312
289
  end
313
290
 
314
291
  def http_method
315
- extract_value('http_method', 'http-method')
292
+ Utils.extract_value(ace_get, 'http_method', 'http-method')
316
293
  end
317
294
 
318
295
  def http_method=(http_method)
319
- attach_prefix(http_method, :http_method, 'http-method')
296
+ @set_args[:http_method] = Utils.attach_prefix(http_method,
297
+ :http_method,
298
+ 'http-method')
320
299
  end
321
300
 
322
301
  def tcp_option_length
323
- extract_value('tcp_option_length', 'tcp-option-length')
302
+ Utils.extract_value(ace_get, 'tcp_option_length', 'tcp-option-length')
324
303
  end
325
304
 
326
305
  def tcp_option_length=(tcp_option_length)
327
- attach_prefix(tcp_option_length, :tcp_option_length, 'tcp-option-length')
306
+ @set_args[:tcp_option_length] = Utils.attach_prefix(tcp_option_length,
307
+ :tcp_option_length,
308
+ 'tcp-option-length')
328
309
  end
329
310
 
330
311
  def redirect
331
- extract_value('redirect')
312
+ Utils.extract_value(ace_get, 'redirect')
332
313
  end
333
314
 
334
315
  def redirect=(redirect)
335
- attach_prefix(redirect, :redirect)
316
+ @set_args[:redirect] = Utils.attach_prefix(redirect, :redirect)
336
317
  end
337
318
 
338
319
  def log
@@ -258,6 +258,7 @@ module Cisco
258
258
  # ex: ['100', '100', '25']
259
259
  # CLI: bfd interval 100 min_rx 100 multiplier 25
260
260
  def interval=(arr)
261
+ return if arr == interval
261
262
  interval, min_rx, multiplier = arr
262
263
  set_args_keys(interval: interval, min_rx: min_rx, multiplier: multiplier,
263
264
  state: arr == default_interval ? 'no' : '')
@@ -0,0 +1,207 @@
1
+ # May 2017, Sai Chintalapudi
2
+ #
3
+ # Copyright (c) 2017 Cisco and/or its affiliates.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require_relative 'node_util'
18
+ require_relative 'bgp'
19
+ require_relative 'bgp_af'
20
+
21
+ module Cisco
22
+ # node_utils class for bgp address-family aggregate address management
23
+ class RouterBgpAFAggrAddr < NodeUtil
24
+ attr_reader :asn, :vrf, :afi, :safi, :aa
25
+
26
+ def initialize(asn, vrf, af, aggr_addr, instantiate=true)
27
+ @asn = asn
28
+ @asn = asn.to_i unless /\d+.\d+/.match(asn.to_s)
29
+ @vrf = vrf
30
+ @afi, @safi = af
31
+ @aa = aggr_addr
32
+ temp_af = [@afi.to_s, @safi.to_s]
33
+ @bgp_af = RouterBgpAF.afs[@asn][vrf][temp_af]
34
+ fail "bgp address family #{@asn} #{vrf} #{af} does not exist" if
35
+ @bgp_af.nil?
36
+ set_args_keys_default
37
+ create if instantiate
38
+ end
39
+
40
+ def self.aas
41
+ aa_hash = {}
42
+ RouterBgpAF.afs.each do |asn, vrfs|
43
+ aa_hash[asn] = {}
44
+ vrfs.each do |vrf, afs|
45
+ aa_hash[asn][vrf] = {}
46
+ afs.each do |af, _obj|
47
+ aa_hash[asn][vrf][af] = {}
48
+ afi, safi = af
49
+ get_args = { asnum: asn, afi: afi, safi: safi }
50
+ get_args[:vrf] = vrf unless vrf == 'default'
51
+ aa_list = config_get('bgp_af_aa', 'all_aa', get_args)
52
+ next if aa_list.nil?
53
+ aa_list.each do |aa|
54
+ aa_hash[asn][vrf][af][aa] =
55
+ RouterBgpAFAggrAddr.new(asn, vrf, af, aa, false)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ aa_hash
61
+ end
62
+
63
+ # Helper method to delete @set_args hash keys
64
+ def set_args_keys_default
65
+ keys = { asnum: @asn, afi: @afi, safi: @safi, address: @aa }
66
+ keys[:vrf] = @vrf unless @vrf == 'default'
67
+ @get_args = @set_args = keys
68
+ end
69
+
70
+ # rubocop:disable Style/AccessorMethodName
71
+ def set_args_keys(hash={})
72
+ set_args_keys_default
73
+ @set_args = @get_args.merge!(hash) unless hash.empty?
74
+ end
75
+
76
+ ########################################################
77
+ # PROPERTIES #
78
+ ########################################################
79
+
80
+ def create
81
+ set_args_keys(state: '', as_set: '', summ: '', advertise: '',
82
+ admap: '', suppress: '', sumap: '', attribute: '',
83
+ atmap: '')
84
+ config_set('bgp_af_aa', 'aggr_addr', @set_args)
85
+ end
86
+
87
+ def destroy
88
+ set_args_keys(state: 'no', as_set: '', summ: '', advertise: '',
89
+ admap: '', suppress: '', sumap: '', attribute: '',
90
+ atmap: '')
91
+ config_set('bgp_af_aa', 'aggr_addr', @set_args)
92
+ end
93
+
94
+ def aa_maps_get
95
+ str = config_get('bgp_af_aa', 'aggr_addr', @get_args)
96
+ return if str.nil?
97
+ str.slice!('as-set') if str.include?('as-set')
98
+ str.slice!('summary-only') if str.include?('summary-only')
99
+ str.strip!
100
+ return if str.empty?
101
+ regexp = Regexp.new(' *(?<admap>advertise-map \S+)?'\
102
+ ' *(?<sumap>suppress-map \S+)?'\
103
+ ' *(?<atmap>attribute-map \S+)?')
104
+ regexp.match(str)
105
+ end
106
+
107
+ def as_set
108
+ str = config_get('bgp_af_aa', 'aggr_addr', @get_args)
109
+ return false if str.nil?
110
+ str.include?('as-set') ? true : false
111
+ end
112
+
113
+ def as_set=(val)
114
+ @set_args[:as_set] = val ? 'as-set' : ''
115
+ end
116
+
117
+ def default_as_set
118
+ config_get_default('bgp_af_aa', 'as_set')
119
+ end
120
+
121
+ def summary_only
122
+ str = config_get('bgp_af_aa', 'aggr_addr', @get_args)
123
+ return false if str.nil?
124
+ str.include?('summary-only') ? true : false
125
+ end
126
+
127
+ def summary_only=(val)
128
+ @set_args[:summ] = val ? 'summary-only' : ''
129
+ end
130
+
131
+ def default_summary_only
132
+ config_get_default('bgp_af_aa', 'summary_only')
133
+ end
134
+
135
+ def advertise_map
136
+ val = Utils.extract_value(aa_maps_get, 'admap', 'advertise-map')
137
+ return default_advertise_map if val.nil?
138
+ val
139
+ end
140
+
141
+ def advertise_map=(map)
142
+ @set_args[:advertise] =
143
+ Utils.attach_prefix(map, :advertise, 'advertise-map')
144
+ end
145
+
146
+ def default_advertise_map
147
+ config_get_default('bgp_af_aa', 'advertise_map')
148
+ end
149
+
150
+ def suppress_map
151
+ val = Utils.extract_value(aa_maps_get, 'sumap', 'suppress-map')
152
+ return default_suppress_map if val.nil?
153
+ val
154
+ end
155
+
156
+ def suppress_map=(map)
157
+ @set_args[:suppress] =
158
+ Utils.attach_prefix(map, :suppress, 'suppress-map')
159
+ end
160
+
161
+ def default_suppress_map
162
+ config_get_default('bgp_af_aa', 'suppress_map')
163
+ end
164
+
165
+ def attribute_map
166
+ val = Utils.extract_value(aa_maps_get, 'atmap', 'attribute-map')
167
+ return default_attribute_map if val.nil?
168
+ val
169
+ end
170
+
171
+ def attribute_map=(map)
172
+ @set_args[:attribute] =
173
+ Utils.attach_prefix(map, :attribute, 'attribute-map')
174
+ end
175
+
176
+ def default_attribute_map
177
+ config_get_default('bgp_af_aa', 'attribute_map')
178
+ end
179
+
180
+ # The CLI can take many forms like:
181
+ # aggregate-address 1.1.1.1/32 as-set advertise-map adm
182
+ # aggregate-address 1.1.1.1/32 suppress-map sum attribute-map atm
183
+ # aggregate-address 1.1.1.1/32 summary-only
184
+ # aggregate-address 2.2.2.2/32 summary-only
185
+ def aa_set(attrs)
186
+ # reset everything before setting as some older
187
+ # software versions require it.
188
+ destroy
189
+ set_args_keys_default
190
+ [:suppress_map,
191
+ :advertise_map,
192
+ :attribute_map,
193
+ ].each do |p|
194
+ attrs[p] = '' if attrs[p].nil? || attrs[p] == false
195
+ send(p.to_s + '=', attrs[p])
196
+ end
197
+ [:summary_only,
198
+ :as_set,
199
+ ].each do |p|
200
+ attrs[p] = false if attrs[p].nil?
201
+ send(p.to_s + '=', attrs[p])
202
+ end
203
+ @set_args[:state] = ''
204
+ config_set('bgp_af_aa', 'aggr_addr', @set_args)
205
+ end
206
+ end # Class
207
+ end # Module