softlayer_api 2.2.2 → 3.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.textile +9 -5
- data/examples/account_servers.rb +2 -2
- data/examples/create_ticket.rb +3 -3
- data/examples/open_tickets.rb +2 -2
- data/examples/ticket_info.rb +2 -2
- data/lib/softlayer/APIParameterFilter.rb +7 -21
- data/lib/softlayer/Account.rb +28 -19
- data/lib/softlayer/BareMetalServer.rb +13 -25
- data/lib/softlayer/BareMetalServerOrder.rb +6 -23
- data/lib/softlayer/BareMetalServerOrder_Package.rb +11 -29
- data/lib/softlayer/Client.rb +17 -23
- data/lib/softlayer/Config.rb +6 -22
- data/lib/softlayer/Datacenter.rb +53 -0
- data/lib/softlayer/DynamicAttribute.rb +3 -19
- data/lib/softlayer/ImageTemplate.rb +384 -0
- data/lib/softlayer/ModelBase.rb +4 -20
- data/lib/softlayer/ObjectFilter.rb +193 -191
- data/lib/softlayer/ObjectMaskParser.rb +3 -19
- data/lib/softlayer/ObjectMaskProperty.rb +3 -19
- data/lib/softlayer/ObjectMaskToken.rb +3 -19
- data/lib/softlayer/ObjectMaskTokenizer.rb +3 -19
- data/lib/softlayer/ProductItemCategory.rb +6 -23
- data/lib/softlayer/ProductPackage.rb +11 -32
- data/lib/softlayer/Server.rb +22 -19
- data/lib/softlayer/Ticket.rb +6 -45
- data/lib/softlayer/VirtualServer.rb +24 -101
- data/lib/softlayer/VirtualServerOrder.rb +14 -31
- data/lib/softlayer/VirtualServerUpgradeOrder.rb +142 -0
- data/lib/softlayer/base.rb +11 -30
- data/lib/softlayer/object_mask_helpers.rb +3 -19
- data/lib/softlayer_api.rb +12 -22
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f8d78ff1302ba4ee3970aa9b35ae5ad58de334a
|
4
|
+
data.tar.gz: 3a26cf514cefcf910e4edbadf810d63a1eea96fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c15a6526a4447e70fcf63433c443236666bebd15dfd8f96d18ace34ae00259e55633b0c38b2938c00e066265793617b276eae6c369a36f3db1ab666e89c66d1
|
7
|
+
data.tar.gz: 75f70052f5946914de71194f7db38ee2d3b6f7ee189c2b33e1bd944d5215c6ce6890e8cb6a653a2a074ef5be76528eb5c82bfe75bd57e58841b48b4076154eed
|
data/CHANGELOG.textile
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
*
|
2
|
-
*
|
1
|
+
*3.0*
|
2
|
+
* Substantially rewrote the ObjectFilter class. ObjectFilters used to be hashes which made it easy to manipulate their content incorrectly. The new implementation has a strict interface that makes it harder to manipulate filters incorrectly.
|
3
|
+
* Added a model for Virtual Server Image Templates (SoftLayer::ImageTemplate) - VirtualServerOrder now requires an instance of this class rather than allowing you to provide just the global_id of an image
|
4
|
+
* Added a model for data centers (SoftLayer::Datacenter). Bare Metal, Bare Metal Package, and Virtual server orders now use an instance of Datacenter to identify where their servers will be provisioned. The routines in those classes which used to provide lists of valid data center names now return data center objects.
|
5
|
+
* Virtual Server Upgrades are now handled by the VirtualServerUpgradeOrder class and not the VirtualServer class. This change was made for several reasons. Firt and foremost, it allows multiple aspects of a virtual server to be upgraded at once without having to wait on separate transactions to complete between upgrades. Secondly it opens the door for additional upgrades (for example, to disk configuration) to be added in the future.
|
6
|
+
* Added a method to reboot servers.
|
7
|
+
* The routine to retreive the open tickets on an account has been moved from the Ticket class. The set of open tickets is now a dynamic property of an account object.
|
3
8
|
|
4
9
|
*2.2*
|
5
|
-
* Added the ability to set a timout for network requests.
|
6
|
-
* Fixed a bug in VirtualServer#capture_image
|
10
|
+
* Added the ability to set a timout for network requests. The timeout is given when a client is created by passing the :timeout hash parameter when creating a client. The value of the parameter is an integer number of seconds.
|
7
11
|
|
8
12
|
*2.1.1*
|
9
13
|
* Virtual server upgrades no longer raise exceptions
|
10
|
-
* Formalized the RDoc documentation process.
|
14
|
+
* Formalized the RDoc documentation process. Added overview and welcome documentation and changed the README so it directs folks to the new documentation.
|
11
15
|
|
12
16
|
*2.1.0*
|
13
17
|
* Began implementing a model framework that allows Ruby developers to work with elements in the SoftLayer API in a more object-oriented fashion. The first release of this framework includes the Ticket, VirtualServer, and BareMetalServer classes.
|
data/examples/account_servers.rb
CHANGED
@@ -23,8 +23,8 @@
|
|
23
23
|
require 'rubygems'
|
24
24
|
require 'softlayer_api'
|
25
25
|
require 'pp'
|
26
|
-
|
27
|
-
# We can set the default client to be our client and that way
|
26
|
+
|
27
|
+
# We can set the default client to be our client and that way
|
28
28
|
# we can avoid supplying it later
|
29
29
|
SoftLayer::Client.default_client = SoftLayer::Client.new(
|
30
30
|
# :username => "joecustomer" # enter your username here
|
data/examples/create_ticket.rb
CHANGED
@@ -35,7 +35,7 @@ begin
|
|
35
35
|
account = SoftLayer::Account.account_for_client(softlayer_client)
|
36
36
|
account_user = account.service.getCurrentUser
|
37
37
|
my_user_id = account_user["id"]
|
38
|
-
|
38
|
+
|
39
39
|
# We also need a subject for the ticket. Subjects are specified by id
|
40
40
|
# This code prints out a table of all the ticket subjects with their
|
41
41
|
# ids:
|
@@ -43,7 +43,7 @@ begin
|
|
43
43
|
ticket_subjects.each do |subject|
|
44
44
|
puts "#{subject['id']}\t#{subject['name']}"
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
# For this example we'll use 'Public Network Question' as the subject. That's id 1022
|
48
48
|
public_network_question_id = 1022
|
49
49
|
|
@@ -58,7 +58,7 @@ begin
|
|
58
58
|
)
|
59
59
|
|
60
60
|
puts "Created a new ticket : #{new_ticket.id} - #{new_ticket.title}"
|
61
|
-
|
61
|
+
|
62
62
|
# we can also add an update to the ticket:
|
63
63
|
new_ticket.update("This is a ticket update sent from the Ruby library")
|
64
64
|
|
data/examples/open_tickets.rb
CHANGED
@@ -30,14 +30,14 @@ require 'pp'
|
|
30
30
|
# $SL_API_KEY = "feeddeadbeefbadf00d..." # enter your api key here
|
31
31
|
|
32
32
|
# The client constructed here must get it's credentials from somewhere
|
33
|
-
# In this script you might uncomment the globals above and assign your
|
33
|
+
# In this script you might uncomment the globals above and assign your
|
34
34
|
# credentials there
|
35
35
|
SoftLayer::Client.default_client = SoftLayer::Client.new()
|
36
36
|
|
37
37
|
# The openTickets routine will pick up the default client established above.
|
38
38
|
open_tickets = SoftLayer::Ticket.open_tickets()
|
39
39
|
|
40
|
-
open_tickets.sort!{ |lhs, rhs| -(lhs.lastEditDate <=> rhs.lastEditDate) }
|
40
|
+
open_tickets.sort!{ |lhs, rhs| -(lhs.lastEditDate <=> rhs.lastEditDate) }
|
41
41
|
open_tickets.each do |ticket|
|
42
42
|
printf "#{ticket.id} - #{ticket.title}"
|
43
43
|
|
data/examples/ticket_info.rb
CHANGED
@@ -34,13 +34,13 @@ begin
|
|
34
34
|
# at information. In this case we are talking directly to the ticket
|
35
35
|
# service
|
36
36
|
ticket_service = softlayer_client.service_named("Ticket");
|
37
|
-
|
37
|
+
|
38
38
|
# Retrive a particular ticket by ID (you will have to substitute an existing ticket's ID here)
|
39
39
|
ticket_ref = ticket_service.object_with_id(12345)
|
40
40
|
|
41
41
|
# Retrive very specific information about the ticket
|
42
42
|
ticket = ticket_ref.object_mask("mask[updates[entry,createDate],assignedUserId,attachedHardware.datacenter]").getObject
|
43
|
-
|
43
|
+
|
44
44
|
pp ticket
|
45
45
|
rescue Exception => exception
|
46
46
|
puts "Unable to retrieve the ticket #{exception}"
|
@@ -1,24 +1,10 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
6
|
+
|
7
|
+
|
22
8
|
|
23
9
|
module SoftLayer
|
24
10
|
# An +APIParameterFilter+ is an intermediary object that understands how
|
@@ -119,7 +105,7 @@ class APIParameterFilter
|
|
119
105
|
# to specify criteria which are used to filter the results returned
|
120
106
|
# by the server.
|
121
107
|
def object_filter(filter)
|
122
|
-
raise ArgumentError, "
|
108
|
+
raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)
|
123
109
|
|
124
110
|
# we create a new object in case the user wants to store off the
|
125
111
|
# filter chain and reuse it later
|
@@ -187,7 +173,7 @@ class APIParameterFilter
|
|
187
173
|
##
|
188
174
|
# A utility method that returns the object filter (if any) stored with this filter.
|
189
175
|
def server_object_filter
|
190
|
-
self.parameters[:object_filter]
|
176
|
+
self.parameters[:object_filter].to_h
|
191
177
|
end
|
192
178
|
|
193
179
|
##
|
data/lib/softlayer/Account.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
22
6
|
|
23
7
|
module SoftLayer
|
24
8
|
class Account < SoftLayer::ModelBase
|
@@ -113,6 +97,31 @@ module SoftLayer
|
|
113
97
|
end
|
114
98
|
end
|
115
99
|
|
100
|
+
sl_dynamic_attr :image_templates do |image_templates|
|
101
|
+
image_templates.should_update? do
|
102
|
+
@last_image_template_update ||= Time.at(0)
|
103
|
+
(Time.now - @last_image_template_update) > 5 * 60 # update every 5 minutes
|
104
|
+
end
|
105
|
+
|
106
|
+
image_templates.to_update do
|
107
|
+
@last_image_template_update ||= Time.now
|
108
|
+
ImageTemplate.find_private_templates(:client => self.softlayer_client)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
sl_dynamic_attr :open_tickets do |open_tickets|
|
113
|
+
open_tickets.should_update? do
|
114
|
+
@last_open_tickets_update ||= Time.at(0)
|
115
|
+
(Time.now - @last_open_tickets_update) > 5 * 60 # update every 5 minutes
|
116
|
+
end
|
117
|
+
|
118
|
+
open_tickets.to_update do
|
119
|
+
@last_open_tickets_update ||= Time.now
|
120
|
+
open_tickets_data = self.service.object_mask(SoftLayer::Ticket.default_object_mask).getOpenTickets
|
121
|
+
open_tickets_data.collect { |ticket_data| SoftLayer::Ticket.new(self.softlayer_client, ticket_data) }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
116
125
|
def service
|
117
126
|
softlayer_client["Account"].object_with_id(self.id)
|
118
127
|
end
|
@@ -1,24 +1,10 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
6
|
+
|
7
|
+
|
22
8
|
|
23
9
|
module SoftLayer
|
24
10
|
#
|
@@ -27,6 +13,7 @@ module SoftLayer
|
|
27
13
|
# +SoftLayer_Hardware_Server+ services in the SoftLayer API
|
28
14
|
#
|
29
15
|
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
|
16
|
+
#
|
30
17
|
# http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Server
|
31
18
|
#
|
32
19
|
class BareMetalServer < Server
|
@@ -51,7 +38,7 @@ module SoftLayer
|
|
51
38
|
# removed from the account).
|
52
39
|
#
|
53
40
|
# The +cancellation_reason+ parameter should be a key from the hash returned
|
54
|
-
# by
|
41
|
+
# by BareMetalServer::cancellation_reasons.
|
55
42
|
#
|
56
43
|
# You may add your own, more specific reasons for cancelling a server in the
|
57
44
|
# +comments+ parameter.
|
@@ -178,8 +165,9 @@ module SoftLayer
|
|
178
165
|
|
179
166
|
if(options_hash.has_key? :object_filter)
|
180
167
|
object_filter = options_hash[:object_filter]
|
168
|
+
raise "Expected an instance of SoftLayer::ObjectFilter" unless object_filter.kind_of?(SoftLayer::ObjectFilter)
|
181
169
|
else
|
182
|
-
object_filter =
|
170
|
+
object_filter = ObjectFilter.new()
|
183
171
|
end
|
184
172
|
|
185
173
|
option_to_filter_path = {
|
@@ -197,18 +185,18 @@ module SoftLayer
|
|
197
185
|
# that particular option, add a clause to the object filter that filters for the matching
|
198
186
|
# value
|
199
187
|
option_to_filter_path.each do |option, filter_path|
|
200
|
-
object_filter.
|
188
|
+
object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option])} if options_hash[option]
|
201
189
|
end
|
202
190
|
|
203
191
|
# Tags get a much more complex object filter operation so we handle them separately
|
204
192
|
if options_hash.has_key?(:tags)
|
205
|
-
object_filter.
|
193
|
+
object_filter.set_criteria_for_key_path("hardware.tagReferences.tag.name", {
|
206
194
|
'operation' => 'in',
|
207
195
|
'options' => [{
|
208
196
|
'name' => 'data',
|
209
|
-
'value' => options_hash[:tags]
|
197
|
+
'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
|
210
198
|
}]
|
211
|
-
} )
|
199
|
+
} );
|
212
200
|
end
|
213
201
|
|
214
202
|
account_service = softlayer_client['Account']
|
@@ -1,24 +1,8 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
22
6
|
|
23
7
|
module SoftLayer
|
24
8
|
#
|
@@ -46,8 +30,7 @@ module SoftLayer
|
|
46
30
|
# a Bare Metal Instance
|
47
31
|
#++
|
48
32
|
|
49
|
-
#
|
50
|
-
# Corresponds to +datacenter.name+ in the documentation for +createObject+.
|
33
|
+
# An instance of SoftLayer::Datacenter. The server will be provisioned in this data center
|
51
34
|
attr_accessor :datacenter
|
52
35
|
|
53
36
|
# String, The hostname to assign to the new server
|
@@ -166,7 +149,7 @@ module SoftLayer
|
|
166
149
|
|
167
150
|
template["privateNetworkOnlyFlag"] = true if @private_network_only
|
168
151
|
|
169
|
-
template["datacenter"] = {"name" => @datacenter} if @datacenter
|
152
|
+
template["datacenter"] = {"name" => @datacenter.name} if @datacenter
|
170
153
|
template['userData'] = [{'value' => @user_metadata}] if @user_metadata
|
171
154
|
template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
|
172
155
|
template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
|
@@ -198,7 +181,7 @@ module SoftLayer
|
|
198
181
|
##
|
199
182
|
# Return a list of values that are valid for the :datacenter attribute
|
200
183
|
def self.datacenter_options(client = nil)
|
201
|
-
create_object_options(client)["datacenters"].collect { |datacenter_spec| datacenter_spec['template']['datacenter'][
|
184
|
+
create_object_options(client)["datacenters"].collect { |datacenter_spec| Datacenter.datacenter_named(datacenter_spec['template']['datacenter']['name'], client) }.uniq
|
202
185
|
end
|
203
186
|
|
204
187
|
def self.core_options(client = nil)
|
@@ -1,24 +1,8 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
22
6
|
|
23
7
|
module SoftLayer
|
24
8
|
#
|
@@ -42,13 +26,14 @@ module SoftLayer
|
|
42
26
|
class BareMetalServerOrder_Package < Server
|
43
27
|
# The following properties are required in a server order.
|
44
28
|
|
45
|
-
# The product package
|
46
|
-
#
|
29
|
+
# The product package object (an instance of SoftLayer::ProductPackage) identifying the base
|
30
|
+
# configuration for the server. A list of Bare Metal Server product packages is returned by
|
47
31
|
# SoftLayer::ProductPackage.bare_metal_server_packages
|
48
32
|
attr_reader :package
|
49
33
|
|
50
|
-
#
|
51
|
-
#
|
34
|
+
# An instance of SoftLayer::Datacenter. The server will be provisioned in this data center.
|
35
|
+
# The set of datacenters available is determined by the package and may be obtained from
|
36
|
+
# the SoftLayer::ProductPackage object using the #datacenter_options method.
|
52
37
|
attr_accessor :datacenter
|
53
38
|
|
54
39
|
# The hostname of the server being created (i.e. 'sldn' is the hostname of sldn.softlayer.com).
|
@@ -133,14 +118,13 @@ module SoftLayer
|
|
133
118
|
product_order = {
|
134
119
|
'packageId' => @package.id,
|
135
120
|
'useHourlyPricing' => false,
|
136
|
-
'hardware' =>
|
121
|
+
'hardware' => {
|
137
122
|
'hostname' => @hostname,
|
138
123
|
'domain' => @domain
|
139
|
-
|
124
|
+
}
|
140
125
|
}
|
141
126
|
|
142
|
-
product_order['location'] = @
|
143
|
-
|
127
|
+
product_order['location'] = @datacenter.id if @datacenter
|
144
128
|
product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
|
145
129
|
product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
|
146
130
|
|
@@ -156,7 +140,5 @@ module SoftLayer
|
|
156
140
|
|
157
141
|
product_order
|
158
142
|
end
|
159
|
-
|
160
143
|
end # BareMetalServerOrder_Package
|
161
|
-
|
162
144
|
end # SoftLayer
|
data/lib/softlayer/Client.rb
CHANGED
@@ -1,31 +1,18 @@
|
|
1
|
-
|
1
|
+
#--
|
2
2
|
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
4
|
+
# For licensing information see the LICENSE.md file in the project root.
|
5
|
+
#++
|
22
6
|
|
23
7
|
module SoftLayer
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
8
|
+
# A client is responsible for storing authentication information for API calls and
|
9
|
+
# it serves as a centeral repository for the Service instances that call into the
|
10
|
+
# network API.
|
27
11
|
#
|
28
|
-
#
|
12
|
+
# When you create a client, you pass in hash arguments specifying how the client
|
13
|
+
# should access the SoftLayer API.
|
14
|
+
#
|
15
|
+
# The following symbols are the keys for options you pass to the constructor:
|
29
16
|
# - +:username+ - a non-empty string providing the username to use for requests to the client
|
30
17
|
# - +:api_key+ - a non-empty string providing the api key to use for requests to the client
|
31
18
|
# - +:endpoint_url+ - a non-empty string providing the endpoint URL to use for requests to the client
|
@@ -56,6 +43,13 @@ module SoftLayer
|
|
56
43
|
# will be used by many methods if you do not provide an explicit client.
|
57
44
|
@@default_client = nil
|
58
45
|
|
46
|
+
##
|
47
|
+
# :attr_accessor:
|
48
|
+
# The client class can maintain a single instance of Client as the "default client"
|
49
|
+
# Other parts of the library that accept a client as part of their calling sequence
|
50
|
+
# will look for the default client if one is not provided in the call
|
51
|
+
#
|
52
|
+
# This routine returns the client set as the default client. It can be nil
|
59
53
|
def self.default_client
|
60
54
|
return @@default_client
|
61
55
|
end
|