From: marios <mar...@redhat.com> https://issues.apache.org/jira/browse/DTACLOUD-448
Signed-off-by: marios <mar...@redhat.com> --- server/lib/cimi/models/address_template.rb | 6 +++--- server/lib/cimi/models/machine_template.rb | 6 +++--- server/lib/cimi/models/volume_configuration.rb | 6 +++--- server/lib/cimi/models/volume_template.rb | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/lib/cimi/models/address_template.rb b/server/lib/cimi/models/address_template.rb index d081567..eea4385 100644 --- a/server/lib/cimi/models/address_template.rb +++ b/server/lib/cimi/models/address_template.rb @@ -67,7 +67,7 @@ class CIMI::Model::AddressTemplate < CIMI::Model::Base :dns => json['dns'], :protocol => json['protocol'], :mask => json['mask'], - :ent_properties => json['properties'].to_json + :ent_properties => json['properties'] ? json['properties'].to_json : {} ) from_db(new_template, context) end @@ -85,7 +85,7 @@ class CIMI::Model::AddressTemplate < CIMI::Model::Base :dns => xml['dns'].first, :protocol => xml['protocol'].nil? ? nil : xml['protocol'].first, :mask => xml['mask'].first, - :ent_properties => JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) + :ent_properties => xml['property'] ? JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) : {} ) from_db(new_template, context) end @@ -108,7 +108,7 @@ class CIMI::Model::AddressTemplate < CIMI::Model::Base :dns => model.dns, :protocol => model.protocol, :mask => model.mask, - :property => JSON::parse(model.ent_properties), + :property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil), :operations => [ { :href => context.destroy_address_template_url(model.id), :rel => 'http://schemas.dmtf.org/cimi/1/action/delete' } ] diff --git a/server/lib/cimi/models/machine_template.rb b/server/lib/cimi/models/machine_template.rb index 32d2c13..5ba9b3e 100644 --- a/server/lib/cimi/models/machine_template.rb +++ b/server/lib/cimi/models/machine_template.rb @@ -59,7 +59,7 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base :description => json['description'], :machine_config => json['machineConfig']['href'], :machine_image => json['machineImage']['href'], - :ent_properties => json['properties'].to_json + :ent_properties => json['properties'] ? json['properties'].to_json : {} ) from_db(new_template, context) end @@ -71,7 +71,7 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base :description => xml['description'].first, :machine_config => xml['machineConfig'].first['href'], :machine_image => xml['machineImage'].first['href'], - :ent_properties => JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) + :ent_properties => xml['property'] ? JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) : {} ) from_db(new_template, context) end @@ -89,7 +89,7 @@ class CIMI::Model::MachineTemplate < CIMI::Model::Base :description => model.description, :machine_config => { :href => model.machine_config }, :machine_image => { :href => model.machine_image }, - :property => JSON::parse(model.ent_properties), + :property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil), :created => Time.parse(model.created_at.to_s).xmlschema, :operations => [ { :href => context.destroy_machine_template_url(model.id), :rel => 'http://schemas.dmtf.org/cimi/1/action/delete' } diff --git a/server/lib/cimi/models/volume_configuration.rb b/server/lib/cimi/models/volume_configuration.rb index 9f15635..031ec44 100644 --- a/server/lib/cimi/models/volume_configuration.rb +++ b/server/lib/cimi/models/volume_configuration.rb @@ -32,7 +32,7 @@ class CIMI::Model::VolumeConfiguration < CIMI::Model::Base :description => json['description'], :format => json['format'], :capacity => json['capacity'], - :ent_properties => json['properties'].to_json + :ent_properties => json['properties'] ? json['properties'].to_json : {} ) from_db(new_config, context) end @@ -45,7 +45,7 @@ class CIMI::Model::VolumeConfiguration < CIMI::Model::Base :description => xml['description'].first, :format => xml['format'].first, :capacity => xml['capacity'].first, - :ent_properties => JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) + :ent_properties => xml['property'] ? JSON::dump(xml['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) : {} ) from_db(new_config, context) end @@ -81,7 +81,7 @@ class CIMI::Model::VolumeConfiguration < CIMI::Model::Base :description => model.description, :format => model.format, :capacity => context.to_kibibyte(model.capacity, "GB"), - :property => JSON::parse(model.ent_properties), + :property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil), :operations => [ { :href => context.destroy_volume_configuration_url(model.id), :rel => 'http://schemas.dmtf.org/cimi/1/action/delete' } ] diff --git a/server/lib/cimi/models/volume_template.rb b/server/lib/cimi/models/volume_template.rb index 3a98128..41d8b92 100644 --- a/server/lib/cimi/models/volume_template.rb +++ b/server/lib/cimi/models/volume_template.rb @@ -56,7 +56,7 @@ class CIMI::Model::VolumeTemplate < CIMI::Model::Base :description => input['description'], :volume_config => input['volumeConfig']['href'], :volume_image => vol_image, - :ent_properties => JSON::dump(input['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) + :ent_properties => input['property'] ? JSON::dump(input['property'].inject({}) { |r, p| r[p['key']]=p['content']; r }) : {} ) from_db(new_template, context) end @@ -74,7 +74,7 @@ private :description => model.description, :volume_config => {:href => model.volume_config}, :volume_image => {:href => model.volume_image}, - :property => JSON::parse(model.ent_properties), + :property => (model.ent_properties ? JSON::parse(model.ent_properties) : nil), :operations => [ { :href => context.destroy_volume_template_url(model.id), :rel => 'http://schemas.dmtf.org/cimi/1/action/delete' } ] -- 1.7.9.5