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


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

#authenticateObject


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

def authenticate
  config_get('ntp_config', 'authenticate')
end

#authenticate=(enable) ⇒ Object


48
49
50
51
# File 'lib/cisco_node_utils/ntp_config.rb', line 48

def authenticate=(enable)
  state = (enable ? '' : 'no')
  config_set('ntp_config', 'authenticate', state: state)
end

#source_interfaceObject


62
63
64
65
66
67
# File 'lib/cisco_node_utils/ntp_config.rb', line 62

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


69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cisco_node_utils/ntp_config.rb', line 69

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

#trusted_keyObject


53
54
55
# File 'lib/cisco_node_utils/ntp_config.rb', line 53

def trusted_key
  config_get('ntp_config', 'trusted_key')
end

#trusted_key_set(state, key) ⇒ Object


57
58
59
60
# File 'lib/cisco_node_utils/ntp_config.rb', line 57

def trusted_key_set(state, key)
  state = (state ? '' : 'no')
  config_set('ntp_config', 'trusted_key', state: state, key: key)
end