Class: Cisco::HostName
- Defined in:
- lib/cisco_node_utils/hostname.rb
Overview
Hostname- node utility class for hostname configuration
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #hostname=(host) ⇒ Object
-
#initialize(name, instantiate = true) ⇒ HostName
constructor
A new instance of HostName.
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
Returns a new instance of 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 (readonly)
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
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 |