cisco_node_utils 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +81 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +72 -6
- data/CONTRIBUTING.md +32 -7
- data/README.md +70 -7
- data/Rakefile +17 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +81 -0
- data/bin/git/hooks/hook_lib +108 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/rubocop +20 -0
- data/bin/git/hooks/pre-commit/validate-diffs +31 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +65 -0
- data/cisco_node_utils.gemspec +9 -3
- data/docs/README-develop-best-practices.md +404 -0
- data/docs/README-develop-node-utils-APIs.md +215 -365
- data/docs/README-maintainers.md +33 -3
- data/docs/template-router.rb +89 -91
- data/docs/template-test_router.rb +52 -55
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils.rb +2 -19
- data/lib/cisco_node_utils/README_YAML.md +1 -9
- data/lib/cisco_node_utils/bgp.rb +664 -0
- data/lib/cisco_node_utils/bgp_af.rb +530 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +425 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +709 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +59 -25
- data/lib/cisco_node_utils/command_reference.rb +72 -74
- data/lib/cisco_node_utils/command_reference_common.yaml +174 -9
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +535 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +4 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -9
- data/lib/cisco_node_utils/configparser_lib.rb +152 -147
- data/lib/cisco_node_utils/dns_domain.rb +79 -0
- data/lib/cisco_node_utils/domain_name.rb +71 -0
- data/lib/cisco_node_utils/interface.rb +167 -161
- data/lib/cisco_node_utils/interface_ospf.rb +78 -81
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +154 -198
- data/lib/cisco_node_utils/node_util.rb +61 -0
- data/lib/cisco_node_utils/ntp_config.rb +65 -0
- data/lib/cisco_node_utils/ntp_server.rb +76 -0
- data/lib/cisco_node_utils/platform.rb +174 -165
- data/lib/cisco_node_utils/radius_global.rb +146 -0
- data/lib/cisco_node_utils/radius_server.rb +295 -0
- data/lib/cisco_node_utils/router_ospf.rb +59 -63
- data/lib/cisco_node_utils/router_ospf_vrf.rb +226 -210
- data/lib/cisco_node_utils/snmpcommunity.rb +52 -58
- data/lib/cisco_node_utils/snmpgroup.rb +22 -23
- data/lib/cisco_node_utils/snmpserver.rb +99 -103
- data/lib/cisco_node_utils/snmpuser.rb +294 -274
- data/lib/cisco_node_utils/syslog_server.rb +92 -0
- data/lib/cisco_node_utils/syslog_settings.rb +69 -0
- data/lib/cisco_node_utils/tacacs_server.rb +137 -133
- data/lib/cisco_node_utils/tacacs_server_host.rb +84 -87
- data/lib/cisco_node_utils/version.rb +2 -1
- data/lib/cisco_node_utils/vlan.rb +28 -31
- data/lib/cisco_node_utils/vrf.rb +80 -0
- data/lib/cisco_node_utils/vtp.rb +100 -97
- data/lib/cisco_node_utils/yum.rb +15 -17
- data/tests/.rubocop.yml +15 -0
- data/tests/basetest.rb +81 -36
- data/tests/ciscotest.rb +38 -78
- data/{lib/cisco_node_utils → tests}/platform_info.rb +12 -8
- data/{lib/cisco_node_utils → tests}/platform_info.yaml +1 -1
- data/tests/test_bgp_af.rb +920 -0
- data/tests/test_bgp_neighbor.rb +403 -0
- data/tests/test_bgp_neighbor_af.rb +589 -0
- data/tests/test_command_config.rb +65 -62
- data/tests/test_command_reference.rb +31 -45
- data/tests/test_dns_domain.rb +113 -0
- data/tests/test_domain_name.rb +86 -0
- data/tests/test_interface.rb +424 -548
- data/tests/test_interface_ospf.rb +248 -432
- data/tests/test_interface_svi.rb +56 -79
- data/tests/test_interface_switchport.rb +196 -272
- data/tests/test_name_server.rb +85 -0
- data/tests/test_node.rb +7 -6
- data/tests/test_node_ext.rb +133 -186
- data/tests/test_ntp_config.rb +49 -0
- data/tests/test_ntp_server.rb +74 -0
- data/tests/test_platform.rb +58 -37
- data/tests/test_radius_global.rb +78 -0
- data/tests/test_radius_server.rb +185 -0
- data/tests/test_router_bgp.rb +838 -0
- data/tests/test_router_ospf.rb +49 -80
- data/tests/test_router_ospf_vrf.rb +274 -392
- data/tests/test_snmpcommunity.rb +128 -172
- data/tests/test_snmpgroup.rb +12 -14
- data/tests/test_snmpserver.rb +160 -189
- data/tests/test_snmpuser.rb +568 -717
- data/tests/test_syslog_server.rb +88 -0
- data/tests/test_syslog_settings.rb +54 -0
- data/tests/test_tacacs_server.rb +113 -148
- data/tests/test_tacacs_server_host.rb +108 -161
- data/tests/test_vlan.rb +63 -79
- data/tests/test_vrf.rb +92 -0
- data/tests/test_vtp.rb +108 -126
- data/tests/test_yum.rb +47 -41
- metadata +92 -56
- data/.rubocop_todo.yml +0 -293
- data/docs/.rubocop.yml +0 -13
- data/docs/template-feature.rb +0 -45
- data/docs/template-test_feature.rb +0 -51
- data/tests/test_all_cisco.rb +0 -46
@@ -40,6 +40,10 @@ show_version:
|
|
40
40
|
description:
|
41
41
|
test_config_get_regex: !ruby/regexp '/.*Hardware\n cisco (\w+ \w+ \(\w+ \w+\) \w+).*/'
|
42
42
|
|
43
|
+
system_image:
|
44
|
+
# TODO: not sure if this is needed
|
45
|
+
config_get_token: "isan_file_name"
|
46
|
+
test_config_get_regex: !ruby/regexp '/.*system image file is: (.*)$.*/'
|
43
47
|
|
44
48
|
vtp:
|
45
49
|
version:
|
@@ -10,15 +10,6 @@ inventory:
|
|
10
10
|
inventory:
|
11
11
|
test_config_get_regex: [!ruby/regexp '/.*\nNAME: "(.+)",\s+DESCR: "(.+)"\s+\nPID: (\S+)\s+,\s+VID: (.+) ,\s+SN: (.+)\s+\n/', !ruby/regexp '/.*NAME: "(.+)",\s+DESCR: "(.+)"\s+PID: (\S+)\s+,\s+VID: (.+) ,\s+SN: (.+)\s+\n/']
|
12
12
|
|
13
|
-
|
14
|
-
show_version:
|
15
|
-
boot_image:
|
16
|
-
test_config_get_regex: !ruby/regexp '/.*NXOS image file is: (.*)$.*/'
|
17
|
-
|
18
|
-
system_image:
|
19
|
-
config_get_token: "kick_file_name"
|
20
|
-
test_config_get_regex: !ruby/regexp '/.*NXOS image file is: (.*)$.*/'
|
21
|
-
|
22
13
|
snmp_user:
|
23
14
|
auth_protocol:
|
24
15
|
config_get_token: "auth"
|
@@ -29,168 +29,173 @@
|
|
29
29
|
# y b | y a | trans match)
|
30
30
|
|
31
31
|
module Cisco
|
32
|
-
module ConfigParser
|
33
|
-
|
34
|
-
|
32
|
+
module ConfigParser
|
33
|
+
# Configuration class - helper for dealing with config CLI
|
34
|
+
class Configuration
|
35
|
+
attr_accessor :configuration
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
# Constructor for Configuration
|
38
|
+
#
|
39
|
+
# @raise [ArgumentError] if config_str is not a String
|
40
|
+
# @param config_str [String] to parse
|
41
|
+
def initialize(config_str)
|
42
|
+
unless config_str.kind_of? String
|
43
|
+
fail ArgumentError, 'Argument is not a String.'
|
44
|
+
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
@configuration = {}
|
47
|
+
@ordered_keys = []
|
48
|
+
@indent = ''
|
49
|
+
parse(config_str)
|
50
|
+
end # initialize
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
52
|
+
# build_min_config_hash
|
53
|
+
#
|
54
|
+
# Build a config hash of the minimum keys that would be needed to update
|
55
|
+
# current config to all of the changes in the "must" config. Each hash key
|
56
|
+
# is a configuration command; some keys have subconfigs which must be
|
57
|
+
# checked before dismissing top-level keys as present. This method is
|
58
|
+
# used primarily by the free-form command_config providers.
|
59
|
+
#
|
60
|
+
# @param current [Hash] superset of running-config & must config
|
61
|
+
# @param must [Hash] pending config from recipe, manifest, etc
|
62
|
+
# @param min_config [Hash] in-progress recursion-built minimum config
|
63
|
+
# @return min_config [Hash] in-progress recursion-built minimum config
|
64
|
+
#
|
65
|
+
def self.build_min_config_hash(current, must, min_config={})
|
66
|
+
return {} if must.empty? # base case
|
67
|
+
must.each do |k, v| # check each must{k} is present in current{}
|
68
|
+
if current.key?(k) # if cmd is in current then compare subconfig
|
69
|
+
min_config[k] = Configuration.new('')
|
70
|
+
min_config[k].configuration =
|
71
|
+
build_min_config_hash(current[k].configuration,
|
72
|
+
v.configuration, {})
|
73
|
+
if min_config[k].configuration.empty?
|
74
|
+
# no differing subconfigs, so empty hash is returned
|
75
|
+
min_config.delete(k)
|
76
|
+
end
|
77
|
+
else # command NOT in current, apply it + all subcommands
|
78
|
+
min_config[k] = v
|
73
79
|
end
|
74
|
-
else # command NOT in current, apply it + all subcommands
|
75
|
-
min_config[k] = v
|
76
80
|
end
|
77
|
-
|
78
|
-
|
79
|
-
end # build_min_config_hash
|
81
|
+
min_config
|
82
|
+
end # build_min_config_hash
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
def self.config_hash_to_str(cmd_hash, str='')
|
85
|
+
return '' if cmd_hash.empty?
|
86
|
+
cmd_hash.each do |k, v|
|
87
|
+
str += k + "\n"
|
88
|
+
str += config_hash_to_str(v.configuration, '')
|
89
|
+
end
|
90
|
+
str
|
91
|
+
end # config_hash_to_str
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
# Get base command and prefix
|
94
|
+
#
|
95
|
+
# @param command [String]
|
96
|
+
# @return [String, String] containing prefix (if any) and
|
97
|
+
# base command.
|
98
|
+
def base_commands(command)
|
99
|
+
prefix, base = command.match(/^(no )?(.*)$/).captures
|
100
|
+
prefix = '' if prefix.nil?
|
101
|
+
[prefix, base]
|
102
|
+
end # base_commands
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
104
|
+
# Compare ConfigParser::Configuration objects
|
105
|
+
#
|
106
|
+
# @param config [ConfigParser::Configuration] obj to search
|
107
|
+
# for match.
|
108
|
+
# @return [String] containing match, empty if no match found.
|
109
|
+
def compare_with(config)
|
110
|
+
return nil if config.nil?
|
111
|
+
existing = ''
|
112
|
+
@ordered_keys.each do |config_line|
|
113
|
+
command = config_line.strip
|
114
|
+
submode = @configuration[command]
|
115
|
+
fail StopIteration, 'Could not find submode.' if submode.nil?
|
113
116
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
117
|
+
if special_command?(command)
|
118
|
+
# match special exit/end command
|
119
|
+
existing << config_line
|
120
|
+
break
|
121
|
+
elsif config.include_command?(command)
|
122
|
+
# match whole command
|
123
|
+
existing << config_line
|
124
|
+
config_submode = config.submode_config(command)
|
125
|
+
existing << submode.compare_with(config_submode)
|
126
|
+
next
|
127
|
+
end # if
|
125
128
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
129
|
+
prefix, base = base_commands(command)
|
130
|
+
if prefix != '' && !config.include_command?(base)
|
131
|
+
existing << config_line
|
132
|
+
next
|
133
|
+
end
|
130
134
|
end
|
131
|
-
|
132
|
-
|
133
|
-
end # compare_with
|
135
|
+
existing
|
136
|
+
end # compare_with
|
134
137
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
# @return [Array] containing command with leading/trailing
|
139
|
+
# whitespace removed.
|
140
|
+
def mode_configuration
|
141
|
+
@ordered_keys.collect(&:strip)
|
142
|
+
end # mode_configuration
|
140
143
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
# Check command [Array] for test command
|
145
|
+
#
|
146
|
+
# @param command [String] test command
|
147
|
+
# @return [Boolean] true if command found, else false
|
148
|
+
def include_command?(command)
|
149
|
+
commands = mode_configuration
|
150
|
+
commands.include?(command)
|
151
|
+
end # include_command?
|
149
152
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
153
|
+
# Parse each config command line and create a
|
154
|
+
# hash of ConfigParser::Configuration objects
|
155
|
+
#
|
156
|
+
# @param config_str [String] Config command
|
157
|
+
def parse(config_str)
|
158
|
+
config_str += "\n"
|
159
|
+
config_str.gsub!(/^\s*$\n/, '')
|
160
|
+
# ignore leading ! or # (comments)
|
161
|
+
config_str.gsub!(/^\s*[!#].*$\n/, '')
|
162
|
+
if config_str.match(/^ *\t/)
|
163
|
+
highlight_str = config_str.gsub(/\t/, '[TAB]')
|
164
|
+
fail "Tab character detected in indentation area:\n" + highlight_str
|
165
|
+
end
|
166
|
+
indent_level = config_str.match(/^\s*/)
|
167
|
+
@indent = indent_level.to_s # capture indentation of level
|
168
|
+
escaped_indent = Regexp.escape(@indent)
|
169
|
+
# Find current configuration mode lines
|
170
|
+
@ordered_keys = config_str.scan(/^#{escaped_indent}\S.*\n/)
|
171
|
+
@ordered_keys.each do |config_line|
|
172
|
+
command = config_line.strip
|
173
|
+
escaped_cmd = Regexp.escape(config_line)
|
174
|
+
submode_string = config_str.match(
|
175
|
+
/^(?:#{escaped_cmd})((?:#{escaped_indent}\s.+\n)*)/).captures.join
|
176
|
+
@configuration[command] = Configuration.new(submode_string)
|
177
|
+
end
|
178
|
+
end # parse
|
174
179
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
180
|
+
# Process 'exit' and 'end' commands
|
181
|
+
#
|
182
|
+
# @param command [String] Configuration command.
|
183
|
+
# @return [Boolean] true when command is
|
184
|
+
# 'exit' or 'end', else false
|
185
|
+
def special_command?(command)
|
186
|
+
command =~ /^(?:exit|end)/
|
187
|
+
end # special_command?
|
183
188
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
189
|
+
# Fetch ConfigParser::Configuration object containing config_line
|
190
|
+
#
|
191
|
+
# @param config_line [String]
|
192
|
+
# @return [ConfigParser::Configuration] containing config_line
|
193
|
+
def submode_config(config_line)
|
194
|
+
command = config_line.strip
|
195
|
+
@configuration[command]
|
196
|
+
end # submode_config
|
192
197
|
|
193
|
-
|
194
|
-
|
195
|
-
end # ConfigParser
|
198
|
+
private :base_commands, :parse, :special_command?
|
199
|
+
end # Configuration
|
200
|
+
end # ConfigParser
|
196
201
|
end # Cisco
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of DnsDomain class
|
3
|
+
#
|
4
|
+
# September 2015, Hunter Haugen
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# "group" is a standard SNMP term but in NXOS "role" is used to serve the
|
21
|
+
# purpose of group; thus this provider utility does not create snmp groups
|
22
|
+
# and is limited to reporting group (role) existence only.
|
23
|
+
|
24
|
+
require_relative 'node_util'
|
25
|
+
|
26
|
+
module Cisco
|
27
|
+
# DnsDomain - node utility class for DNS search domain config management
|
28
|
+
class DnsDomain < NodeUtil
|
29
|
+
attr_reader :name, :vrf
|
30
|
+
|
31
|
+
def initialize(name, vrf=nil, instantiate=true)
|
32
|
+
unless name.is_a? String
|
33
|
+
fail TypeError, "Expected a string, got a #{name.class.inspect}"
|
34
|
+
end
|
35
|
+
@name = name
|
36
|
+
@vrf = vrf
|
37
|
+
create if instantiate
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.dnsdomains(vrf=nil)
|
41
|
+
if vrf.nil?
|
42
|
+
domains = config_get('dnsclient', 'domain_list')
|
43
|
+
else
|
44
|
+
domains = config_get('dnsclient', 'domain_list_vrf', vrf: vrf)
|
45
|
+
end
|
46
|
+
return {} if domains.nil?
|
47
|
+
|
48
|
+
hash = {}
|
49
|
+
domains.each do |name|
|
50
|
+
hash[name] = DnsDomain.new(name, vrf, false)
|
51
|
+
end
|
52
|
+
hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def ==(other)
|
56
|
+
(name == other.name) && (vrf == other.vrf)
|
57
|
+
end
|
58
|
+
|
59
|
+
def create
|
60
|
+
if @vrf.nil?
|
61
|
+
config_set('dnsclient', 'domain_list',
|
62
|
+
state: '', name: @name)
|
63
|
+
else
|
64
|
+
config_set('dnsclient', 'domain_list_vrf',
|
65
|
+
state: '', name: @name, vrf: @vrf)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def destroy
|
70
|
+
if @vrf.nil?
|
71
|
+
config_set('dnsclient', 'domain_list',
|
72
|
+
state: 'no', name: @name)
|
73
|
+
else
|
74
|
+
config_set('dnsclient', 'domain_list_vrf',
|
75
|
+
state: 'no', name: @name, vrf: @vrf)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Domain Name provider class
|
2
|
+
#
|
3
|
+
# October 2015, Bryan Jen
|
4
|
+
#
|
5
|
+
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'node_util'
|
20
|
+
|
21
|
+
module Cisco
|
22
|
+
# DomainName- node utility class for domain name configuration
|
23
|
+
class DomainName < NodeUtil
|
24
|
+
attr_reader :name, :vrf
|
25
|
+
|
26
|
+
def initialize(name, vrf=nil, instantiate=true)
|
27
|
+
@name = name
|
28
|
+
@vrf = vrf
|
29
|
+
create if instantiate
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.domainnames(vrf=nil)
|
33
|
+
hash = {}
|
34
|
+
if vrf.nil?
|
35
|
+
domains = config_get('dnsclient', 'domain_name')
|
36
|
+
else
|
37
|
+
domains = config_get('dnsclient', 'domain_name_vrf', vrf: vrf)
|
38
|
+
end
|
39
|
+
return hash if domains.nil?
|
40
|
+
|
41
|
+
domains.each do |name|
|
42
|
+
hash[name] = DomainName.new(name, vrf, false)
|
43
|
+
end
|
44
|
+
hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def ==(other)
|
48
|
+
(name == other.name) && (vrf == other.vrf)
|
49
|
+
end
|
50
|
+
|
51
|
+
def create
|
52
|
+
if @vrf.nil?
|
53
|
+
config_set('dnsclient', 'domain_name',
|
54
|
+
state: '', name: @name)
|
55
|
+
else
|
56
|
+
config_set('dnsclient', 'domain_name_vrf',
|
57
|
+
state: '', name: @name, vrf: @vrf)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
if @vrf.nil?
|
63
|
+
config_set('dnsclient', 'domain_name',
|
64
|
+
state: 'no', name: @name)
|
65
|
+
else
|
66
|
+
config_set('dnsclient', 'domain_name_vrf',
|
67
|
+
state: 'no', name: @name, vrf: @vrf)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|