softlayer_api 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.textile +5 -1
- data/examples/order_bare_metal_package.rb +25 -19
- data/lib/softlayer/ImageTemplate.rb +7 -3
- data/lib/softlayer/ProductPackage.rb +2 -2
- data/lib/softlayer/Service.rb +3 -1
- data/lib/softlayer/VirtualDiskImage.rb +29 -0
- data/lib/softlayer/base.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f92616fa3f3d7892a380e75a600df3c4b0e6d1f
|
4
|
+
data.tar.gz: cf11685a6754bc2ac4b1386008ba3953b6bda16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70eb92b41aef54b2aa555bff34e071945110d2cd2a0f703f2662fa0546b0ed22cd0e66ae74ece48950e5d843bf4971647d6fb8fc7803174e830ede67644077db
|
7
|
+
data.tar.gz: 5a336a63bdd8504e858e32cc8f6a2512abdc483b82a0c9f580f9820c0978b39f8c8fe73371075ff4ae534a60fc067d531dec6b21fefb5115382bf6edee2f67aa
|
data/CHANGELOG.textile
CHANGED
@@ -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
|
+
|
1
5
|
*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.
|
3
7
|
|
4
8
|
*3.2*
|
5
9
|
* Add password-based authentication with `SoftLayer::Client.with_password(username: '...', password: '...', ...)`.
|
@@ -37,24 +37,26 @@ require 'pp'
|
|
37
37
|
# a server.
|
38
38
|
def tl_dr_version
|
39
39
|
client = SoftLayer::Client.new(
|
40
|
-
# :username => "joecustomer"
|
40
|
+
# :username => "joecustomer", # enter your username here
|
41
41
|
# :api_key => "feeddeadbeefbadf00d..." # enter your api key here
|
42
42
|
)
|
43
43
|
|
44
44
|
# Select a package
|
45
|
-
|
45
|
+
product_package = SoftLayer::ProductPackage.package_with_id(251, client)
|
46
46
|
|
47
47
|
# Find required Categories and fill config_options with defaults
|
48
48
|
config_options = {}
|
49
|
-
required_categories =
|
49
|
+
required_categories = product_package.configuration.select { |category| category.required? }
|
50
50
|
required_categories.each { |required_category| config_options[required_category.categoryCode] = required_category.default_option }
|
51
51
|
|
52
|
-
# Provide a value for missing config categories
|
53
|
-
config_options['server'] =
|
52
|
+
# Provide a value for missing config categories as they don't have defaults
|
53
|
+
config_options['server'] = 50691 # Dual Intel Xeon E5-2620 v3 (12 Cores, 2.40 GHz)
|
54
|
+
config_options['ram'] = 49427 # 64 GB RAM
|
55
|
+
config_options['disk0'] = 49811 # 1.00 TB SATA
|
54
56
|
|
55
57
|
# With all the config options in place we can now construct the product order.
|
56
|
-
server_order = SoftLayer::BareMetalServerOrder_Package.new(
|
57
|
-
server_order.
|
58
|
+
server_order = SoftLayer::BareMetalServerOrder_Package.new(product_package, client)
|
59
|
+
server_order.datacenter = SoftLayer::Datacenter.datacenter_named 'sng01', client
|
58
60
|
server_order.hostname = 'sample'
|
59
61
|
server_order.domain = 'softlayerapi.org'
|
60
62
|
server_order.configuration_options = config_options
|
@@ -69,7 +71,7 @@ end
|
|
69
71
|
|
70
72
|
begin
|
71
73
|
client = SoftLayer::Client.new(
|
72
|
-
# :username => "joecustomer"
|
74
|
+
# :username => "joecustomer", # enter your username here
|
73
75
|
# :api_key => "feeddeadbeefbadf00d..." # enter your api key here
|
74
76
|
)
|
75
77
|
|
@@ -80,14 +82,14 @@ begin
|
|
80
82
|
packages.each { |package| puts "#{package.id}\t#{package.name}"}
|
81
83
|
|
82
84
|
# For this example, we'll assume that we've selected the a package
|
83
|
-
# with an id of
|
84
|
-
|
85
|
+
# with an id of 251 representing a "Dual E5-2600 v3 Series (12 Drives)"
|
86
|
+
product_package = SoftLayer::ProductPackage.package_with_id(251, client)
|
85
87
|
|
86
88
|
# Now we need to now what ProductItemCategories are required to
|
87
89
|
# configure a server in that package. This code prints out a table
|
88
90
|
# of the required category codes with a description of each
|
89
|
-
puts "\nRequired Categories for '#{
|
90
|
-
required_categories =
|
91
|
+
puts "\nRequired Categories for '#{product_package.name}':"
|
92
|
+
required_categories = product_package.configuration.select { |category| category.required? }
|
91
93
|
max_code_length = required_categories.inject(0) { |max_code_length, category| [category.categoryCode.length, max_code_length].max }
|
92
94
|
printf "%#{max_code_length}s\tCategory Description\n", "Category Code"
|
93
95
|
printf "%#{max_code_length}s\t--------------------\n", "-------------"
|
@@ -96,7 +98,7 @@ begin
|
|
96
98
|
# We will need to provide values for each of the required category codes in our
|
97
99
|
# configuration_options. Let's see what configuration options are available for
|
98
100
|
# just one of the categories... Say 'os'
|
99
|
-
os_category =
|
101
|
+
os_category = product_package.category('os')
|
100
102
|
config_options = os_category.configuration_options
|
101
103
|
puts "\nConfiguration options in the 'os' category:"
|
102
104
|
config_options.each { |option| printf "%5s\t#{option.description}\n", option.price_id }
|
@@ -119,20 +121,25 @@ begin
|
|
119
121
|
# Regardless of the default values... we know we want the os selection we discovered above:
|
120
122
|
config_options['os'] = os_config_option
|
121
123
|
|
124
|
+
# Provide a value for missing config categories as they don't have defaults
|
125
|
+
config_options['server'] = 50691 # Dual Intel Xeon E5-2620 v3 (12 Cores, 2.40 GHz)
|
126
|
+
config_options['ram'] = 49427 # 64 GB RAM
|
127
|
+
config_options['disk0'] = 49811 # 1.00 TB SATA
|
128
|
+
|
122
129
|
# And we can customize the default config by providing selections for any config categories
|
123
130
|
# we are interested in
|
124
131
|
config_options.merge! ({
|
125
|
-
'
|
126
|
-
'
|
132
|
+
'port_speed' => 37220, # 1 Gbps Public & Private Network Uplinks (Unbonded)
|
133
|
+
'bandwidth' => 50233 # 1000 GB Bandwidth
|
127
134
|
})
|
128
135
|
|
129
136
|
# We have a configuration for the server, we also need a location for the new server.
|
130
137
|
# The package can give us a list of locations. Let's print out that list
|
131
|
-
puts "\nData Centers for '#{
|
132
|
-
|
138
|
+
puts "\nData Centers for '#{product_package.name}':"
|
139
|
+
product_package.datacenter_options.each { |datacenter| puts "\t#{datacenter.name}"}
|
133
140
|
|
134
141
|
# With all the config options in place we can now construct the product order.
|
135
|
-
server_order = SoftLayer::BareMetalServerOrder_Package.new(
|
142
|
+
server_order = SoftLayer::BareMetalServerOrder_Package.new(product_package, client)
|
136
143
|
server_order.datacenter = SoftLayer::Datacenter.datacenter_named 'sng01', client
|
137
144
|
server_order.hostname = 'sample'
|
138
145
|
server_order.domain = 'softlayerapi.org'
|
@@ -151,4 +158,3 @@ begin
|
|
151
158
|
rescue Exception => exception
|
152
159
|
$stderr.puts "An exception occurred while trying to complete the SoftLayer API calls #{exception}"
|
153
160
|
end
|
154
|
-
|
@@ -78,7 +78,9 @@ module SoftLayer
|
|
78
78
|
##
|
79
79
|
# Returns the an array containing the datacenters where this image is available.
|
80
80
|
def datacenters
|
81
|
-
self['datacenters'].collect
|
81
|
+
Array(self['datacenters']).collect do |datacenter_data|
|
82
|
+
SoftLayer::Datacenter.datacenter_named(datacenter_data['name'])
|
83
|
+
end
|
82
84
|
end
|
83
85
|
|
84
86
|
##
|
@@ -253,7 +255,7 @@ module SoftLayer
|
|
253
255
|
account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
|
254
256
|
end
|
255
257
|
|
256
|
-
templates_data = account_service.getPrivateBlockDeviceTemplateGroups
|
258
|
+
templates_data = Array(account_service.getPrivateBlockDeviceTemplateGroups)
|
257
259
|
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
|
258
260
|
end
|
259
261
|
|
@@ -312,7 +314,9 @@ module SoftLayer
|
|
312
314
|
template_service = template_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
|
313
315
|
end
|
314
316
|
|
315
|
-
|
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)
|
316
320
|
templates_data.collect { |template_data| ImageTemplate.new(softlayer_client, template_data) }
|
317
321
|
end
|
318
322
|
|
@@ -45,7 +45,7 @@ module SoftLayer
|
|
45
45
|
##
|
46
46
|
# :attr_reader: available_locations
|
47
47
|
# The list of locations where this product package is available.
|
48
|
-
sl_attr :available_locations, '
|
48
|
+
sl_attr :available_locations, 'regions'
|
49
49
|
|
50
50
|
##
|
51
51
|
# Retrieve the set of product categories needed to make an order for this product package.
|
@@ -230,7 +230,7 @@ module SoftLayer
|
|
230
230
|
"groups.prices.requiredCoreCount" ].join(",") + "]"
|
231
231
|
|
232
232
|
def self.default_object_mask(root)
|
233
|
-
"#{root}[id,name,description,
|
233
|
+
"#{root}[id,name,description,regions]"
|
234
234
|
end
|
235
235
|
end
|
236
236
|
end # SoftLayer
|
data/lib/softlayer/Service.rb
CHANGED
@@ -14,9 +14,11 @@ ensure
|
|
14
14
|
$VERBOSE = old_verbose
|
15
15
|
end
|
16
16
|
|
17
|
-
# enable parsing of "nil" values in structures returned from the API
|
18
17
|
with_warnings(nil) {
|
18
|
+
# enable parsing of "nil" values in structures returned from the API
|
19
19
|
XMLRPC::Config.const_set('ENABLE_NIL_PARSER', true)
|
20
|
+
# enable serialization of "nil" values in structures sent to the API
|
21
|
+
XMLRPC::Config.const_set('ENABLE_NIL_CREATE', true)
|
20
22
|
}
|
21
23
|
|
22
24
|
# The XML-RPC spec calls for the "faultCode" in faults to be an integer
|
@@ -188,6 +188,35 @@ module SoftLayer
|
|
188
188
|
softlayer_client[:Virtual_Disk_Image].object_with_id(self.id)
|
189
189
|
end
|
190
190
|
|
191
|
+
##
|
192
|
+
# Retrieve the virtual disk image with the given image ID from the API
|
193
|
+
#
|
194
|
+
# The options parameter should contain:
|
195
|
+
#
|
196
|
+
# <b>+:client+</b> - The client used to connect to the API
|
197
|
+
#
|
198
|
+
# If no client is given, then the routine will try to use Client.default_client
|
199
|
+
# If no client can be found the routine will raise an error.
|
200
|
+
#
|
201
|
+
# The options may include the following keys
|
202
|
+
# * <b>+:object_mask+</b> (string) - A object mask of properties, in addition to the default properties, that you wish to retrieve for the image
|
203
|
+
#
|
204
|
+
def self.image_with_id(image_id, options = {})
|
205
|
+
softlayer_client = options[:client] || Client.default_client
|
206
|
+
raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
|
207
|
+
|
208
|
+
vdi_service = softlayer_client[:Virtual_Disk_Image]
|
209
|
+
vdi_service = vdi_service.object_mask(default_object_mask.to_sl_object_mask)
|
210
|
+
|
211
|
+
if options.has_key?(:object_mask)
|
212
|
+
vdi_service = vdi_service.object_mask(options[:object_mask])
|
213
|
+
end
|
214
|
+
|
215
|
+
image_data = vdi_service.object_with_id(image_id).getObject()
|
216
|
+
|
217
|
+
return VirtualDiskImage.new(softlayer_client, image_data)
|
218
|
+
end
|
219
|
+
|
191
220
|
protected
|
192
221
|
|
193
222
|
def self.default_object_mask
|
data/lib/softlayer/base.rb
CHANGED
@@ -12,7 +12,7 @@ require 'rubygems'
|
|
12
12
|
module SoftLayer
|
13
13
|
# The version number (including major, minor, and bugfix numbers)
|
14
14
|
# This should change in accordance with the concept of Semantic Versioning
|
15
|
-
VERSION = "3.2.
|
15
|
+
VERSION = "3.2.2" # version history in the CHANGELOG.textile file at the root of the source
|
16
16
|
|
17
17
|
# The base URL of the SoftLayer API available to the public internet.
|
18
18
|
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3/'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softlayer_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SoftLayer Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configparser
|
@@ -86,20 +86,34 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 1.8.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: mime-types
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 2.99.3
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.99.3
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: coveralls
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- -
|
107
|
+
- - '='
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
109
|
+
version: 0.7.2
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
|
-
- -
|
114
|
+
- - '='
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
116
|
+
version: 0.7.2
|
103
117
|
description: The softlayer_api gem offers a convenient mechanism for invoking the
|
104
118
|
services of the SoftLayer API from Ruby.
|
105
119
|
email: sldn@softlayer.com
|
@@ -183,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
197
|
version: '0'
|
184
198
|
requirements: []
|
185
199
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.6.12
|
187
201
|
signing_key:
|
188
202
|
specification_version: 4
|
189
203
|
summary: Library for accessing the SoftLayer API
|