FAQ
I'm taking some time to refactor a custom provider. I'm trying to move
common code into a parent provider so that it can be shared among all
custom resource providers in the puppet module. While verifying I can call
methods in the parent provider I get the following error:

Error: Could not prefetch jboss7_deployment provider 'jboss7':
     undefined method `echo' for
Puppet::Type::Jboss7_deployment::ProviderJboss7:Class

Here are the relevant snippets of code

class Puppet::Provider::Jboss7 < Puppet::Provider
   def echo(arg)
     info arg
   end
end

require 'puppet/provider/jboss7'
Puppet::Type.type(:jboss7_deployment).provide(:jboss7, :parent =>
Puppet::Provider::Jboss7) do
   echo "hello world"
   ...
end

I modeled this code after the puppetlabs F5 code on the forge.
https://github.com/puppetlabs/puppetlabs-f5 I am running puppet version
3.0.0. Any thoughts on why the jboss7_deployment resource provider code
cannot access the echo method of the parent provider?

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Stefan Schulte at Jul 14, 2013 at 8:23 am

    On 14.07.2013 02:27, Schofield wrote:
    I'm taking some time to refactor a custom provider. I'm trying to move
    common code into a parent provider so that it can be shared among all
    custom resource providers in the puppet module. While verifying I can
    call methods in the parent provider I get the following error:

    Error: Could not prefetch jboss7_deployment provider 'jboss7':
    undefined method `echo' for
    Puppet::Type::Jboss7_deployment::ProviderJboss7:Class

    Here are the relevant snippets of code

    class Puppet::Provider::Jboss7 < Puppet::Provider
    def echo(arg)
    info arg
    end
    end
    so your provider has an instance method "echo" ...
    require 'puppet/provider/jboss7'
    Puppet::Type.type(:jboss7_deployment).provide(:jboss7, :parent =>
    Puppet::Provider::Jboss7) do
    echo "hello world"
    ...
    end
    .. and here you are calling echo in a class context that will execute
    as soon as the corresponding file is loaded. So depending on your actual
    goal you should either only call echo in an instance method

         Puppet::Type.type(:jboss7_deployment).provide(:jboss7, :parent =>
    Puppet::Provider::Jboss7) do
           def create
             echo "I was created"
           end
         end

    or, if you want to call the `echo` method at class level (e.g.
    self.prefetch), define your method as a class method in your parent provider

         class Puppet::Provider::Jboss7 < Puppet::Provider
           def self.echo(arg)
             info arg
           end
         end

    Does this make sense?

    -Stefan

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJul 14, '13 at 12:27a
activeJul 14, '13 at 8:23a
posts2
users2
websitepuppetlabs.com

2 users in discussion

Stefan Schulte: 1 post Schofield: 1 post

People

Translate

site design / logo © 2021 Grokbase