softlayer_api 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.textile +3 -0
  3. data/lib/softlayer/Account.rb +85 -8
  4. data/lib/softlayer/AccountPassword.rb +49 -49
  5. data/lib/softlayer/BareMetalServer.rb +33 -43
  6. data/lib/softlayer/BareMetalServerOrder.rb +17 -8
  7. data/lib/softlayer/BareMetalServerOrder_Package.rb +25 -7
  8. data/lib/softlayer/Client.rb +7 -7
  9. data/lib/softlayer/Config.rb +105 -49
  10. data/lib/softlayer/Datacenter.rb +10 -2
  11. data/lib/softlayer/DynamicAttribute.rb +1 -1
  12. data/lib/softlayer/ImageTemplate.rb +44 -61
  13. data/lib/softlayer/ModelBase.rb +2 -2
  14. data/lib/softlayer/NetworkComponent.rb +25 -3
  15. data/lib/softlayer/NetworkMessageDelivery.rb +25 -5
  16. data/lib/softlayer/NetworkMonitor.rb +333 -0
  17. data/lib/softlayer/NetworkService.rb +6 -4
  18. data/lib/softlayer/NetworkStorage.rb +42 -29
  19. data/lib/softlayer/NetworkStorageAllowedHost.rb +9 -3
  20. data/lib/softlayer/NetworkStorageCredential.rb +44 -29
  21. data/lib/softlayer/NetworkStorageGroup.rb +42 -10
  22. data/lib/softlayer/ObjectFilter.rb +54 -4
  23. data/lib/softlayer/ObjectMaskParser.rb +1 -1
  24. data/lib/softlayer/ProductItemCategory.rb +34 -5
  25. data/lib/softlayer/ProductPackage.rb +11 -7
  26. data/lib/softlayer/Server.rb +77 -5
  27. data/lib/softlayer/ServerFirewall.rb +12 -11
  28. data/lib/softlayer/Service.rb +1 -1
  29. data/lib/softlayer/Software.rb +35 -50
  30. data/lib/softlayer/SoftwarePassword.rb +92 -107
  31. data/lib/softlayer/Ticket.rb +37 -28
  32. data/lib/softlayer/UserCustomer.rb +56 -13
  33. data/lib/softlayer/UserCustomerExternalBinding.rb +18 -5
  34. data/lib/softlayer/VLANFirewall.rb +40 -9
  35. data/lib/softlayer/VLANFirewallOrder.rb +1 -1
  36. data/lib/softlayer/VirtualDiskImage.rb +38 -10
  37. data/lib/softlayer/VirtualServer.rb +75 -48
  38. data/lib/softlayer/VirtualServerOrder.rb +15 -8
  39. data/lib/softlayer/VirtualServerOrder_Package.rb +25 -7
  40. data/lib/softlayer/VirtualServerUpgradeOrder.rb +1 -1
  41. data/lib/softlayer/base.rb +1 -1
  42. data/lib/softlayer/object_mask_helpers.rb +1 -1
  43. data/lib/softlayer_api.rb +2 -0
  44. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db7fb619e9abee8aa3716ef5cc5e88b29ee86232
4
- data.tar.gz: a4544cc335c39b45149616d1e725b65bb1115484
3
+ metadata.gz: 21403d80bc5530202d1f40ceda6e67404de66717
4
+ data.tar.gz: 8879bb889d5418a4a3f2853d754565e794e3ab41
5
5
  SHA512:
6
- metadata.gz: a9919fb7d7cd6f2a4a7b071970212257d2364821be75d96cf3c56ab3806d65f0f28438b892ffd85503d41be10cd53e7c71f21bb38b08f2fbaa4c0a10df28c785
7
- data.tar.gz: ad1fdd2a7317e8d87c6285a0a95a77906a70ed8f1382fd29862af9f27256613d30462ef8c5dff45ac601fd0faea8b78ee353327b6367bf2a7c9e865531ff9b82
6
+ metadata.gz: 584069e9c12b5922e1d7fae1c0004f1deb3f0435401cac9e7bbafd0bb713b7868eeea37c6dcc560a15dc8fb2dca9001d654464cd05bb263d4f181b8d52c1a535
7
+ data.tar.gz: fe1a472fa84d6e23468ef538a0653623ef37c2a501f5a179b4cf17144aa12288c52e81b3f492d0f354360cec31516536826fd024e01645e38c950e8c56461b2d
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,6 @@
1
+ *3.1.0*
2
+ * Many SoftLayer Attributes are now shadowed with snake_case names. The old CamelCase versions are deprecated and will be removed in the next major release
3
+ * New functionality related to network monitoring has been added
1
4
  *3.0*
2
5
  * 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
6
  * Added a model for Virtual Server Image Templates (SoftLayer::ImageTemplate) - VirtualServerOrder now requires an instance of this class rather than allowing you to provide the global_id of an image
@@ -8,19 +8,43 @@ module SoftLayer
8
8
  class Account < SoftLayer::ModelBase
9
9
  include ::SoftLayer::DynamicAttribute
10
10
 
11
+ ##
12
+ # :attr_reader: company_name
13
+ # The company name of the primary contact
14
+ sl_attr :company_name, 'companyName'
15
+
11
16
  ##
12
17
  # :attr_reader:
13
18
  # The company name of the primary contact
19
+ #
20
+ # DEPRECATION WARNING: This attribute is deprecated in favor of company_name
21
+ # and will be removed in the next major release.
14
22
  sl_attr :companyName
15
23
 
24
+ ##
25
+ # :attr_reader: first_name
26
+ # The given name name of the primary contact
27
+ sl_attr :first_name, 'firstName'
28
+
16
29
  ##
17
30
  # :attr_reader:
18
31
  # The given name name of the primary contact
32
+ #
33
+ # DEPRECATION WARNING: This attribute is deprecated in favor of first_name
34
+ # and will be removed in the next major release.
19
35
  sl_attr :firstName
20
36
 
37
+ ##
38
+ # :attr_reader: last_name
39
+ # The surname of the primary contact
40
+ sl_attr :last_name, 'lastName'
41
+
21
42
  ##
22
43
  # :attr_reader:
23
44
  # The surname of the primary contact
45
+ #
46
+ # DEPRECATION WARNING: This attribute is deprecated in favor of last_name
47
+ # and will be removed in the next major release.
24
48
  sl_attr :lastName
25
49
 
26
50
  ##
@@ -51,18 +75,34 @@ module SoftLayer
51
75
  # The country stored as part of the primary contact's address
52
76
  sl_attr :country
53
77
 
78
+ ##
79
+ # :attr_reader: postal_code
80
+ # The postal code (in the US, aka. zip code) of the primary contact's address
81
+ sl_attr :postal_code, 'postalCode'
82
+
54
83
  ##
55
84
  # :attr_reader:
56
85
  # The postal code (in the US, aka. zip code) of the primary contact's address
86
+ #
87
+ # DEPRECATION WARNING: This attribute is deprecated in favor of postal_code
88
+ # and will be removed in the next major release.
57
89
  sl_attr :postalCode
58
90
 
91
+ ##
92
+ # :attr_reader: office_phone
93
+ # The office phone number listed for the primary contact
94
+ sl_attr :office_phone, 'officePhone'
95
+
59
96
  ##
60
97
  # :attr_reader:
61
- # The office phone nubmer listed for the primary contact
98
+ # The office phone number listed for the primary contact
99
+ #
100
+ # DEPRECATION WARNING: This attribute is deprecated in favor of office_phone
101
+ # and will be removed in the next major release.
62
102
  sl_attr :officePhone
63
103
 
64
104
  ##
65
- # The Bare Metal Servers (physical hardware) associated with the
105
+ # Retrieve the Bare Metal Servers (physical hardware) associated with the
66
106
  # account. Unless you force these to update, they will be refreshed every
67
107
  # five minutes.
68
108
  # :call-seq:
@@ -82,6 +122,8 @@ module SoftLayer
82
122
  ##
83
123
  # Retrieve an account's master EVault user. This is only used when an account
84
124
  # has an EVault service.
125
+ # :call-seq:
126
+ # evault_master_users(force_update=false)
85
127
  sl_dynamic_attr :evault_master_users do |evault_users|
86
128
  evault_users.should_update? do
87
129
  @evault_master_users == nil
@@ -94,7 +136,10 @@ module SoftLayer
94
136
  end
95
137
 
96
138
  ##
97
- # Retrieve an account's image templates
139
+ # Retrieve an account's image templates. Unless you force
140
+ # these to update, they will be refreshed every five minutes
141
+ # :call-seq:
142
+ # image_templates(force_update=false)
98
143
  sl_dynamic_attr :image_templates do |image_templates|
99
144
  image_templates.should_update? do
100
145
  @last_image_template_update ||= Time.at(0)
@@ -108,7 +153,9 @@ module SoftLayer
108
153
  end
109
154
 
110
155
  ##
111
- # Retrieve an account's network message delivery acounts.
156
+ # Retrieve an account's network message delivery accounts.
157
+ # :call-seq:
158
+ # network_message_delivery_accounts(force_update=false)
112
159
  sl_dynamic_attr :network_message_delivery_accounts do |net_msg_deliv_accts|
113
160
  net_msg_deliv_accts.should_update? do
114
161
  @network_message_delivery_accounts == nil
@@ -122,6 +169,8 @@ module SoftLayer
122
169
 
123
170
  ##
124
171
  # Retrieve an account's network storage groups.
172
+ # :call-seq:
173
+ # network_storage_groups(force_update=false)
125
174
  sl_dynamic_attr :network_storage_groups do |net_stor_groups|
126
175
  net_stor_groups.should_update? do
127
176
  @network_storage_groups == nil
@@ -134,7 +183,10 @@ module SoftLayer
134
183
  end
135
184
 
136
185
  ##
137
- # Retrieve an account's open tickets
186
+ # Retrieve an account's open tickets. Unless you force these
187
+ # to update, they will be refreshed every five minutes
188
+ # :call-seq:
189
+ # open_tickets(force_update=false)
138
190
  sl_dynamic_attr :open_tickets do |open_tickets|
139
191
  open_tickets.should_update? do
140
192
  @last_open_tickets_update ||= Time.at(0)
@@ -150,6 +202,8 @@ module SoftLayer
150
202
 
151
203
  ##
152
204
  # Retrieve an account's portal users.
205
+ # :call-seq:
206
+ # users(force_update=false)
153
207
  sl_dynamic_attr :users do |users|
154
208
  users.should_update? do
155
209
  @users == nil
@@ -162,7 +216,10 @@ module SoftLayer
162
216
  end
163
217
 
164
218
  ##
165
- # Retrieve an account's virtual disk images
219
+ # Retrieve an account's virtual disk images. Unless you force
220
+ # these to update, they will be refreshed every five minutes
221
+ # :call-seq:
222
+ # virtual_disk_images(force_update=false)
166
223
  sl_dynamic_attr :virtual_disk_images do |virtual_disk_images|
167
224
  virtual_disk_images.should_update? do
168
225
  @last_virtual_disk_images_update ||= Time.at(0)
@@ -177,7 +234,7 @@ module SoftLayer
177
234
  end
178
235
 
179
236
  ##
180
- # The virtual servers (aka. CCIs or Virtual_Guests) associated with the
237
+ # Retrieve the virtual servers (aka. CCIs or Virtual_Guests) associated with the
181
238
  # account. Unless you force these to update, they will be refreshed every
182
239
  # five minutes.
183
240
  # :call-seq:
@@ -207,6 +264,26 @@ module SoftLayer
207
264
  # The IDs of the different segments can be helpful for ordering
208
265
  # firewalls.
209
266
  #
267
+ def find_vlan_with_number(vlan_number)
268
+ filter = SoftLayer::ObjectFilter.new() { |filter|
269
+ filter.accept('networkVlans.vlanNumber').when_it is vlan_number
270
+ }
271
+
272
+ vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
273
+ return vlan_data
274
+ end
275
+
276
+ ##
277
+ # Searches the account's list of VLANs for the ones with the given
278
+ # vlan number. This may return multiple results because a VLAN can
279
+ # span different routers and you will get a separate segment for
280
+ # each router.
281
+ #
282
+ # The IDs of the different segments can be helpful for ordering
283
+ # firewalls.
284
+ #
285
+ # DEPRECATION WARNING: This method is deprecated in favor of find_vlan_with_number
286
+ # and will be removed in the next major release.
210
287
  def find_VLAN_with_number(vlan_number)
211
288
  filter = SoftLayer::ObjectFilter.new() { |filter|
212
289
  filter.accept('networkVlans.vlanNumber').when_it is vlan_number
@@ -226,7 +303,7 @@ module SoftLayer
226
303
 
227
304
  account_service = softlayer_client[:Account]
228
305
  network_hash = account_service.getObject()
229
- new(softlayer_client, network_hash)
306
+ Account.new(softlayer_client, network_hash)
230
307
  end
231
308
 
232
309
  ##
@@ -32,6 +32,8 @@ module SoftLayer
32
32
 
33
33
  ##
34
34
  # A description of the use for the account username/password combination.
35
+ # :call-seq:
36
+ # description(force_update=false)
35
37
  sl_dynamic_attr :description do |resource|
36
38
  resource.should_update? do
37
39
  #only retrieved once per instance
@@ -74,13 +76,21 @@ module SoftLayer
74
76
  # If no client can be found the routine will raise an error.
75
77
  #
76
78
  # You may filter the list returned by adding options:
77
- # * <b>+:datacenter+</b> (string) - Include network storage account passwords from servers matching this datacenter
78
- # * <b>+:domain+</b> (string) - Include network storage account passwords from servers matching this domain
79
- # * <b>+:hostname+</b> (string) - Include network storage account passwords from servers matching this hostname
80
- # * <b>+:network_storage_server_type+</b> (string) - Include network storage account passwords attached to this server type
81
- # * <b>+:network_storage_type+</b> (string) - Include network storage account passwords from devices of this storage type
82
- # * <b>+:tags+</b> (Array) - Include network storage account passwords from servers matching these tags
83
- # * <b>+:username+</b> (string) - Include network storage account passwords with this username only
79
+ # * <b>+:datacenter+</b> (string/array) - Include network storage account passwords from servers matching this datacenter
80
+ # * <b>+:domain+</b> (string/array) - Include network storage account passwords from servers matching this domain
81
+ # * <b>+:hostname+</b> (string/array) - Include network storage account passwords from servers matching this hostname
82
+ # * <b>+:network_storage_server_type+</b> (symbol) - Include network storage account passwords attached to this server type
83
+ # * <b>+:network_storage_type+</b> (symbol) - Include network storage account passwords from devices of this storage type
84
+ # * <b>+:tags+</b> (string/array) - Include network storage account passwords from servers matching these tags
85
+ # * <b>+:username+</b> (string/array) - Include network storage account passwords with this username only
86
+ #
87
+ # Additionally you may provide options related to the request itself:
88
+ # * <b>*:account_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for account passwords that match the
89
+ # criteria of this object filter
90
+ # * <b>*:account_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
91
+ # If not provided, the result will use the default object mask
92
+ # * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
93
+ # criteria of this object filter
84
94
  #
85
95
  def self.find_network_storage_account_passwords(options_hash = {})
86
96
  softlayer_client = options_hash[:client] || Client.default_client
@@ -119,10 +129,12 @@ module SoftLayer
119
129
  :account_password => {
120
130
  :username => "accountPassword.username"
121
131
  },
122
- :datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
123
- :domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
124
- :hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
125
- :tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join }
132
+ :network_storage => {
133
+ :datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
134
+ :domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
135
+ :hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
136
+ :tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join }
137
+ }
126
138
  }
127
139
 
128
140
  if options_hash[:network_storage_type]
@@ -134,24 +146,13 @@ module SoftLayer
134
146
  if options_hash[:network_storage_server_type]
135
147
  network_storage_type = options_hash[:network_storage_type] || :network_storage
136
148
 
137
- [ :datacenter, :domain, :hostname ].each do |option|
149
+ option_to_filter_path[:network_storage].keys.each do |option|
138
150
  if options_hash[option]
139
151
  network_storage_object_filter.modify do |filter|
140
- filter.accept(option_to_filter_path[option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
152
+ filter.accept(option_to_filter_path[:network_storage][option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
141
153
  end
142
154
  end
143
155
  end
144
-
145
- if options_hash[:tags]
146
- network_storage_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(network_storage_type, options_hash[:network_storage_server_type]),
147
- {
148
- 'operation' => 'in',
149
- 'options' => [{
150
- 'name' => 'data',
151
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
152
- }]
153
- })
154
- end
155
156
  end
156
157
 
157
158
  option_to_filter_path[:account_password].each do |option, filter_path|
@@ -201,13 +202,21 @@ module SoftLayer
201
202
  # If no client can be found the routine will raise an error.
202
203
  #
203
204
  # You may filter the list returned by adding options:
204
- # * <b>+:datacenter+</b> (string) - Include network storage webcc passwords from servers matching this datacenter
205
- # * <b>+:domain+</b> (string) - Include network storage webcc passwords from servers matching this domain
206
- # * <b>+:hostname+</b> (string) - Include network storage webcc passwords from servers matching this hostname
207
- # * <b>+:network_storage_server_type+</b> (string) - Include network storage webcc passwords attached to this server type
208
- # * <b>+:network_storage_type+</b> (string) - Include network storage webcc passwords from devices of this storage type
209
- # * <b>+:tags+</b> (Array) - Include network storage webcc passwords from servers matching these tags
210
- # * <b>+:username+</b> (string) - Include network storage webcc passwords with this username only
205
+ # * <b>+:datacenter+</b> (string/array) - Include network storage webcc passwords from servers matching this datacenter
206
+ # * <b>+:domain+</b> (string/array) - Include network storage webcc passwords from servers matching this domain
207
+ # * <b>+:hostname+</b> (string/array) - Include network storage webcc passwords from servers matching this hostname
208
+ # * <b>+:network_storage_server_type+</b> (symbol) - Include network storage webcc passwords attached to this server type
209
+ # * <b>+:network_storage_type+</b> (symbol) - Include network storage webcc passwords from devices of this storage type
210
+ # * <b>+:tags+</b> (string/array) - Include network storage webcc passwords from servers matching these tags
211
+ # * <b>+:username+</b> (string/array) - Include network storage webcc passwords with this username only
212
+ #
213
+ # Additionally you may provide options related to the request itself:
214
+ # * <b>*:network_storage_object_filter*</b> (ObjectFilter) - Include network storage account passwords from network storage that matches the
215
+ # criteria of this object filter
216
+ # * <b>*:webcc_password_object_filter*</b> (ObjectFilter) - Include network storage account passwords for webcc passwords that match the
217
+ # criteria of this object filter
218
+ # * <b>*:webcc_password_object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
219
+ # If not provided, the result will use the default object mask
211
220
  #
212
221
  def self.find_network_storage_webcc_passwords(options_hash = {})
213
222
  softlayer_client = options_hash[:client] || Client.default_client
@@ -243,11 +252,13 @@ module SoftLayer
243
252
  }
244
253
 
245
254
  option_to_filter_path = {
246
- :datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
247
- :domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
248
- :hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
249
- :tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join },
250
- :webcc_password => {
255
+ :network_storage => {
256
+ :datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
257
+ :domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
258
+ :hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
259
+ :tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join }
260
+ },
261
+ :webcc_password => {
251
262
  :username => "webccAccount.username"
252
263
  }
253
264
  }
@@ -261,24 +272,13 @@ module SoftLayer
261
272
  if options_hash[:network_storage_server_type]
262
273
  network_storage_type = options_hash[:network_storage_type] || :network_storage
263
274
 
264
- [ :datacenter, :domain, :hostname ].each do |option|
275
+ option_to_filter_path[:network_storage].keys.each do |option|
265
276
  if options_hash[option]
266
277
  network_storage_object_filter.modify do |filter|
267
- filter.accept(option_to_filter_path[option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
278
+ filter.accept(option_to_filter_path[:network_storage][option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
268
279
  end
269
280
  end
270
281
  end
271
-
272
- if options_hash[:tags]
273
- network_storage_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(network_storage_type, options_hash[:network_storage_server_type]),
274
- {
275
- 'operation' => 'in',
276
- 'options' => [{
277
- 'name' => 'data',
278
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
279
- }]
280
- })
281
- end
282
282
  end
283
283
 
284
284
  option_to_filter_path[:webcc_password].each do |option, filter_path|
@@ -9,7 +9,7 @@
9
9
  module SoftLayer
10
10
  #
11
11
  # This class represents a Bare Metal Server, a hardware server in contrast to a virtual machine,
12
- # in the SoftLayer Environment. It corresponds rougly to the +SoftLayer_Hardware+ and
12
+ # in the SoftLayer Environment. It corresponds roughly to the +SoftLayer_Hardware+ and
13
13
  # +SoftLayer_Hardware_Server+ services in the SoftLayer API
14
14
  #
15
15
  # http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
@@ -23,7 +23,7 @@ module SoftLayer
23
23
  # a Bare Metal Instance is physical, hardware server that is is provisioned to
24
24
  # match a profile with characteristics similar to a Virtual Server
25
25
  #
26
- # This is an important distincition in rare cases, like cancelling the server.
26
+ # This is an important distinction in rare cases, like cancelling the server.
27
27
  #
28
28
  def bare_metal_instance?
29
29
  if has_sl_property?(:bareMetalInstanceFlag)
@@ -65,7 +65,7 @@ module SoftLayer
65
65
  # Returns the typical Service used to work with this Server
66
66
  # For Bare Metal Servers that is +SoftLayer_Hardware+ though in some special cases
67
67
  # you may have to use +SoftLayer_Hardware_Server+ as a type or service. That
68
- # service object is available thorugh the hardware_server_service method
68
+ # service object is available through the hardware_server_service method
69
69
  def service
70
70
  return softlayer_client[:Hardware_Server].object_with_id(self.id)
71
71
  end
@@ -146,7 +146,7 @@ module SoftLayer
146
146
  end
147
147
 
148
148
  ##
149
- # Retrive the bare metal server with the given server ID from the
149
+ # Retrieve the bare metal server with the given server ID from the
150
150
  # SoftLayer API
151
151
  #
152
152
  # The options parameter should contain:
@@ -155,6 +155,10 @@ module SoftLayer
155
155
  #
156
156
  # If no client is given, then the routine will try to use Client.default_client
157
157
  # If no client can be found the routine will raise an error.
158
+ #
159
+ # Additionally you may provide options related to the request itself:
160
+ # * <b>*:object_mask*</b> (string) - The object mask of properties you wish to receive for the items returned.
161
+ # If not provided, the result will use the default object mask
158
162
  def self.server_with_id(server_id, options = {})
159
163
  softlayer_client = options[:client] || Client.default_client
160
164
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
@@ -183,20 +187,22 @@ module SoftLayer
183
187
  #
184
188
  # You may filter the list returned by adding options:
185
189
  #
186
- # * <b>+:tags+</b> (array) - an array of strings representing tags to search for on the instances
187
- # * <b>+:cpus+</b> (int) - return servers with the given number of (virtual) CPUs
188
- # * <b>+:memory+</b> (int) - return servers with at least the given amount of memory (in Gigabytes)
189
- # * <b>+:hostname+</b> (string) - return servers whose hostnames match the query string given (see ObjectFilter::query_to_filter_operation)
190
- # * <b>+:domain+</b> (string) - filter servers to those whose domain matches the query string given (see ObjectFilter::query_to_filter_operation)
191
- # * <b>+:datacenter+</b> (string) - find servers whose data center name matches the query string given (see ObjectFilter::query_to_filter_operation)
192
- # * <b>+:nic_speed+</b> (int) - include servers with the given nic speed (in Mbps)
193
- # * <b>+:public_ip+</b> (string) - return servers whose public IP address matches the query string given (see ObjectFilter::query_to_filter_operation)
194
- # * <b>+:private_ip+</b> (string) - same as :public_ip, but for private IP addresses
190
+ # * <b>+:tags+</b> (string/array) - an array of strings representing tags to search for on the instances
191
+ # * <b>+:cpus+</b> (int/array) - return servers with the given number of (virtual) CPUs
192
+ # * <b>+:memory+</b> (int/array) - return servers with at least the given amount of memory (in Gigabytes)
193
+ # * <b>+:hostname+</b> (string/array) - return servers whose hostnames match the query string given (see ObjectFilter::query_to_filter_operation)
194
+ # * <b>+:domain+</b> (string/array) - filter servers to those whose domain matches the query string given (see ObjectFilter::query_to_filter_operation)
195
+ # * <b>+:datacenter+</b> (string/array) - find servers whose data center name matches the query string given (see ObjectFilter::query_to_filter_operation)
196
+ # * <b>+:nic_speed+</b> (int/array) - include servers with the given nic speed (in Mbps)
197
+ # * <b>+:public_ip+</b> (string/array) - return servers whose public IP address matches the query string given (see ObjectFilter::query_to_filter_operation)
198
+ # * <b>+:private_ip+</b> (string/array) - same as :public_ip, but for private IP addresses
195
199
  #
196
200
  # Additionally you may provide options related to the request itself:
197
- #
198
- # * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned If not provided, the result will use the default object mask
199
- # * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
201
+ # * <b>*:object_filter*</b> (ObjectFilter) - Include hardware servers for servers that matche the
202
+ # criteria of this object filter
203
+ # * <b>+:object_mask+</b> (string, hash, or array) - The object mask of properties you wish to receive for the items returned.
204
+ # If not provided, the result will use the default object mask
205
+ # * <b>+:result_limit+</b> (hash with :limit, and :offset keys) - Limit the scope of results returned.
200
206
  #
201
207
  def self.find_servers(options_hash = {})
202
208
  softlayer_client = options_hash[:client] || Client.default_client
@@ -210,14 +216,15 @@ module SoftLayer
210
216
  end
211
217
 
212
218
  option_to_filter_path = {
213
- :cpus => "hardware.processorPhysicalCoreAmount",
214
- :memory => "hardware.memoryCapacity",
215
- :hostname => "hardware.hostname",
216
- :domain => "hardware.domain",
219
+ :cpus => "hardware.processorPhysicalCoreAmount",
220
+ :memory => "hardware.memoryCapacity",
221
+ :hostname => "hardware.hostname",
222
+ :domain => "hardware.domain",
217
223
  :datacenter => "hardware.datacenter.name",
218
- :nic_speed => "hardware.networkComponents.maxSpeed",
219
- :public_ip => "hardware.primaryIpAddress",
220
- :private_ip => "hardware.primaryBackendIpAddress"
224
+ :nic_speed => "hardware.networkComponents.maxSpeed",
225
+ :public_ip => "hardware.primaryIpAddress",
226
+ :private_ip => "hardware.primaryBackendIpAddress",
227
+ :tags => "hardware.tagReferences.tag.name"
221
228
  }
222
229
 
223
230
  # For each of the options in the option_to_filter_path map, if the options hash includes
@@ -227,30 +234,13 @@ module SoftLayer
227
234
  object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option])} if options_hash[option]
228
235
  end
229
236
 
230
- # Tags get a much more complex object filter operation so we handle them separately
231
- if options_hash.has_key?(:tags)
232
- object_filter.set_criteria_for_key_path("hardware.tagReferences.tag.name", {
233
- 'operation' => 'in',
234
- 'options' => [{
235
- 'name' => 'data',
236
- 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
237
- }]
238
- } );
239
- end
240
-
241
237
  account_service = softlayer_client[:Account]
242
238
  account_service = account_service.object_filter(object_filter) unless object_filter.empty?
243
239
  account_service = account_service.object_mask(default_object_mask.to_sl_object_mask)
240
+ account_service = account_service.object_mask(options_hash[:object_mask]) if options_hash[:object_mask]
244
241
 
245
- if(options_hash.has_key? :object_mask)
246
- account_service = account_service.object_mask(options_hash[:object_mask])
247
- end
248
-
249
- if options_hash.has_key?(:result_limit)
250
- offset = options[:result_limit][:offset]
251
- limit = options[:result_limit][:limit]
252
-
253
- account_service = account_service.result_limit(offset, limit)
242
+ if options_hash[:result_limit] && options_hash[:result_limit][:offset] && options_hash[:result_limit][:limit]
243
+ account_service = account_service.result_limit(options_hash[:result_limit][:offset], options_hash[:result_limit][:limit])
254
244
  end
255
245
 
256
246
  bare_metal_data = account_service.getHardware()