Skip to content

Commit 6267be4

Browse files
author
Renier Morales
committed
Fix image template issues found while looking into #128
1 parent b902c51 commit 6267be4

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

CHANGELOG.textile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
*3.2.2*
2+
* Fix NoMethodError when getting the datacenters out of an ImageTemplate and the value was nil.
3+
* Fix NoMethodError when getting public and private images with a result limit of 1.
4+
15
*3.2.1*
2-
Fix a crashing issue where a Bare Metal server order tried to retrieve the hardware ordered before it has been provisioned.
6+
* Fix a crashing issue where a Bare Metal server order tried to retrieve the hardware ordered before it has been provisioned.
37

48
*3.2*
59
* Add password-based authentication with `SoftLayer::Client.with_password(username: '...', password: '...', ...)`.

lib/softlayer/ImageTemplate.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def tags=(tags_array)
7878
##
7979
# Returns the an array containing the datacenters where this image is available.
8080
def datacenters
81-
self['datacenters'].collect{ |datacenter_data| SoftLayer::Datacenter.datacenter_named(datacenter_data['name'])}
81+
Array(self['datacenters']).collect do |datacenter_data|
82+
SoftLayer::Datacenter.datacenter_named(datacenter_data['name'])
83+
end
8284
end
8385

8486
##
@@ -253,7 +255,7 @@ def self.find_private_templates(options_hash = {})
253255
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
254256
end
255257

256-
templates_data = account_service.getPrivateBlockDeviceTemplateGroups
258+
templates_data = Array(account_service.getPrivateBlockDeviceTemplateGroups)
257259
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
258260
end
259261

@@ -312,7 +314,9 @@ def self.find_public_templates(options_hash = {})
312314
template_service = template_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
313315
end
314316

315-
templates_data = template_service.getPublicImages
317+
# Ensure this is an array with Array(). SL won't return array if the result set is of just one
318+
# (like when the user specifies a limit of 1)
319+
templates_data = Array(template_service.getPublicImages)
316320
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
317321
end
318322

lib/softlayer/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
module SoftLayer
1313
# The version number (including major, minor, and bugfix numbers)
1414
# This should change in accordance with the concept of Semantic Versioning
15-
VERSION = "3.2.1" # version history in the CHANGELOG.textile file at the root of the source
15+
VERSION = "3.2.2" # version history in the CHANGELOG.textile file at the root of the source
1616

1717
# The base URL of the SoftLayer API available to the public internet.
1818
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3/'

0 commit comments

Comments
 (0)