Class: Puppet::Util::NetworkDevice::Cisco_ios::Model::Aaa_group
- Inherits:
-
Base
- Object
- Base
- Puppet::Util::NetworkDevice::Cisco_ios::Model::Aaa_group
- Defined in:
- lib/puppet/util/network_device/cisco_ios/model/aaa_group.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
- #construct_server_cmd ⇒ Object
-
#initialize(transport, facts, options) ⇒ Aaa_group
constructor
A new instance of Aaa_group.
- #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.
Constructor Details
#initialize(transport, facts, options) ⇒ Aaa_group
Returns a new instance of Aaa_group.
10 11 12 13 14 15 16 17 18 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.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/aaa_group.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/aaa_group.rb', line 8 def params @params end |
Instance Method Details
#construct_server_cmd ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 68 def construct_server_cmd p = { :server => @params[:server], :acct_port => @params[:acct_port], :auth_port => @params[:auth_port], } Puppet::Util::NetworkDevice::Sorter \ .new(p) \ .tsort \ .collect { |p| p.get_fragment if p.fragment and p.value and p.supported? } \ .reject { |f| f.nil? } \ .join " " end |
#mod_const_base ⇒ Object
24 25 26 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 24 def mod_const_base return Puppet::Util::NetworkDevice::Cisco_ios::Model::Aaa_group end |
#mod_path_base ⇒ Object
20 21 22 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 20 def mod_path_base return 'puppet/util/network_device/cisco_ios/model/aaa_group' end |
#param_class ⇒ Object
28 29 30 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 28 def param_class return Puppet::Util::NetworkDevice::Cisco_ios::Model::StringValue end |
#register_modules ⇒ Object
32 33 34 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 32 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
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 |
# File 'lib/puppet/util/network_device/cisco_ios/model/aaa_group.rb', line 40 def update(is = {}, should = {}) return unless configuration_changed?(is, should) before_update if should[:ensure] == :present missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort missing_commands.delete(:name) missing_commands.delete(:protocol) missing_commands.delete(:ensure) 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 should[property] == :undef @params[property].value = :absent if should[property] == :absent || should[property].nil? @params[property].value = should[property] unless should[property] == :absent || should[property].nil? end transport.command("aaa group server #{should[:protocol]} #{@name}", :prompt => /\(config-sg-#{should[:protocol]}\)#\z/n) transport.command(construct_server_cmd) transport.command("exit") [:local_authentication, :local_authorization].each do |auth| if !is[auth] and should[auth] @params[auth].update(@transport, is[auth]) end end else transport.command("no aaa group server #{is[:protocol]} #{@name}") end after_update end |