Class: Puppet::Provider::IosRadiusGlobal::CiscoIos
- Inherits:
-
Object
- Object
- Puppet::Provider::IosRadiusGlobal::CiscoIos
- Defined in:
- lib/puppet/provider/ios_radius_global/cisco_ios.rb
Overview
Configure the domain name of the device
Class Method Summary collapse
- .commands_from_instance(instance) ⇒ Object
- .commands_hash ⇒ Object
- .instances_from_cli(output) ⇒ Object
Instance Method Summary collapse
- #canonicalize(_context, resources) ⇒ Object
- #commands_hash ⇒ Object
- #get(context, _names = nil) ⇒ Object
- #set(context, changes) ⇒ Object
- #update(context, _name, should) ⇒ Object
Class Method Details
.commands_from_instance(instance) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 26 def self.commands_from_instance(instance) commands = [] if instance[:remove_attributes] remove_instance = { name: (instance[:name]).to_s, attributes: instance[:remove_attributes] } remove_commands = PuppetX::CiscoIOS::Utility.set_tuple_values(remove_instance, commands_hash, 'attributes', 'attribute_id', 'attribute_string') remove_commands.each do |remove_command| commands << "no #{remove_command}" end instance.delete(:remove_attributes) end commands.concat(PuppetX::CiscoIOS::Utility.set_tuple_values(instance, commands_hash, 'attributes', 'attribute_id', 'attribute_string')) commands += Puppet::Provider::RadiusGlobal::CiscoIos.commands_from_instance(instance) commands end |
.commands_hash ⇒ Object
10 11 12 13 14 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 10 def self.commands_hash local_commands_hash = PuppetX::CiscoIOS::Utility.load_yaml(File.(__dir__) + '/command.yaml') radius_global_commands_hash = PuppetX::CiscoIOS::Utility.load_yaml(File.(__dir__) + '/../radius_global/command.yaml') @commands_hash = local_commands_hash.merge(radius_global_commands_hash) { |_key, oldval, newval| (oldval.to_a + newval.to_a).to_h } end |
.instances_from_cli(output) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 16 def self.instances_from_cli(output) new_instance_fields = [] new_instance = {} new_instance[:attributes] = PuppetX::CiscoIOS::Utility.parse_multiples(output, commands_hash, 'attributes', 0) || [] new_instance = new_instance.merge(Puppet::Provider::RadiusGlobal::CiscoIos.instances_from_cli(output).first) new_instance.delete_if { |_k, v| v.nil? } new_instance_fields << new_instance new_instance_fields end |
Instance Method Details
#canonicalize(_context, resources) ⇒ Object
72 73 74 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 72 def canonicalize(_context, resources) resources end |
#commands_hash ⇒ Object
41 42 43 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 41 def commands_hash Puppet::Provider::IosRadiusGlobal::CiscoIos.commands_hash end |
#get(context, _names = nil) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 45 def get(context, _names = nil) output = context.transport.run_command_enable_mode(PuppetX::CiscoIOS::Utility.get_values(commands_hash)) return [] if output.nil? return_value = Puppet::Provider::IosRadiusGlobal::CiscoIos.instances_from_cli(output) PuppetX::CiscoIOS::Utility.enforce_simple_types(context, return_value) end |
#set(context, changes) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 52 def set(context, changes) changes.each do |name, change| should = change[:should] if change[:is][:attributes] should[:remove_attributes] = change[:is][:attributes] - should[:attributes] should[:attributes] = should[:attributes] - change[:is][:attributes] end context.updating(name) do update(context, name, should) end end end |
#update(context, _name, should) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/puppet/provider/ios_radius_global/cisco_ios.rb', line 65 def update(context, _name, should) array_of_commands_to_run = Puppet::Provider::IosRadiusGlobal::CiscoIos.commands_from_instance(should) array_of_commands_to_run.each do |command| context.transport.run_command_conf_t_mode(command) end end |