Skip to content

Commit

Permalink
Do not send blank attributes through API
Browse files Browse the repository at this point in the history
In Liberty API, sending nil values is not supported anymore.
Fixes for this are being done, but not everywhere. So we should
not send any parameter that was not specified.
  • Loading branch information
Ladas committed Apr 19, 2016
1 parent 24bb249 commit 13bfc96
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/fog/openstack/requests/compute/create_server.rb
Expand Up @@ -6,10 +6,10 @@ def create_server(name, image_ref, flavor_ref, options = {})
data = {
'server' => {
'flavorRef' => flavor_ref,
'imageRef' => image_ref,
'name' => name
}
}
data['server']['imageRef'] = image_ref if image_ref

vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
'availability_zone', 'user_data', 'key_name',
Expand Down Expand Up @@ -59,15 +59,12 @@ def create_server(name, image_ref, flavor_ref, options = {})

if (block_device_mapping = options['block_device_mapping_v2'])
data['server']['block_device_mapping_v2'] = [block_device_mapping].flatten.collect do |mapping|
{
'boot_index' => mapping[:boot_index],
'delete_on_termination' => mapping[:delete_on_termination],
'destination_type' => mapping[:destination_type],
'device_name' => mapping[:device_name],
'source_type' => mapping[:source_type],
'uuid' => mapping[:uuid],
'volume_size' => mapping[:volume_size],
}
entered_block_device_mapping = {}
[:boot_index, :delete_on_termination, :destination_type, :device_name, :source_type, :uuid,
:volume_size].each do |index|
entered_block_device_mapping[index.to_s] = mapping[index] if mapping.key?(index)
end
entered_block_device_mapping
end
elsif (block_device_mapping = options['block_device_mapping'])
data['server']['block_device_mapping'] = [block_device_mapping].flatten.collect do |mapping|
Expand Down

0 comments on commit 13bfc96

Please sign in to comment.