Class: Cisco::DomainName

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/domain_name.rb

Overview

DomainName- node utility class for domain name 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, vrf = nil, instantiate = true) ⇒ DomainName

Returns a new instance of DomainName.



26
27
28
29
30
# File 'lib/cisco_node_utils/domain_name.rb', line 26

def initialize(name, vrf=nil, instantiate=true)
  @name = name
  @vrf = vrf
  create if instantiate
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/cisco_node_utils/domain_name.rb', line 24

def name
  @name
end

#vrfObject (readonly)

Returns the value of attribute vrf.



24
25
26
# File 'lib/cisco_node_utils/domain_name.rb', line 24

def vrf
  @vrf
end

Class Method Details

.domainnames(vrf = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/cisco_node_utils/domain_name.rb', line 32

def self.domainnames(vrf=nil)
  hash = {}
  if vrf.nil?
    domain = config_get('dnsclient', 'domain_name')
  else
    domain = config_get('dnsclient', 'domain_name_vrf', vrf: vrf)
  end
  hash[domain] = DomainName.new(domain, vrf, false) unless domain.empty?
  hash
end

Instance Method Details

#==(other) ⇒ Object



43
44
45
# File 'lib/cisco_node_utils/domain_name.rb', line 43

def ==(other)
  (name == other.name) && (vrf == other.vrf)
end

#createObject



47
48
49
50
51
52
53
54
55
# File 'lib/cisco_node_utils/domain_name.rb', line 47

def create
  if @vrf.nil?
    config_set('dnsclient', 'domain_name',
               state: '', name: @name)
  else
    config_set('dnsclient', 'domain_name_vrf',
               state: '', name: @name, vrf: @vrf)
  end
end

#destroyObject



57
58
59
60
61
62
63
64
65
# File 'lib/cisco_node_utils/domain_name.rb', line 57

def destroy
  if @vrf.nil?
    config_set('dnsclient', 'domain_name',
               state: 'no', name: @name)
  else
    config_set('dnsclient', 'domain_name_vrf',
               state: 'no', name: @name, vrf: @vrf)
  end
end