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.
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  require "softlayer/ObjectMaskTokenizer"
24
8
  require "softlayer/ObjectMaskProperty"
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  #
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  #
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  require 'softlayer/ObjectMaskToken'
24
8
  require 'strscan'
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  # This struct represents a configuration option that can be included in
@@ -26,8 +10,7 @@ module SoftLayer
26
10
  # the product order is the price_id, the rest of the information is provided
27
11
  # to make the object friendly to humans who may be searching for the
28
12
  # meaning of a given price_id.
29
- ProductConfigurationOption = Struct.new(:price_id, :description, :capacity, :units, :setupFee, :laborFee, :oneTimeFee, :recurringFee, :hourlyRecurringFee) do
30
-
13
+ class ProductConfigurationOption < Struct.new(:price_id, :description, :capacity, :units, :setupFee, :laborFee, :oneTimeFee, :recurringFee, :hourlyRecurringFee)
31
14
  # Is it evil, or just incongruous to give methods to a struct?
32
15
 
33
16
  # returns true if the configurtion option has no fees associated with it.
@@ -48,13 +31,13 @@ module SoftLayer
48
31
  # service.
49
32
  class ProductItemCategory < ModelBase
50
33
  include ::SoftLayer::DynamicAttribute
51
-
34
+
52
35
  ##
53
36
  # :attr_reader:
54
37
  # The categoryCode is a primary identifier for a particular
55
38
  # category. It is a string like 'os' or 'ram'
56
39
  sl_attr :categoryCode
57
-
40
+
58
41
  ##
59
42
  # :attr_reader:
60
43
  # The name of a category is a friendly, readable string
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  require 'json'
24
8
 
@@ -59,7 +43,7 @@ module SoftLayer
59
43
 
60
44
  ##
61
45
  # The list of locations where this product package is available.
62
- sl_attr :availableLocations
46
+ sl_attr :available_locations, 'availableLocations'
63
47
 
64
48
  ##
65
49
  # The set of product categories needed to make an order for this product package.
@@ -119,15 +103,7 @@ module SoftLayer
119
103
  end
120
104
 
121
105
  def datacenter_options
122
- availableLocations.collect { |location_data| location_data["location"]["name"] }
123
- end
124
-
125
- ##
126
- # Given a datacenter name that was returned by datacenter_options, use information
127
- # in the package to retrieve a location id.
128
- def location_id_for_datacenter_name(datacenter_name)
129
- location_data = availableLocations.find { |location_data| location_data["location"]["name"] == datacenter_name }
130
- location_data["locationId"]
106
+ available_locations.collect { |location_data| Datacenter::datacenter_named(location_data["location"]["name"], self.softlayer_client) }.compact
131
107
  end
132
108
 
133
109
  def service
@@ -141,8 +117,11 @@ module SoftLayer
141
117
  def self.packages_with_key_name(key_name, client = nil)
142
118
  softlayer_client = client || Client.default_client
143
119
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
144
-
145
- filter = SoftLayer::ObjectFilter.build('type.keyName', key_name)
120
+
121
+ filter = SoftLayer::ObjectFilter.new do |filter|
122
+ filter.accept('type.keyName').when_it is(key_name)
123
+ end
124
+
146
125
  filtered_service = softlayer_client['Product_Package'].object_filter(filter).object_mask(self.default_object_mask('mask'))
147
126
  packages_data = filtered_service.getAllObjects
148
127
  packages_data.collect { |package_data| ProductPackage.new(softlayer_client, package_data) }
@@ -155,7 +134,7 @@ module SoftLayer
155
134
  def self.package_with_id(package_id, client = nil)
156
135
  softlayer_client = client || Client.default_client
157
136
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
158
-
137
+
159
138
  package_data = softlayer_client['Product_Package'].object_with_id(package_id).object_mask(self.default_object_mask('mask')).getObject
160
139
  ProductPackage.new(softlayer_client, package_data)
161
140
  end
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
  # Server is the base class for VirtualServer and BareMetalServer.
@@ -83,6 +67,25 @@ module SoftLayer
83
67
  end
84
68
  end
85
69
 
70
+ ##
71
+ # Reboot the server. This action is taken immediately.
72
+ # Servers can be rebooted in three different ways:
73
+ # :default_reboot - (Try soft, then hard) Attempts to reboot a server using the :os_reboot technique then, if that is not successful, tries the :power_cycle method
74
+ # :os_reboot - (aka. soft rebot) instructs the server's host operating system to reboot
75
+ # :power_cycle - (aka. hard reboot) The actual (for hardware) or metaphorical (for virtual servers) equivalent to pulling the plug on the server then plugging it back in.
76
+ def reboot!(reboot_technique = :default_reboot)
77
+ case reboot_technique
78
+ when :default_reboot
79
+ self.service.rebootDefault
80
+ when :os_reboot
81
+ self.service.rebootSoft
82
+ when :power_cycle
83
+ self.service.rebootHard
84
+ else
85
+ raise RuntimeError, "Unrecognized reboot technique in SoftLayer::Server#reboot!}"
86
+ end
87
+ end
88
+
86
89
  ##
87
90
  # Make an API request to SoftLayer and return the latest properties hash
88
91
  # for this object.
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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 Ticket < SoftLayer::ModelBase
@@ -32,10 +16,10 @@ module SoftLayer
32
16
  # :attr_reader:
33
17
  # The ticket system maintains a fixed set of subjects for tickets that are used to ensure tickets make it to the right folks quickly
34
18
  sl_attr :subject
35
-
19
+
36
20
  ##
37
21
  # :attr_reader:
38
- # The date the ticket was last updated.
22
+ # The date the ticket was last updated.
39
23
  sl_attr :lastEditDate
40
24
 
41
25
  ##
@@ -99,7 +83,7 @@ module SoftLayer
99
83
  'awaitingUserResponseFlag', # This comes in from the server as a Boolean value
100
84
  'serverAdministrationFlag', # This comes in from the server as an integer :-(
101
85
  ]
102
- }
86
+ }.to_sl_object_mask
103
87
  end
104
88
 
105
89
  ##
@@ -118,29 +102,6 @@ module SoftLayer
118
102
  @ticket_subjects
119
103
  end
120
104
 
121
- ##
122
- # Returns the set of currently open tickets
123
- #
124
- # Options should contain:
125
- #
126
- # <b>+:client+</b> - the client in which to search for the ticket
127
- #
128
- # If a client is not provided then the routine will search Client::default_client
129
- # If Client::default_client is also nil the routine will raise an error.
130
- def self.open_tickets(options = {})
131
- softlayer_client = options[:client] || Client.default_client
132
- raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
133
-
134
- if options.has_key?(:object_mask)
135
- object_mask = options[:object_mask]
136
- else
137
- object_mask = default_object_mask.to_sl_object_mask
138
- end
139
-
140
- open_tickets_data = softlayer_client["Account"].object_mask(object_mask).getOpenTickets
141
- open_tickets_data.collect { |ticket_data| new(softlayer_client, ticket_data) }
142
- end
143
-
144
105
  ##
145
106
  # Find the ticket with the given ID and return it
146
107
  #
@@ -1,26 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
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
- #
22
-
23
- require 'time'
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
24
6
 
25
7
  module SoftLayer
26
8
  ##
@@ -90,49 +72,6 @@ module SoftLayer
90
72
  self.service.deleteObject()
91
73
  end
92
74
 
93
- ##
94
- # This routine submits an order to upgrade the cpu count of the virtual server.
95
- # The order may result in additional charges being applied to SoftLayer account
96
- #
97
- # This routine can also "downgrade" servers (set their cpu count lower)
98
- #
99
- # The routine returns true if the order is placed and false if it is not
100
- #
101
- def upgrade_cores!(num_cores)
102
- upgrade_item_price = _item_price_in_category("guest_core", num_cores)
103
- _order_upgrade_item!(upgrade_item_price) if upgrade_item_price
104
- nil != upgrade_item_price
105
- end
106
-
107
- ##
108
- # This routine submits an order to change the RAM available to the virtual server.
109
- # Pass in the desired amount of RAM for the server in Gigabytes
110
- #
111
- # The order may result in additional charges being applied to SoftLayer account
112
- #
113
- # The routine returns true if the order is placed and false if it is not
114
- #
115
- def upgrade_RAM!(ram_in_GB)
116
- upgrade_item_price = _item_price_in_category("ram", ram_in_GB)
117
- _order_upgrade_item!(upgrade_item_price) if upgrade_item_price
118
- nil != upgrade_item_price
119
- end
120
-
121
- ##
122
- # This routine submits an order to change the maximum nic speed of the server
123
- # Pass in the desired speed in Megabits per second (typically 10, 100, or 1000)
124
- # (since you may choose a slower speed this routine can also be used for "downgrades")
125
- #
126
- # The order may result in additional charges being applied to SoftLayer account
127
- #
128
- # The routine returns true if the order is placed and false if it is not
129
- #
130
- def upgrade_max_port_speed!(network_speed_in_Mbps)
131
- upgrade_item_price = _item_price_in_category("port_speed", network_speed_in_Mbps)
132
- _order_upgrade_item!(upgrade_item_price) if upgrade_item_price
133
- nil != upgrade_item_price
134
- end
135
-
136
75
  ##
137
76
  # Capture a disk image of this virtual server for use with other servers.
138
77
  #
@@ -143,15 +82,21 @@ module SoftLayer
143
82
  #
144
83
  # The image_notes should be a string and will be added to the image as notes.
145
84
  #
146
- def capture_image(image_name, include_attached_storage = false, image_notes = '')
147
- image_notes = '' if !image_notes
148
-
85
+ # The routine returns the instance of SoftLayer::ImageTemplate that is
86
+ # created. That image template will probably not be available immediately, however.
87
+ # You may use the wait_until_ready routine of SoftLayer::ImageTemplate to
88
+ # wait on it.
89
+ #
90
+ def capture_image(image_name, include_attached_storage = false, image_notes = nil)
149
91
  disk_filter = lambda { |disk| disk['device'] == '0' }
150
92
  disk_filter = lambda { |disk| disk['device'] != '1' } if include_attached_storage
151
93
 
152
94
  disks = self.blockDevices.select(&disk_filter)
153
95
 
154
- self.service.createArchiveTransaction(image_name, disks, image_notes) if disks && !disks.empty?
96
+ self.service.createArchiveTransaction(image_name, disks, notes ? notes : "") if disks && !disks.empty?
97
+
98
+ image_templates = SoftLayer::ImageTemplate.find_private_templates(:name => image_name)
99
+ image_templates[0] if !image_templates.empty?
155
100
  end
156
101
 
157
102
  ##
@@ -260,10 +205,15 @@ module SoftLayer
260
205
  softlayer_client = options_hash[:client] || Client.default_client
261
206
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
262
207
 
263
- object_filter = {}
208
+ if(options_hash.has_key? :object_filter)
209
+ object_filter = options_hash[:object_filter]
210
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless object_filter.kind_of?(SoftLayer::ObjectFilter)
211
+ else
212
+ object_filter = ObjectFilter.new()
213
+ end
264
214
 
265
215
  option_to_filter_path = {
266
- :cpus => "virtualGuests.maxCpu",
216
+ :cores => "virtualGuests.maxCpu",
267
217
  :memory => "virtualGuests.maxMemory",
268
218
  :hostname => "virtualGuests.hostname",
269
219
  :domain => "virtualGuests.domain",
@@ -282,18 +232,18 @@ module SoftLayer
282
232
  # that particular option, add a clause to the object filter that filters for the matching
283
233
  # value
284
234
  option_to_filter_path.each do |option, filter_path|
285
- object_filter.merge!(SoftLayer::ObjectFilter.build(filter_path, options_hash[option])) if options_hash.has_key?(option)
235
+ object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option])} if options_hash[option]
286
236
  end
287
237
 
288
238
  # Tags get a much more complex object filter operation so we handle them separately
289
239
  if options_hash.has_key?(:tags)
290
- object_filter.merge!(SoftLayer::ObjectFilter.build("virtualGuests.tagReferences.tag.name", {
240
+ object_filter.set_criteria_for_key_path("virtualGuests.tagReferences.tag.name", {
291
241
  'operation' => 'in',
292
242
  'options' => [{
293
243
  'name' => 'data',
294
- 'value' => options_hash[:tags]
244
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
295
245
  }]
296
- } ));
246
+ } );
297
247
  end
298
248
 
299
249
  required_properties_mask = 'mask.id'
@@ -359,32 +309,5 @@ module SoftLayer
359
309
  def service
360
310
  return softlayer_client["Virtual_Guest"].object_with_id(self.id)
361
311
  end
362
-
363
- private
364
-
365
- ##
366
- # Searches through the upgrade items pricess known to this server for the one that is in a particular category
367
- # and whose capacity matches the value given. Returns the item_price or nil
368
- #
369
- def _item_price_in_category(which_category, capacity)
370
- item_prices_in_category = self.upgrade_options.select { |item_price| item_price["categories"].find { |category| category["categoryCode"] == which_category } }
371
- item_prices_in_category.find { |ram_item| ram_item["item"]["capacity"].to_i == capacity}
372
- end
373
-
374
- ##
375
- # Constructs an upgrade order to order the given item price.
376
- # The order is built to execute immediately
377
- #
378
- def _order_upgrade_item!(upgrade_item_price)
379
- # put together an order
380
- upgrade_order = {
381
- 'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade',
382
- 'virtualGuests' => [{'id' => self.id }],
383
- 'properties' => [{'name' => 'MAINTENANCE_WINDOW', 'value' => Time.now.iso8601}],
384
- 'prices' => [ upgrade_item_price ]
385
- }
386
-
387
- self.softlayer_client["Product_Order"].placeOrder(upgrade_order)
388
- end
389
312
  end #class VirtualServer
390
313
  end