Class: Cisco::SyslogServer
- Defined in:
- lib/cisco_node_utils/syslog_server.rb
Overview
NtpServer - node utility class for NTP Server configuration management
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#vrf ⇒ Object
readonly
Returns the value of attribute vrf.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#initialize(name, level = nil, vrf = nil, instantiate = true) ⇒ SyslogServer
constructor
A new instance of SyslogServer.
Methods inherited from NodeUtil
config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show
Constructor Details
#initialize(name, level = nil, vrf = nil, instantiate = true) ⇒ SyslogServer
Returns a new instance of SyslogServer.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 26 def initialize(name, level=nil, vrf=nil, instantiate=true) fail TypeError unless name.is_a?(String) fail TypeError unless name.length > 0 @name = name fail TypeError unless level.is_a?(Integer) || level.nil? @level = level fail TypeError unless vrf.is_a?(String) || vrf.nil? @vrf = vrf create if instantiate end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
24 25 26 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 24 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 24 def name @name end |
#vrf ⇒ Object (readonly)
Returns the value of attribute vrf.
24 25 26 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 24 def vrf @vrf end |
Class Method Details
.syslogservers ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 43 def self.syslogservers hash = {} syslogservers_list = config_get('syslog_server', 'server') return hash if syslogservers_list.nil? syslogservers_list.each do |id| level = config_get('syslog_server', 'level', id) vrf = config_get('syslog_server', 'vrf', id) hash[id] = SyslogServer.new(id, level, vrf, false) end hash end |
Instance Method Details
#==(other) ⇒ Object
60 61 62 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 60 def ==(other) (name == other.name) && (vrf == other.vrf) end |
#create ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 64 def create # Set timestamp units config_set('syslog_server', 'server', state: '', ip: "#{name}", level: level.nil? ? '' : "#{level}", vrf: vrf.nil? ? '' : "use-vrf #{vrf}", ) end |
#destroy ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cisco_node_utils/syslog_server.rb', line 75 def destroy # Set timestamp units config_set('syslog_server', 'server', state: 'no', ip: "#{name}", level: '', vrf: '', ) end |