Class: Puppet::Util::NetworkDevice::Cisco_ios::Model::Acl
- Inherits:
-
Base
- Object
- Base
- Puppet::Util::NetworkDevice::Cisco_ios::Model::Acl
- Defined in:
- lib/puppet/util/network_device/cisco_ios/model/acl.rb
Instance Attribute Summary collapse
-
#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) ⇒ Acl
constructor
A new instance of Acl.
- #mod_const_base ⇒ Object
- #mod_path_base ⇒ Object
- #param_class ⇒ Object
- #register_modules ⇒ Object
- #remove_acl(is) ⇒ Object
- #update(is = {}, should = {}) ⇒ Object
Constructor Details
#initialize(transport, facts, options) ⇒ Acl
Returns a new instance of Acl.
10 11 12 13 14 15 16 17 18 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 10 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
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 8 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 8 def params @params end |
Instance Method Details
#mod_const_base ⇒ Object
24 25 26 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 24 def mod_const_base return Puppet::Util::NetworkDevice::Cisco_ios::Model::Acl end |
#mod_path_base ⇒ Object
20 21 22 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 20 def mod_path_base return 'puppet/util/network_device/cisco_ios/model/acl' end |
#param_class ⇒ Object
28 29 30 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 28 def param_class return Puppet::Util::NetworkDevice::Cisco_ios::Model::ScopedValue end |
#register_modules ⇒ Object
73 74 75 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 73 def register_modules register_new_module(:base) end |
#remove_acl(is) ⇒ Object
69 70 71 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 69 def remove_acl(is) transport.command("no ip access-list #{is[:type]} #{is[:name]}") end |
#update(is = {}, should = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/puppet/util/network_device/cisco_ios/model/acl.rb', line 32 def update(is = {}, should = {}) return unless configuration_changed?(is, should) should_present = should[:ensure] == :present is.delete(:ensure) should.delete(:ensure) missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort missing_commands.delete(:name) raise Puppet::Error, "Undefined commands for #{missing_commands.join(', ')}" unless missing_commands.empty? [is.keys, should.keys].flatten.uniq.sort.each do |property| next if property == :ensure || property == :name next if should[property] == :undef if should[property] == :absent || should[property].nil? then @params[property].value = :absent else @params[property].value = should[property] end end before_update if should_present then transport.command("ip access-list standard #{@name}", :prompt => /\(config-std-nacl\)#\z/n) Puppet::Util::NetworkDevice::Sorter.new(@params).tsort.each do |param| # We dont want to change undefined values next if should[param.name] == :undef || should[param.name].nil? param.update(@transport, is[param.name]) unless is[param.name] == should[param.name] end transport.command("exit") else remove_acl(is) end after_update end |