Ignasi, Very much appreciate all the information you provided. I created myrecipe.rb and tried upload it and received this error when it reached
mChefContext.getApi().updateCookbook("cookbook_test", "0.1.0", cookbook); org.jclouds.http.HttpResponseException: command: PUT https://sw-ucs-15/cookbooks/cookbook_test/0.1.0 HTTP/1.1 failed with response: HTTP/1.1 400 Bad Request; content: [Field 'metadata.version' missing] How do I set the metadata.version? Any insight will be deeply appreciate. Alex private void createNewCookbook() throws Exception { // define the file you want in the cookbook FilePayload content = Payloads.newFilePayload(new File("c:\\temp\\myrecipe.rb")); content.getContentMetadata().setContentType("text/plain"); // get an md5 so that you can see if the server already has it or not Payloads.calculateMD5(content); // Note that java collections cannot effectively do equals or hashcodes on // byte arrays, // so let's convert to a list of bytes. List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5()); // request an upload site for this file UploadSandbox site = mChefContext.getApi().getUploadSandboxForChecksums(ImmutableSet.of(md5)); try { assert site.getChecksums().containsKey(md5) : md5 + " not in " + site.getChecksums(); ChecksumStatus status = site.getChecksums().get(md5); if (status.needsUpload()) { mChefContext.getApi().uploadContent(status.getUrl(), content); } mChefContext.getApi().commitSandbox(site.getSandboxId(), true); } catch (RuntimeException e) { mChefContext.getApi().commitSandbox(site.getSandboxId(), false); e.printStackTrace(); } // create a new cookbook CookbookVersion cookbook = new CookbookVersion("cookbook_test", "0.1.0"); cookbook.getRootFiles().add(new Resource(content)); // upload the cookbook to the remote server mChefContext.getApi().updateCookbook("cookbook_test", "0.1.0", cookbook); } On Fri, Jul 19, 2013 at 3:55 PM, Ignasi <ignasi.barr...@gmail.com> wrote: > Yes, it is supported. You just have to upload the desired files to the Chef > Server, and then update the desired cookbook to include them in it. You can > take a look at this live test [1] that creates a new cookbook with a just > uploaded file. > > Also, consider subscribing and participating in the jclouds user list [2]. > You might get better feedback there! > > > HTH > > Ignasi > > > [1] > > https://github.com/jclouds/jclouds-chef/blob/master/core/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java#L80-118 > [2] u...@jclouds.incubator.apache.org< > https://mail.google.com/mail/mu/mp/53/> > > > On Saturday, 20 July 2013, Alex Tang <2degh...@gmail.com<javascript:_e({}, > 'cvml', '2degh...@gmail.com');>> wrote: > > > Hi, > > > > I was not able to find an API from jclouds-chef (1.5.5) which uploads a > > new recipe (including its content) to the Chef server. Is this > supported? > > > > I see there is an API called getApi().uploadContent( > > location, content). Is > > this the one I should use. Any example of this API usage? > > > > Thanks > > Alex > > >