Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
deltacloud-core HEAD (ea5fda91da9f8c061c2c2fa0a267c84501c743fa)
json_pure-1.7.5
Description
I found strange problem with JSON parser under 1.9.3 MRI ruby when you try to create a new Machine.
Requirements:
~/code/core/server › rbenv versions
- 1.9.3-p194 (set by /home/mfojtik/code/core/server/.rbenv-version)
1.9.3-p286
How to reproduce:
1. Use 1.9.3p194, start Deltacloud API with CIMI frontend, then:
$ curl -v -X POST --user 'mockuser:mockpassword' -H 'Content-Type: application/json' -d @machine.json http://localhost:3001/cimi/machines
Results: Everything works perfectly, Machine is created and JSON is returned to console.
2. Use 1.9.3p286, start Deltacloud API with CIMI frontend, then:
$ curl -v -X POST --user 'mockuser:mockpassword' -H 'Content-Type: application/json' -d @machine.json http://localhost:3001/cimi/machines
Result:
E, 2012-11-28T11:48:55.665131 #11346 ERROR – 500: [TypeError] wrong argument type JSON::Pure::Generator::State (expected Data)
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:316:in `to_json'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:316:in `block in json_transform'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:309:in `each'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:309:in `json_transform'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:291:in `to_json'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:257:in `generate'
/home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/json/common.rb:216:in `generate'
/home/mfojtik/code/core/server/lib/cimi/models/base.rb:232:in `to_json'
/home/mfojtik/code/core/server/lib/cimi/models/base.rb:243:in `to_json'
/home/mfojtik/code/core/server/lib/cimi/collections/machines.rb:58:in `block (5 levels) in <class:Machines>'
The Machine objects looks like this:
#<CIMI::Model::Machine:0x000000044423f8 @attribute_values={:id=>"http://localhost:3001/cimi/machines/inst9", :name=>"myMachine1", :description=>"My very first machine", :created=>"2012-11-28T11:48:55+01:00", :property=>
{"foo"=>"bar", "life"=>"is life", "machine_image"=>"http://localhost:3001/cimi/machine_images/img1", "credential"=>"http://localhost:3001/cimi/credentials"}, :state=>"STARTED", :cpu=>"1", :memory=>1781760, :disks=>#<Class::DiskCollection:0x00000004441c28 @attribute_values={:id=>nil, :href=>"http://localhost:3001/cimi/machines/inst9/disks", :count=>nil, :disks=>[], :operations=>nil}>, :volumes=>#<Class::MachineVolumeCollection:0x000000044416d8 @attribute_values={:id=>nil, :href=>"http://localhost:3001/cimi/machines/inst9/volumes", :count=>nil, :machine_volumes=>[], :operations=>nil}>, :meters=>nil, :operations=>[{:href=>"http://localhost:3001/cimi/machines/inst9/restart", :rel=>"http://schemas.dmtf.org/cimi/1/action/restart"}, {:href=>"http://localhost:3001/cimi/machines/inst9/stop", :rel=>"http://schemas.dmtf.org/cimi/1/action/stop"}, {:href=>"http://localhost:3001/cimi/machine_images", :rel=>"http://schemas.dmtf.org/cimi/1/action/capture"}]}>
(nothing suspicious).
I think this is caused by something they added to p286, but I was unable to track the problem down.
NOTE: This bug is affecting *ALL* JSON output, not just create.
PS: The @machine.json file:
{
"resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate",
"name": "myMachine1",
"description": "My very first machine",
"properties":
,
"machineTemplate": {
"machineConfig":
,
"machineImage":
}
}