Module: PuppetX::NetDev::EosProviderClassMethods

Defined in:
lib/puppet_x/net_dev/eos_api.rb

Overview

EosProviderClassMethods implements common methods, e.g. ‘self.prefetch`

for EOS providers.

Instance Method Summary collapse

Instance Method Details

#prefetch(resources) ⇒ Hash<String,Puppet::Type>

prefetch associates resources declared in the Puppet catalog with resources discovered on the system using the instances class method. Each resource that has a matching provider in the instances list will have the provider bound to the resource.

Parameters:

  • resources (Hash)

    The set of resources declared in the catalog.

Returns:

  • (Hash<String,Puppet::Type>)

    catalog resources with updated provider instances.



1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/puppet_x/net_dev/eos_api.rb', line 1000

def prefetch(resources)
  provider_hash = instances.each_with_object({}) do |provider, hsh|
    hsh[provider.name] = provider
  end

  resources.each_pair do |name, resource|
    resource.provider = provider_hash[name] if provider_hash[name]
  end
end