Class: Cisco::HostName
Overview
Hostname- node utility class for hostname configuration
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NodeUtil
client, #client, config_get, #config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, #node, node, platform, #platform, supports?, #supports?
Constructor Details
#initialize(name, instantiate = true) ⇒ HostName
26
27
28
29
|
# File 'lib/cisco_node_utils/hostname.rb', line 26
def initialize(name, instantiate=true)
@name = name
create if instantiate
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
24
25
26
|
# File 'lib/cisco_node_utils/hostname.rb', line 24
def name
@name
end
|
Class Method Details
.hostname ⇒ Object
31
32
33
34
35
36
|
# File 'lib/cisco_node_utils/hostname.rb', line 31
def self.hostname
hash = {}
hostname = config_get('hostname', 'name')
hash[hostname] = HostName.new(hostname, false)
hash
end
|
Instance Method Details
#==(other) ⇒ Object
50
51
52
|
# File 'lib/cisco_node_utils/hostname.rb', line 50
def ==(other)
name == other.name
end
|
#create ⇒ Object
54
55
56
|
# File 'lib/cisco_node_utils/hostname.rb', line 54
def create
config_set('hostname', 'name', state: '', name: @name)
end
|
#destroy ⇒ Object
58
59
60
|
# File 'lib/cisco_node_utils/hostname.rb', line 58
def destroy
config_set('hostname', 'name', state: 'no', name: @name)
end
|
#hostname=(host) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/cisco_node_utils/hostname.rb', line 38
def hostname=(host)
if host
config_set(
'hostname', 'name',
state: '', name: host)
else
config_set(
'hostname', 'name',
state: 'no', name: '')
end
end
|