Alex Tang <[email protected]> writes:
> Hi
>
> 1) It seems that the Chef server URL supplied to JCloud-Chef must be a
> domain name, not IP address. Is it possible to supply an IP address?
>
Otherwise SSL handshake will not work out of the box.
> 2) This method,
>
> mChefContext.getApi().deleteDatabagItem(DATABAG_NAME, databagItemName);
>
I think I could re-create this using a test recipe (Groovy)
api.deleteDatabag("test")
Gson gson = new Gson()
api.createDatabag("test")
Properties config = new Properties()
config.setProperty("foo", "bar");
def databagItem = api.createDatabagItem("test", new
DatabagItem("config", gson.toJson(config)))
def databagItemId = databagItem.getId()
assertEquals(databagItem.getId(), "config");
databagItem = api.getDatabagItem("test", databagItemId)
assertEquals(databagItem.getId(), "config");
databagItem = api.deleteDatabagItem("test", databagItemId)
assertEquals(databagItem.getId(), "config");
databagItem = api.getDatabagItem("test", databagItemId)
assertNull(databagItem)
And it is evident that, chef server output for delete is not the same as
documented here http://docs.opscode.com/api_chef_server.html#id11
See below the actual response.
noman in ~/projects/cu097-chef-repo
G |master X| --> knife raw --method DELETE /data/test/config
{"name":"data_bag_item_test_config","json_class":"Chef::DataBagItem","chef_type":"data_bag_item","data_bag":"test","raw_data":{"id":"config",
"foo":"bar"}}
Created a JIRA artifact
https://issues.apache.org/jira/browse/JCLOUDS-335 to track this.
Thanks and Regards
Noorul
> throws the following exception. Any insight why? The databag item was
> delete propertly.
>
> Thanks,
> Alex
>
> SEVERE: Error parsing input
> com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
> databag item must be a json hash ex. {"id":"item1","my_key":"my_data"}; was
> {"name":"data_bag_item_cisco_packages_N3000-node1","json_class":"Chef::DataBagItem","chef_type":"data_bag_item","data_bag":"cisco_packages","raw_data":{"id":"N3000-node1","created_by":"alextang","packages":[{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf08335.bin"},{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf23555.bin"},{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf42365.bin"}],"location":"
> ftp://10.2.3.4","creation_time":"Thursday, October 3, 2013 2:39:00 PM PDT"}}
> at com.google.gson.Gson.fromJson(Gson.java:802)
> at com.google.gson.Gson.fromJson(Gson.java:757)
> at com.google.gson.Gson.fromJson(Gson.java:706)
> at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:47)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:86)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:80)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:66)
> at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:46)
> at com.google.common.util.concurrent.Futures$3.apply(Futures.java:376)
> at
> com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:518)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: java.lang.IllegalStateException: databag item must be a json
> hash ex. {"id":"item1","my_key":"my_data"}; was
> {"name":"data_bag_item_cisco_packages_N3000-node1","json_class":"Chef::DataBagItem","chef_type":"data_bag_item","data_bag":"cisco_packages","raw_data":{"id":"N3000-node1","created_by":"alextang","packages":[{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf08335.bin"},{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf23555.bin"},{"action":"add","image":"n3000-uk9.6.0.2.U1.1.CSCuf42365.bin"}],"location":"
> ftp://10.2.3.4","creation_time":"Thursday, October 3, 2013 2:39:00 PM PDT"}}
> at
> com.google.common.base.Preconditions.checkState(Preconditions.java:176)
> at
> org.jclouds.chef.config.ChefParserModule$DataBagItemAdapter.createJsonLiteralFromRawJson(ChefParserModule.java:182)
> at
> org.jclouds.chef.config.ChefParserModule$DataBagItemAdapter.createJsonLiteralFromRawJson(ChefParserModule.java:176)
> at
> org.jclouds.json.internal.NullHackJsonLiteralAdapter.read(NullHackJsonLiteralAdapter.java:44)
> at com.google.gson.Gson.fromJson(Gson.java:791)
> ... 12 more