That worked quite well, thanks!! That's what happens when you copy-paste without understanding everything :)
Let me then share with the rest the little script to extract (and hint to insert) a full catalog into another PuppetDB: #!/usr/bin/python # Echo the output to a file (e.g. catalog.json), and use this way: # curl -vv -H "Accept: application/json" 'http://localhost:8080/v2/commands' --data-urlencode [email protected] import json import urllib2 response = urllib2.urlopen('http://localhost:8080/v3/catalogs/<node_name>') data = json.load(response) object = { "command": "replace catalog", "version": 2, "payload": data } print json.dumps(object, indent=2) I guess you could potentiate this script by running the curl itself, but that would require permissions on both PuppetDBs. BR/Pablo On 10/17/2013 06:02 PM, Deepak Giridharagopal wrote: > On Thu, Oct 17, 2013 at 9:09 AM, Pablo Fernandez > <[email protected] <mailto:[email protected]>> wrote: > > Hi, > > I tried to upload a full catalog with the command: > # curl -vv -G -H "Accept: application/json" > 'http://localhost:8080/v2/commands' --data-urlencode > [email protected] <mailto:[email protected]> > > Where catalog.json would start with: > {"version": 2, "command": "replace catalog", "payload": {"data": > {"version ...etc... > > But I get a: > HTTP/1.1 413 FULL head > > This seems to be the Jetty server not accepting big POST. This one > is 112 KB, which is not really big for a catalog. > I probably hit a configuration issue, but I don't see the option > in the [jetty] section... bug maybe? > > > (resending as I forgot to reply to the list) > > The "-G" command you're giving to curl forces it to use a GET for the > data...can you try after removing that option? That should default it > to POST. > > deepak > > > > Thanks! > BR/Pablo > > > > On 10/16/2013 09:16 AM, Pablo Fernandez wrote: >> Dear Deepak, >> >> >> On 10/15/2013 06:51 PM, Deepak Giridharagopal wrote: >>> >>> 1) You don't need to formulate the "payload" as a pre-serialized >>> JSON string (with all the requisite escaping and whatnot) >>> anymore. As of "replace catalog" version 2, you can just inline >>> the raw JSON object itself: >>> >>> "payload": {"data": ..., "metadata": ..., ...} >>> >>> The entire command is a single JSON object that way, and the >>> payload is just a normal value in that hash >>> 3) With curl, you can supply an argument of "--data-urlencode >>> [email protected] <mailto:[email protected]>". Then >>> you can just put the payload in a mycatalog.json file, and curl >>> should automatically load the content and urlencode it for you. >>> See http://curl.haxx.se/docs/manpage.html#--data-urlencode >> >> >> This RAW version is quite interesting (escaping part of the thing >> is a bit nasty), I will play with it :) >> >> I have a question, though... if you can insert the RAW payload... >> what happens with the command name? >> I guess you mean: >> "payload": { "command": "replace catalog", "version": 2, >> "payload": {"data": ..., "metadata": ..., ...} } >> Without any escape sequence at all, right? >> >> And then send it with the --data-urlencode >> >> >> >>> >>> That said, as there aren't any relationships specified in your >>> above set of resource (no require/subscribe params, for example) >>> I'm curious why the empty list of edges fails. That smells like >>> a bug to me; would you mind filing a ticket against PuppetDB >>> with the above command included? We can take a look and see >>> what's up. >> >> Submitted! >> >> >> Thanks a lot, >> Pablo Fernandez >> -- >> 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 [email protected] >> <mailto:[email protected]>. >> To post to this group, send email to >> [email protected] <mailto:[email protected]>. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
