Class: Cisco::NtpConfig

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

Overview

NtpConfig - node utility class for NTP Config configuration management

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) ⇒ NtpConfig

Returns a new instance of NtpConfig.



26
27
28
29
30
31
32
# File 'lib/cisco_node_utils/ntp_config.rb', line 26

def initialize(name)
  fail TypeError unless name.is_a?(String)
  fail ArgumentError,
       "This provider only accepts an id of 'default'" \
       unless name.eql?('default')
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.ntpconfigsObject



34
35
36
37
38
# File 'lib/cisco_node_utils/ntp_config.rb', line 34

def self.ntpconfigs
  hash = {}
  hash['default'] = NtpConfig.new('default')
  hash
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
# File 'lib/cisco_node_utils/ntp_config.rb', line 40

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

#source_interfaceObject



44
45
46
47
48
49
# File 'lib/cisco_node_utils/ntp_config.rb', line 44

def source_interface
  source_interface = config_get('ntp_config', 'source_interface')
  source_interface = source_interface.downcase \
                      unless source_interface.nil?
  source_interface
end

#source_interface=(val) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cisco_node_utils/ntp_config.rb', line 51

def source_interface=(val)
  if val.nil? && !source_interface.nil?
    config_set('ntp_config',
               'source_interface',
               state:            'no',
               source_interface: source_interface)
  elsif !val.nil?
    config_set('ntp_config',
               'source_interface',
               state:            '',
               source_interface: val)
  end
end