[chef] Re: Help with vagrant-butcher and the Chef API


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Help with vagrant-butcher and the Chef API
  • Date: Fri, 28 Dec 2012 11:23:50 -0800


On Wednesday, December 26, 2012 at 10:41 AM, Cassiano Leal wrote:

Ohai Chefs,

I'm struggling to get vagrant-butcher [0] to work in my current setup. I'm not sure what has changed since last time, but it used to work just fine. (And I know that this last sentence isn't very helpful, but it's what I've got :)

I'm using the methods Chef::Node.load and Chef::ApiClient.load, with a subsequent destroy on the object [1].

Digging into the Chef source code, I found out that I can call Chef::Node.build [2] and then destroy, and it works fine.

The same cannot be said about ApiClient, which doesn't have a build method. For that, load should work, except it doesn't. The problem seems to be that it's trying to reference the client by a key 'clientname' [3], whereas I get a hash with a 'name' key instead [4].

Any clues as to what I'm doing wrong here, or if I should file bugs for Chef?

Also, if anyone had any success or failures in using the gem, I'd like to know as much as possible so that I can pinpoint where the issue might lie as well.

Thanks!

Chef is relying on the json gem to "inflate" the response into an ApiClient object. Normally, the json gem looks at the "json_class" key and if that exists, will lookup the matching class and then call class_name.json_create(data) to return an object of the matching class. The json gem supports changing the magic key name via (e.g.) JSON.create_id = "not_json_class". If neither Node.load nor ApiClient.load are working correctly, then I'd try grepping the relevant source code for 'create_id=', to see if that's being disabled somewhere (maybe by vagrant?).

If you can't re-enable the 'json_class' stuff, then you can pass the hash responses you get into Node.json_create() and ApiClient.json_create() manually. Alternatively, you can just make a HTTP DELETE call to $base_url/clients/$name (and similar for nodes).

As I mentioned in a previous thread, we'd like to eliminate our reliance on the 'json_class' stuff, but it'll take a fair bit of work so it's not going to happen soon.


-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§