Class: Puppet::Provider::Netapp
- Inherits:
-
Puppet::Provider
- Object
- Puppet::Provider
- Puppet::Provider::Netapp
- Defined in:
- lib/puppet/provider/netapp.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Class Method Summary collapse
-
.netapp_commands(command_specs) ⇒ Object
Helper function for simplifying the execution of NetApp API commands, in a similar fashion to the commands function.
- .transport ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
6 7 8 |
# File 'lib/puppet/provider/netapp.rb', line 6 def device @device end |
Class Method Details
.netapp_commands(command_specs) ⇒ Object
Helper function for simplifying the execution of NetApp API commands, in a similar fashion to the commands function. Arguments should be a hash of ‘command name’ => ‘api command’.
27 28 29 30 31 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 |
# File 'lib/puppet/provider/netapp.rb', line 27 def self.netapp_commands(command_specs) command_specs.each do |name, apicommand| # The `create_class_and_instance_method` method was added in puppet 3.0.0 if respond_to? :create_class_and_instance_method create_class_and_instance_method(name) do |*args| debug "Executing api call #{[apicommand, args].flatten.join(' ')}" result = transport.invoke(apicommand, *args) if result.results_status == 'failed' raise Puppet::Error, "Executing api call #{[apicommand, args].flatten.join(' ')} failed: #{result.results_reason.inspect}" end result end else # workaround for puppet 2.7.x unless singleton_class.method_defined?(name) (name) do |*args| debug "Executing api call #{[apicommand, args].flatten.join(' ')}" result = transport.invoke(apicommand, *args) if result.results_status == 'failed' raise Puppet::Error, "Executing api call #{[apicommand, args].flatten.join(' ')} failed: #{result.results_reason.inspect}" end result end end unless method_defined?(name) define_method(name) do |*args| self.class.send(name, *args) end end end end end |
.transport ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/puppet/provider/netapp.rb', line 8 def self.transport if Facter.value(:url) then Puppet.debug "Puppet::Util::NetworkDevice::Netapp: connecting via facter url." @device ||= Puppet::Util::NetworkDevice::Netapp::Device.new(Facter.value(:url)) else @device ||= Puppet::Util::NetworkDevice.current raise Puppet::Error, "Puppet::Util::NetworkDevice::Netapp: device not initialized #{caller.join("\n")}" unless @device end @tranport = @device.transport end |
Instance Method Details
#transport ⇒ Object
20 21 22 23 |
# File 'lib/puppet/provider/netapp.rb', line 20 def transport # this calls the class instance of self.transport instead of the object instance which causes an infinite loop. self.class.transport end |