Class: Rbeapi::Api::Radius
Overview
Radius provides instance methods to retrieve and set radius configuration values.
Constant Summary collapse
- DEFAULT_KEY_FORMAT =
0- DEFAULT_KEY =
nil- SERVER_REGEXP =
Regular expression to extract a radius server’s attributes from the running-configuration text. The explicit [ ] spaces enable line wrapping and indentation with the /x flag.
/radius-server[ ]host[ ](.*?) (?:[ ]vrf[ ]([^\s]+))? (?:[ ]auth-port[ ](\d+))? (?:[ ]acct-port[ ](\d+))? (?:[ ]timeout[ ](\d+))? (?:[ ]retransmit[ ](\d+))? (?:[ ]key[ ](\d+)[ ](\w+))?\s/x
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#get ⇒ Array<Hash>
get Returns an Array with a single resource Hash describing the current state of the global radius configuration on the target device.
-
#remove_server(opts = {}) ⇒ Boolean
remove_server removes the SNMP server identified by the hostname, auth_port, and acct_port attributes.
-
#set_global_key(opts = {}) ⇒ Boolean
set_global_key configures the global radius-server key.
-
#set_global_retransmit(opts = {}) ⇒ Boolean
set_global_retransmit configures the global radius-server retransmit value.
-
#set_global_timeout(opts = {}) ⇒ Boolean
set_global_timeout configures the radius-server timeout value.
-
#update_server(opts = {}) ⇒ Boolean
update_server configures a radius server resource on the target device.
Methods inherited from Entity
#command_builder, #configure, #configure_interface, #get_block, #initialize, instance
Constructor Details
This class inherits a constructor from Rbeapi::Api::Entity
Instance Method Details
#get ⇒ Array<Hash>
get Returns an Array with a single resource Hash describing the current state of the global radius configuration on the target device. This method is intended to be used by a provider’s instances class method.
The resource hash returned contains the following information:
* key: (String) the key either in plain text or hashed format
* key_format: (Fixnum) e.g. 0 or 7
* timeout: (Fixnum) seconds before the timeout period ends
* retransmit: (Fixnum), e.g. 3, attempts after first timeout expiry.
* servers: (Array),
74 75 76 77 78 79 80 81 |
# File 'lib/rbeapi/api/radius.rb', line 74 def get global = {} global.merge!(parse_global_timeout) global.merge!(parse_global_retransmit) global.merge!(parse_global_key) resource = { global: global, servers: parse_servers } resource end |
#remove_server(opts = {}) ⇒ Boolean
remove_server removes the SNMP server identified by the hostname, auth_port, and acct_port attributes.
303 304 305 306 307 308 309 |
# File 'lib/rbeapi/api/radius.rb', line 303 def remove_server(opts = {}) cmd = "no radius-server host #{opts[:hostname]}" cmd << " vrf #{opts[:vrf]}" if opts[:vrf] cmd << " auth-port #{opts[:auth_port]}" if opts[:auth_port] cmd << " acct-port #{opts[:acct_port]}" if opts[:acct_port] configure cmd end |
#set_global_key(opts = {}) ⇒ Boolean
set_global_key configures the global radius-server key. If the enable option is false, radius-server key is configured using the no keyword. If the default option is specified, radius-server key is configured using the default keyword. If both options are specified, the default keyword option takes precedence.
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/rbeapi/api/radius.rb', line 194 def set_global_key(opts = {}) value = opts[:value] enable = opts.fetch(:enable, true) key_format = opts[:key_format] || 0 default = opts[:default] || false case default when true cmds = 'default radius-server key' when false if enable cmds = "radius-server key #{key_format} #{value}" else cmds = 'no radius-server key' end end configure cmds end |
#set_global_retransmit(opts = {}) ⇒ Boolean
set_global_retransmit configures the global radius-server retransmit value. If the enable option is false, then the radius-server retransmit value is configured using the no keyword. If the default option is specified, the radius-server retransmit value is configured using the default keyword. If both options are specified then the default keyword takes precedence
269 270 271 272 |
# File 'lib/rbeapi/api/radius.rb', line 269 def set_global_retransmit(opts = {}) cmd = command_builder('radius-server retransmit', opts) configure cmd end |
#set_global_timeout(opts = {}) ⇒ Boolean
set_global_timeout configures the radius-server timeout value. If the enable option is false, then radius-server timeout is configured using the no keyword. If the default option is specified, radius-server timeout is configured using the default keyword. If both options are specified then the default keyword takes precedence.
238 239 240 241 |
# File 'lib/rbeapi/api/radius.rb', line 238 def set_global_timeout(opts = {}) cmd = command_builder('radius-server timeout', opts) configure cmd end |
#update_server(opts = {}) ⇒ Boolean
update_server configures a radius server resource on the target device. This API method maps to the ‘radius server host` command, e.g. `radius-server host 10.11.12.13 auth-port 1024 acct-port 2048 timeout 30 retransmit 5 key 7 011204070A5955`
283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/rbeapi/api/radius.rb', line 283 def update_server(opts = {}) # beware: order of cli keyword options counts key_format = opts[:key_format] || 7 cmd = "radius-server host #{opts[:hostname]}" cmd << " vrf #{opts[:vrf]}" if opts[:vrf] cmd << " auth-port #{opts[:auth_port]}" if opts[:auth_port] cmd << " acct-port #{opts[:acct_port]}" if opts[:acct_port] cmd << " timeout #{opts[:timeout]}" if opts[:timeout] cmd << " retransmit #{opts[:retransmit]}" if opts[:retransmit] cmd << " key #{key_format} #{opts[:key]}" if opts[:key] configure cmd end |