Class: Cisco::TacacsServerHost
- Inherits:
-
NodeUtil
show all
- Defined in:
- lib/cisco_node_utils/tacacs_server_host.rb
Overview
TacacsServerHost - node utility class for TACACS+ server host config
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
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, create = true) ⇒ TacacsServerHost
Returns a new instance of TacacsServerHost.
26
27
28
29
30
31
32
33
34
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 26
def initialize(name, create=true)
fail TypeError unless name.is_a? String
fail ArgumentError if name.empty?
@name = name
return unless create
TacacsServer.new.enable unless TacacsServer.enabled
config_set('tacacs_server_host', 'host', '', name)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
23
24
25
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 23
def name
@name
end
|
Class Method Details
.default_encryption_password ⇒ Object
80
81
82
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 80
def self.default_encryption_password
config_get_default('tacacs_server_host', 'encryption_password')
end
|
.default_encryption_type ⇒ Object
.default_port ⇒ Object
63
64
65
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 63
def self.default_port
config_get_default('tacacs_server_host', 'port')
end
|
.default_timeout ⇒ Object
117
118
119
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 117
def self.default_timeout
config_get_default('tacacs_server_host', 'timeout')
end
|
.hosts ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 36
def self.hosts
@hosts = {}
return @hosts unless TacacsServer.enabled
hosts = config_get('tacacs_server_host', 'hosts')
unless hosts.nil?
hosts = [hosts] if hosts.is_a?(Hash)
hosts.each do |name|
@hosts[name] = TacacsServerHost.new(name, false) if @hosts[name].nil?
end
end
@hosts
end
|
Instance Method Details
#destroy ⇒ Object
51
52
53
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 51
def destroy
config_set('tacacs_server_host', 'host', 'no', @name)
end
|
#encryption_key_set(enctype, password) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 84
def encryption_key_set(enctype, password)
fail TypeError unless enctype.is_a? Fixnum
fail ArgumentError if password && ![TACACS_SERVER_ENC_NONE,
TACACS_SERVER_ENC_CISCO_TYPE_7,
TACACS_SERVER_ENC_UNKNOWN,
].include?(enctype)
if enctype == TACACS_SERVER_ENC_UNKNOWN
if encryption_type != TACACS_SERVER_ENC_UNKNOWN
config_set('tacacs_server_host', 'encryption', 'no', @name,
encryption_type,
encryption_password)
end
else
config_set('tacacs_server_host', 'encryption',
'', @name, enctype, password)
end
end
|
#encryption_password ⇒ Object
76
77
78
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 76
def encryption_password
config_get('tacacs_server_host', 'encryption_password', @name)
end
|
#encryption_type ⇒ Object
67
68
69
70
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 67
def encryption_type
type = config_get('tacacs_server_host', 'encryption_type', @name)
type.nil? ? TACACS_SERVER_ENC_UNKNOWN : type.to_i
end
|
#port ⇒ Object
55
56
57
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 55
def port
config_get('tacacs_server_host', 'port', @name)
end
|
#port=(n) ⇒ Object
59
60
61
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 59
def port=(n)
config_set('tacacs_server_host', 'port', @name, n.to_i)
end
|
#timeout ⇒ Object
106
107
108
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 106
def timeout
config_get('tacacs_server_host', 'timeout', @name)
end
|
#timeout=(t) ⇒ Object
110
111
112
113
114
115
|
# File 'lib/cisco_node_utils/tacacs_server_host.rb', line 110
def timeout=(t)
fail TypeError unless t.is_a? Fixnum
return if t == timeout
config_set('tacacs_server_host', 'timeout', '', @name, t)
end
|