Class: Puppet::Util::NetworkDevice::Cisco_ios::Model::Snmp_host
- Inherits:
-
Base
- Object
- Base
- Puppet::Util::NetworkDevice::Cisco_ios::Model::Snmp_host
- Defined in:
- lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb
Instance Attribute Summary collapse
-
#base_cmd ⇒ Object
Returns the value of attribute base_cmd.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(transport, facts, options) ⇒ Snmp_host
constructor
A new instance of Snmp_host.
- #mod_const_base ⇒ Object
- #mod_path_base ⇒ Object
- #param_class ⇒ Object
- #register_modules ⇒ Object
-
#update(is = {}, should = {}) ⇒ Object
Since we have to construct a single string of our Options override update here to implent the needed custom logic TODO: Extract the Common behaviour into seperated Methods that can be overloaded so we dont have all that duplication.
- #update_existing?(is, should) ⇒ Boolean
Constructor Details
#initialize(transport, facts, options) ⇒ Snmp_host
Returns a new instance of Snmp_host.
12 13 14 15 16 17 18 19 20 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 12 def initialize(transport, facts, ) super(transport, facts) # Initialize some defaults @params ||= {} @name = [:name] if .key? :name # Register all needed Modules based on the availiable Facts register_modules end |
Instance Attribute Details
#base_cmd ⇒ Object
Returns the value of attribute base_cmd.
10 11 12 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 10 def base_cmd @base_cmd end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 9 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 9 def params @params end |
Instance Method Details
#mod_const_base ⇒ Object
57 58 59 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 57 def mod_const_base return Puppet::Util::NetworkDevice::Cisco_ios::Model::Snmp_host end |
#mod_path_base ⇒ Object
53 54 55 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 53 def mod_path_base return 'puppet/util/network_device/cisco_ios/model/snmp_host' end |
#param_class ⇒ Object
61 62 63 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 61 def param_class return Puppet::Util::NetworkDevice::Cisco_ios::Model::StringValue end |
#register_modules ⇒ Object
65 66 67 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 65 def register_modules register_new_module(:base) end |
#update(is = {}, should = {}) ⇒ Object
Since we have to construct a single string of our Options override update here to implent the needed custom logic TODO: Extract the Common behaviour into seperated Methods that can be overloaded so we dont have all that duplication
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 26 def update(is = {}, should = {}) # Delete the Property here since we cant really compare params in a propertys validate block # Puppet Magic... return unless configuration_changed?(is, should, :keep_ensure => true) missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort missing_commands.delete(:ensure) raise Puppet::Error, "Undefined commands for #{missing_commands.join(', ')}" unless missing_commands.empty? # We have to remove the old Instance if it exists here before we update the Params so we still can work # with the old (parsed) Values if update_existing?(is, should) before_update transport.command("no " + construct_cmd) after_update end [is.keys, should.keys].flatten.uniq.sort.each do |property| next if should[property] == :undef @params[property].value = should[property] unless should[property].nil? end before_update perform_update after_update end |
#update_existing?(is, should) ⇒ Boolean
49 50 51 |
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb', line 49 def update_existing?(is, should) is[:ensure] == :present && should[:ensure] == :present end |