- From: Adam Jacob <
>
- To:
- Subject: [chef] Re: Re: Re: Re: making a library global?
- Date: Tue, 20 Jul 2010 17:36:47 -0700
resource_name is used for lookup and stringification of resources:
@resource_name = :pylabs_qshell
Means you can do:
resources(:pylabs_qshell => "foo")
Adam
On Mon, Jul 19, 2010 at 8:52 AM, Daniel DeLeo
<
>
wrote:
>
>
>
> -- START --
>
> require 'chef/resource/script'
>
>
>
> class Chef
>
> class Resource
>
> class QShell < Chef::Resource::Script
>
>
>
> def initialize(name, run_context=nil)
>
> super
>
>
>
>
>
> = :pylabs_qshell
>
>
>
>
>
> = "/opt/qbase3/qshell -f"
>
> end
>
>
>
> end
>
> end
>
> end
>
> -- END --
>
>
>
> All required files are in my client cache, but still I get a
>
> NoMethodError on "pylabs_qshell", which is the @resource_name.
>
>
>
> 2010-07-19_09:41:42.73142 [Mon, 19 Jul 2010 11:41:42 +0200] ERROR:
>
> NoMethodError
>
> 2010-07-19_09:41:42.73143 [Mon, 19 Jul 2010 11:41:42 +0200] FATAL:
>
> undefined method `pylabs_qshell' for #<Chef::Recipe:0x7fc7e53f9aa8>
>
> 2010-07-19_09:41:42.73143
>
> /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:55:in
>
> `method_missing'
>
> 2010-07-19_09:41:42.73143
>
> /srv/chef/cache/cookbooks/dss/recipes/pylabs.rb:23:in `from_file'
>
> 2010-07-19_09:41:42.73144
>
> /usr/lib/ruby/gems/1.8/gems/chef-0.9.6/bin/../lib/chef/cookbook_version.rb:316:in
>
> `load_recipe'
>
>
>
> What am I missing here?
>
>
>
> Ringo
>
>
>
>
Resources are looked up by finding a constant defined on
>
Chef::Resource matching the CamelCased name of the method you called,
>
so calling pylabs_qshell causes chef to look for
>
Chef::Resource::PylabsQshell. I'm not sure what the resource_name is
>
used for, but it doesn't manipulate the way the method names map to
>
resource classes.
>
>
Dan DeLeo
>
--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E:
Archive powered by MHonArc 2.6.16.