softlayer_api 3.0.0 → 3.0.1

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.
@@ -75,7 +75,7 @@ module SoftLayer
75
75
  end
76
76
 
77
77
  # This call to getCategories is the one that does lots of fancy back-end filtering for us
78
- categories_data = softlayer_client[:Product_Package].object_with_id(self.id).getCategories()
78
+ categories_data = softlayer_client[:Product_Package].object_with_id(self.id).object_mask(@@categories_object_mask).getCategories()
79
79
 
80
80
  # Run though the categories and for each one that's in our config, create a SoftLayer::ProductItemCategory object.
81
81
  # Conveniently the +keys+ of the required_by_category_code gives us a list of the category codes in the configuration
@@ -220,8 +220,13 @@ module SoftLayer
220
220
 
221
221
  protected
222
222
 
223
+ @@categories_object_mask = "mask[" + [ "groups.prices.capacityRestrictionMaximum",
224
+ "groups.prices.capacityRestrictionMinimum",
225
+ "groups.prices.capacityRestrictionType",
226
+ "groups.prices.requiredCoreCount" ].join(",") + "]"
227
+
223
228
  def self.default_object_mask(root)
224
229
  "#{root}[id,name,description,availableLocations.location]"
225
230
  end
226
231
  end
227
- end # SoftLayer
232
+ end # SoftLayer
@@ -64,6 +64,20 @@ module SoftLayer
64
64
  end
65
65
  end
66
66
 
67
+ ##
68
+ # :attr_reader:
69
+ # All software installed on current server
70
+ sl_dynamic_attr :software do |software|
71
+ software.should_update? do
72
+ @software == nil
73
+ end
74
+
75
+ software.to_update do
76
+ software_data = self.service.object_mask(Software.default_object_mask).getSoftwareComponents
77
+ software_data.collect { |sw| Software.new(self.softlayer_client, sw) unless sw.empty? }.compact
78
+ end
79
+ end
80
+
67
81
  ##
68
82
  # Construct a server from the given client using the network data found in +network_hash+
69
83
  #
@@ -1,22 +1,8 @@
1
+ #--
1
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
2
3
  #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18
- # THE SOFTWARE.
19
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
20
6
 
21
7
  require 'xmlrpc/client'
22
8
 
@@ -0,0 +1,368 @@
1
+ #--
2
+ # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
+ #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
6
+
7
+ module SoftLayer
8
+ ##
9
+ # Each SoftLayer Software instance provides information about software
10
+ # installed on a specific piece of hardware.
11
+ #
12
+ # This class roughly corresponds to the entity SoftLayer_Software_Component
13
+ # in the API.
14
+ #
15
+ class Software < ModelBase
16
+ include ::SoftLayer::DynamicAttribute
17
+
18
+ ##
19
+ # :attr_reader:
20
+ # The manufacturer code that is needed to activate a license.
21
+ sl_attr :manufacturer_activation_code, 'manufacturerActivationCode'
22
+
23
+ ##
24
+ # :attr_reader:
25
+ # A license key for this specific installation of software, if it is needed.
26
+ sl_attr :manufacturer_license_key, 'manufacturerLicenseInstance'
27
+
28
+ ##
29
+ # The manufacturer, name and version of a piece of software.
30
+ sl_dynamic_attr :description do |resource|
31
+ resource.should_update? do
32
+ #only retrieved once per instance
33
+ @description == nil
34
+ end
35
+
36
+ resource.to_update do
37
+ description = self.service.getSoftwareDescription
38
+ description['longDescription']
39
+ end
40
+ end
41
+
42
+ ##
43
+ # The name of this specific piece of software.
44
+ sl_dynamic_attr :name do |resource|
45
+ resource.should_update? do
46
+ #only retrieved once per instance
47
+ @name == nil
48
+ end
49
+
50
+ resource.to_update do
51
+ description = self.service.getSoftwareDescription
52
+ description['name']
53
+ end
54
+ end
55
+
56
+ ##
57
+ # Username/Password pairs used for access to this Software Installation.
58
+ sl_dynamic_attr :passwords do |resource|
59
+ resource.should_update? do
60
+ #only retrieved once per instance
61
+ @passwords == nil
62
+ end
63
+
64
+ resource.to_update do
65
+ passwords = self.service.getPasswords
66
+ passwords.collect { |password_data| SoftwarePassword.new(softlayer_client, password_data) }
67
+ end
68
+ end
69
+
70
+ ##
71
+ # Adds specified username/password combination to current software instance
72
+ #
73
+ def add_user_password(username, password, options = {})
74
+ raise ArgumentError, "The new password cannot be nil" unless password
75
+ raise ArgumentError, "The new username cannot be nil" unless username
76
+ raise ArgumentError, "The new password cannot be empty" if password.empty?
77
+ raise ArgumentError, "The new username cannot be empty" if username.empty?
78
+
79
+ raise Exception, "Cannot add username password, a Software Password already exists for the provided username" if self.has_user_password?(username.to_s)
80
+
81
+ add_user_pw_template = {
82
+ 'softwareId' => self['id'].to_i,
83
+ 'password' => password.to_s,
84
+ 'username' => username.to_s
85
+ }
86
+
87
+ add_user_pw_template['notes'] = options['notes'].to_s if options.has_key?('notes')
88
+ add_user_pw_template['port'] = options['port'].to_i if options.has_key?('port')
89
+
90
+ softlayer_client[:Software_Component_Password].createObject(add_user_pw_template)
91
+
92
+ @passwords = nil
93
+ end
94
+
95
+ ##
96
+ # Deletes specified username password from current software instance
97
+ #
98
+ #
99
+ # This is a final action and cannot be undone.
100
+ # the transaction will proceed immediately.
101
+ #
102
+ # Call it with extreme care!
103
+ def delete_user_password!(username)
104
+ user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s }
105
+
106
+ unless user_password.empty?
107
+ softlayer_client[:Software_Component_Password].object_with_id(user_password.first['id']).deleteObject
108
+ @passwords = nil
109
+ end
110
+ end
111
+
112
+ ##
113
+ # Returns whether or not one of the Software Passowrd instances pertains to the specified user
114
+ #
115
+ def has_user_password?(username)
116
+ self.passwords.map { |sw_pw| sw_pw.username }.include?(username)
117
+ end
118
+
119
+ ##
120
+ # Retrieve a list of software from hardware devices.
121
+ #
122
+ # The options parameter should contain:
123
+ #
124
+ # <b>+:client+</b> - The client used to connect to the API
125
+ #
126
+ # If no client is given, then the routine will try to use Client.default_client
127
+ # If no client can be found the routine will raise an error.
128
+ #
129
+ # You may filter the list returned by adding options:
130
+ # * <b>+:datacenter+</b> (string) - Include software from hardware matching this datacenter
131
+ # * <b>+:description+</b> (string) - Include software that matches this description
132
+ # * <b>+:domain+</b> (string) - Include software from hardware matching this domain
133
+ # * <b>+:hardware_type+</b> (string) - Include software from hardware matching this hardware type
134
+ # * <b>+:hostname+</b> (string) - Include software from hardware matching this hostname
135
+ # * <b>+:manufacturer+</b> (string) - Include software that matches this manufacturer
136
+ # * <b>+:name+</b> (string) - Include software that matches this name
137
+ # * <b>+:username+</b> (string) - Include software that has software password matching this username
138
+ #
139
+ # You may use the following properties to provide hardware or software object filter instances:
140
+ # * <b>+:hardware_object_filter+</b> (ObjectFilter) - Include software from hardware that matches the criteria of this object filter
141
+ # * <b>+:software_object_filter+</b> (ObjectFilter) - Include software that matches the criteria of this object filter
142
+ # * <b>+:software_object_mask+</b> (string) - Include software properties that matches the criteria of this object mask
143
+ #
144
+ def self.find_software_on_hardware(options_hash = {})
145
+ softlayer_client = options_hash[:client] || Client.default_client
146
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
147
+
148
+ if(options_hash.has_key? :hardware_object_filter)
149
+ hardware_object_filter = options_hash[:hardware_object_filter]
150
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless hardware_object_filter.kind_of?(SoftLayer::ObjectFilter)
151
+ else
152
+ hardware_object_filter = ObjectFilter.new()
153
+ end
154
+
155
+ if(options_hash.has_key? :software_object_filter)
156
+ software_object_filter = options_hash[:software_object_filter]
157
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
158
+ else
159
+ software_object_filter = ObjectFilter.new()
160
+ end
161
+
162
+ filter_label = {
163
+ :bare_metal_instance => "bareMetalInstances",
164
+ :hardware => "hardware",
165
+ :network_hardware => "networkHardware",
166
+ :router => "routers"
167
+ }
168
+
169
+ option_to_filter_path = {
170
+ :datacenter => lambda { |hardware_type| return [ filter_label[hardware_type], '.datacenter.name' ].join },
171
+ :domain => lambda { |hardware_type| return [ filter_label[hardware_type], '.domain' ].join },
172
+ :hostname => lambda { |hardware_type| return [ filter_label[hardware_type], '.hostname' ].join },
173
+ :tags => lambda { |hardware_type| return [ filter_label[hardware_type], '.tagReferences.tag.name' ].join },
174
+ :software => {
175
+ :description => "softwareComponents.softwareDescription.longDescription",
176
+ :manufacturer => "softwareComponents.softwareDescription.manufacturer",
177
+ :name => "softwareComponents.softwareDescription.name",
178
+ :username => "softwareComponents.passwords.username"
179
+ }
180
+ }
181
+
182
+ if options_hash[:hardware_type]
183
+ unless filter_label.keys.include?(options_hash[:hardware_type])
184
+ raise "Expected :bare_metal_instance, :hardware, :network_hardware, or :router for option :hardware_type in #{__method__}"
185
+ end
186
+ end
187
+
188
+ [ :datacenter, :domain, :hostname ].each do |option|
189
+ if options_hash[option]
190
+ hardware_object_filter.modify { |filter| filter.accept(option_to_filter_path[option].call(options_hash[:hardware_type] || :hardware)).when_it is(options_hash[option]) }
191
+ end
192
+ end
193
+
194
+ if options_hash[:tags]
195
+ hardware_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(options_hash[:hardware_type] || :hardware),
196
+ {
197
+ 'operation' => 'in',
198
+ 'options' => [{
199
+ 'name' => 'data',
200
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
201
+ }]
202
+ })
203
+ end
204
+
205
+ option_to_filter_path[:software].each do |option, filter_path|
206
+ software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
207
+ end
208
+
209
+ account_service = softlayer_client[:Account]
210
+ account_service = account_service.object_filter(hardware_object_filter) unless hardware_object_filter.empty?
211
+ account_service = account_service.object_mask("mask[id]")
212
+
213
+ case options_hash[:hardware_type]
214
+ when :bare_metal_instance
215
+ hardware_data = account_service.getBareMetalInstances
216
+ when :hardware, nil
217
+ hardware_data = account_service.getHardware
218
+ when :network_hardware
219
+ hardware_data = account_service.getNetworkHardware
220
+ when :router
221
+ hardware_data = account_service.getRouters
222
+ end
223
+
224
+ software = hardware_data.collect do |hardware|
225
+ hardware_service = softlayer_client[:Hardware].object_with_id(hardware['id'])
226
+ hardware_service = hardware_service.object_filter(software_object_filter) unless software_object_filter.empty?
227
+ hardware_service = hardware_service.object_mask(Software.default_object_mask)
228
+ hardware_service = hardware_service.object_mask(options_hash[:software_object_mask]) if options_hash[:software_object_mask]
229
+
230
+ software_data = hardware_service.getSoftwareComponents
231
+ software_data.map { |software| Software.new(softlayer_client, software) unless software.empty? }.compact
232
+ end
233
+
234
+ software.flatten
235
+ end
236
+
237
+ ##
238
+ # Retrieve a list of software from virtual servers.
239
+ #
240
+ # The options parameter should contain:
241
+ #
242
+ # <b>+:client+</b> - The client used to connect to the API
243
+ #
244
+ # If no client is given, then the routine will try to use Client.default_client
245
+ # If no client can be found the routine will raise an error.
246
+ #
247
+ # You may filter the list returned by adding options:
248
+ # * <b>+:datacenter+</b> (string) - Include software from virtual servers matching this datacenter
249
+ # * <b>+:description+</b> (string) - Include software that matches this description
250
+ # * <b>+:domain+</b> (string) - Include software from virtual servers matching this domain
251
+ # * <b>+:hostname+</b> (string) - Include software from virtual servers matching this hostname
252
+ # * <b>+:manufacturer+</b> (string) - Include software that matches this manufacturer
253
+ # * <b>+:name+</b> (string) - Include software that matches this name
254
+ # * <b>+:username+</b> (string) - Include software that has software password matching this username
255
+ #
256
+ # You may use the following properties to provide virtual server or software object filter instances:
257
+ # * <b>+:virtual_server_object_filter+</b> (ObjectFilter) - Include software from virtual servers that matches the criteria of this object filter
258
+ # * <b>+:software_object_filter+</b> (ObjectFilter) - Include software that matches the criteria of this object filter
259
+ # * <b>+:software_object_mask+</b> (string) - Include software properties that matches the criteria of this object mask
260
+ #
261
+ def self.find_software_on_virtual_servers(options_hash = {})
262
+ softlayer_client = options_hash[:client] || Client.default_client
263
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
264
+
265
+ if(options_hash.has_key? :virtual_server_object_filter)
266
+ virtual_server_object_filter = options_hash[:virtual_server_object_filter]
267
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless virtual_server_object_filter.kind_of?(SoftLayer::ObjectFilter)
268
+ else
269
+ virtual_server_object_filter = ObjectFilter.new()
270
+ end
271
+
272
+ if(options_hash.has_key? :software_object_filter)
273
+ software_object_filter = options_hash[:software_object_filter]
274
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
275
+ else
276
+ software_object_filter = ObjectFilter.new()
277
+ end
278
+
279
+ option_to_filter_path = {
280
+ :software => {
281
+ :description => "softwareComponents.softwareDescription.longDescription",
282
+ :manufacturer => "softwareComponents.softwareDescription.manufacturer",
283
+ :name => "softwareComponents.softwareDescription.name",
284
+ :username => "softwareComponents.passwords.username"
285
+ },
286
+ :virtual_server => {
287
+ :datacenter => "virtualGuests.datacenter.name",
288
+ :domain => "virtualGuests.domain",
289
+ :hostname => "virtualGuests.hostname",
290
+ :tags => "virtualGuests.tagReferences.tag.name"
291
+ }
292
+ }
293
+
294
+ if options_hash[:tags]
295
+ virtual_server_object_filter.set_criteria_for_key_path(option_to_filter_path[:virtual_server][:tags],
296
+ {
297
+ 'operation' => 'in',
298
+ 'options' => [{
299
+ 'name' => 'data',
300
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
301
+ }]
302
+ })
303
+ end
304
+
305
+ option_to_filter_path[:virtual_server].each do |option, filter_path|
306
+ next if option == :tags
307
+ virtual_server_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
308
+ end
309
+
310
+ option_to_filter_path[:software].each do |option, filter_path|
311
+ software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
312
+ end
313
+
314
+ account_service = softlayer_client[:Account]
315
+ account_service = account_service.object_filter(virtual_server_object_filter) unless virtual_server_object_filter.empty?
316
+ account_service = account_service.object_mask("mask[id]")
317
+
318
+ virtual_server_data = account_service.getVirtualGuests
319
+
320
+ software = virtual_server_data.collect do |virtual_server|
321
+ virtual_server_service = softlayer_client[:Virtual_Guest].object_with_id(virtual_server['id'])
322
+ virtual_server_service = virtual_server_service.object_filter(software_object_filter) unless software_object_filter.empty?
323
+ virtual_server_service = virtual_server_service.object_mask(Software.default_object_mask)
324
+ virtual_server_service = virtual_server_service.object_mask(options_hash[:software_object_mask]) if options_hash[:software_object_mask]
325
+
326
+ software_data = virtual_server_service.getSoftwareComponents
327
+ software_data.map { |software| Software.new(softlayer_client, software) unless software.empty? }.compact
328
+ end
329
+
330
+ software.flatten
331
+ end
332
+
333
+ ##
334
+ # Returns the service for interacting with this software component through the network API
335
+ #
336
+ def service
337
+ softlayer_client[:Software_Component].object_with_id(self.id)
338
+ end
339
+
340
+ ##
341
+ # Make an API request to SoftLayer and return the latest properties hash
342
+ # for this object.
343
+ #
344
+ def softlayer_properties(object_mask = nil)
345
+ my_service = self.service
346
+
347
+ if(object_mask)
348
+ my_service = my_service.object_mask(object_mask)
349
+ else
350
+ my_service = my_service.object_mask(self.class.default_object_mask)
351
+ end
352
+
353
+ my_service.getObject()
354
+ end
355
+
356
+ protected
357
+
358
+ def self.default_object_mask
359
+ {
360
+ "mask(SoftLayer_Software_Component)" => [
361
+ 'id',
362
+ 'manufacturerActivationCode',
363
+ 'manufacturerLicenseInstance'
364
+ ]
365
+ }.to_sl_object_mask
366
+ end
367
+ end
368
+ end #SoftLayer
@@ -0,0 +1,612 @@
1
+ #--
2
+ # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
+ #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
6
+
7
+ module SoftLayer
8
+ ##
9
+ # Each SoftLayer SoftwarePassword instance provides information about
10
+ # a user's password associated with a SoftLayer Software instance.
11
+ #
12
+ # This class roughly corresponds to the entity SoftLayer_Software_Component_Password
13
+ # in the API.
14
+ #
15
+ class SoftwarePassword < ModelBase
16
+ include ::SoftLayer::DynamicAttribute
17
+
18
+ ##
19
+ # :attr_reader:
20
+ # The date this username/password pair was created.
21
+ sl_attr :created, 'createDate'
22
+
23
+ ##
24
+ # :attr_reader:
25
+ # The date of the last modification to this username/password pair.
26
+ sl_attr :modified, 'modifyDate'
27
+
28
+ ##
29
+ # :attr_reader:
30
+ # A note string stored for this username/password pair.
31
+ sl_attr :notes
32
+
33
+ ##
34
+ # :attr_reader:
35
+ # The password part of the username/password pair.
36
+ sl_attr :password
37
+
38
+ ##
39
+ # :attr_reader:
40
+ sl_attr :port
41
+
42
+ ##
43
+ # The username part of the username/password pair.
44
+ sl_attr :username
45
+
46
+ ##
47
+ # Updates the password for the current software user.
48
+ #
49
+ def password=(password)
50
+ raise ArgumentError, "The new password cannot be nil" unless password
51
+ raise ArgumentError, "The new password cannot be empty" if password.empty?
52
+
53
+ self.service.editObject({ "password" => password.to_s })
54
+ self.refresh_details()
55
+ end
56
+
57
+ ##
58
+ # Retrieve a list of software passwords from application delivery controllers.
59
+ #
60
+ # The options parameter should contain:
61
+ #
62
+ # <b>+:client+</b> - The client used to connect to the API
63
+ #
64
+ # If no client is given, then the routine will try to use Client.default_client
65
+ # If no client can be found the routine will raise an error.
66
+ #
67
+ # You may filter the list returned by adding options:
68
+ # * <b>+:datacenter+</b> (string) - Include software passwords from application delivery controllers matching this datacenter
69
+ # * <b>+:name+</b> (string) - Include software passwords from application delivery controllers that matches this name
70
+ # * <b>+:tags+</b> (Array) - Include software passwords from application delivery controllers that matches these tags
71
+ # * <b>+:username+</b> (string) - Include software passwords that match this username
72
+ #
73
+ def self.find_passwords_for_application_delivery_controllers(options_hash = {})
74
+ softlayer_client = options_hash[:client] || Client.default_client
75
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
76
+
77
+ if(options_hash.has_key? :application_delivery_controller_object_filter)
78
+ application_delivery_controller_object_filter = options_hash[:application_delivery_controller_object_filter]
79
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless application_delivery_controller_object_filter.kind_of?(SoftLayer::ObjectFilter)
80
+ else
81
+ application_delivery_controller_object_filter = ObjectFilter.new()
82
+ end
83
+
84
+ if(options_hash.has_key? :software_password_object_filter)
85
+ software_password_object_filter = options_hash[:software_password_object_filter]
86
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
87
+ else
88
+ software_password_object_filter = ObjectFilter.new()
89
+ end
90
+
91
+ option_to_filter_path = {
92
+ :advanced_mode => "applicationDeliveryControllers.advancedModeFlag",
93
+ :datacenter => "applicationDeliveryControllers.datacenter.name",
94
+ :name => "applicationDeliveryControllers.name",
95
+ :tags => "applicationDeliveryControllers.tagReferences.tag.name",
96
+ :software_password => {
97
+ :username => "password.username"
98
+ }
99
+ }
100
+
101
+ application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[:advanced_mode]).when_it is(true) }
102
+
103
+ [ :datacenter, :name ].each do |option|
104
+ if options_hash[option]
105
+ application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[option]).when_it is(options_hash[option]) }
106
+ end
107
+ end
108
+
109
+ if options_hash[:tags]
110
+ application_delivery_controller_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags],
111
+ {
112
+ 'operation' => 'in',
113
+ 'options' => [{
114
+ 'name' => 'data',
115
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
116
+ }]
117
+ })
118
+ end
119
+
120
+ option_to_filter_path[:software_password].each do |option, filter_path|
121
+ software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
122
+ end
123
+
124
+ account_service = softlayer_client[:Account]
125
+ account_service = account_service.object_filter(application_delivery_controller_object_filter) unless application_delivery_controller_object_filter.empty?
126
+ account_service = account_service.object_mask("mask[id]")
127
+
128
+ application_delivery_controller_data = account_service.getApplicationDeliveryControllers
129
+ software_passwords = application_delivery_controller_data.collect do |application_delivery_controller|
130
+ application_delivery_controller_service = softlayer_client[:Network_Application_Delivery_Controller].object_with_id(application_delivery_controller['id'])
131
+ application_delivery_controller_service = application_delivery_controller_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
132
+ application_delivery_controller_service = application_delivery_controller_service.object_mask(SoftwarePassword.default_object_mask)
133
+ application_delivery_controller_service = application_delivery_controller_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]
134
+
135
+ software_password_data = application_delivery_controller_service.getPassword
136
+ SoftwarePassword.new(softlayer_client, software_password_data) unless software_password_data.empty?
137
+ end
138
+
139
+ software_passwords.compact
140
+ end
141
+
142
+ ##
143
+ # Retrieve a list of software passwords from vlan firewalls management credentials.
144
+ #
145
+ # The options parameter should contain:
146
+ #
147
+ # <b>+:client+</b> - The client used to connect to the API
148
+ #
149
+ # If no client is given, then the routine will try to use Client.default_client
150
+ # If no client can be found the routine will raise an error.
151
+ #
152
+ # You may filter the list returned by adding options:
153
+ # * <b>+:datacenter+</b> (string) - Include software passwords from vlan firewalls matching this datacenter
154
+ # * <b>+:vlan_name+</b> (Array) - Include software passwords from vlans that matches these names
155
+ # * <b>+:vlan_numbers+</b> (Array) - Include software passwords from vlans that matches these numbers
156
+ # * <b>+:vlan_space+</b> (symbol) - Include software passwords from vlans that match this space
157
+ # * <b>+:vlan_tags+</b> (Array) - Include software passwords from vlans that matches these tags
158
+ # * <b>+:vlan_fw_fqdn+</b> (string) - Include software passwords from vlan firewalls that match this fqdn
159
+ # * <b>+:vlan_fw_tags+</b> (Array) - Include software passwords from vlan firewalls that matches these tags
160
+ # * <b>+:vlan_fw_type+</b> (string) - Include software passwords from vlan firewalls that match this type
161
+ # * <b>+:username+</b> (string) - Include software passwords that match this username
162
+ #
163
+ def self.find_passwords_for_vlan_firewalls(options_hash = {})
164
+ softlayer_client = options_hash[:client] || Client.default_client
165
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
166
+
167
+ if(options_hash.has_key? :vlan_object_filter)
168
+ vlan_object_filter = options_hash[:vlan_object_filter]
169
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless vlan_object_filter.kind_of?(SoftLayer::ObjectFilter)
170
+ else
171
+ vlan_object_filter = ObjectFilter.new()
172
+ end
173
+
174
+ if(options_hash.has_key? :vlan_firewall_object_filter)
175
+ vlan_firewall_object_filter = options_hash[:vlan_firewall_object_filter]
176
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless vlan_firewall_object_filter.kind_of?(SoftLayer::ObjectFilter)
177
+ else
178
+ vlan_firewall_object_filter = ObjectFilter.new()
179
+ end
180
+
181
+ if(options_hash.has_key? :software_password_object_filter)
182
+ software_password_object_filter = options_hash[:software_password_object_filter]
183
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
184
+ else
185
+ software_password_object_filter = ObjectFilter.new()
186
+ end
187
+
188
+ filter_label = {
189
+ :all => 'networkVlans',
190
+ :private => 'privateNetworkVlans',
191
+ :public => 'publicNetworkVlans'
192
+ }
193
+
194
+ option_to_filter_path = {
195
+ :software_password => {
196
+ :username => "managementCredentials.username"
197
+ },
198
+ :vlan_dedicated_fw => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'dedicatedFirewallFlag' ].join },
199
+ :vlan_names => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'name' ].join },
200
+ :vlan_numbers => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'vlanNumber' ].join },
201
+ :vlan_tags => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'tagReferences.tag.name' ].join },
202
+ :vlan_firewall => {
203
+ :vlan_fw_datacenter => "networkVlanFirewall.datacenter.name",
204
+ :vlan_fw_fqdn => "networkVlanFirewall.fullyQualifiedDomainName",
205
+ :vlan_fw_type => "networkVlanFirewall.firewallType"
206
+ },
207
+ :vlan_fw_tags => "networkVlanFirewall.tagReferences.tag.name"
208
+ }
209
+
210
+ if options_hash[:vlan_space] && ! filter_label.keys.include?(options_hash[:vlan_space])
211
+ raise "Expected one of :all, :private, or :public for option :vlan_space in #{__method__}"
212
+ end
213
+
214
+ option_to_filter_path[:software_password].each do |option, filter_path|
215
+ software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
216
+ end
217
+
218
+ vlan_space = options_hash[:vlan_space] || :all
219
+
220
+ vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan_dedicated_fw].call(vlan_space)).when_it is(1) }
221
+ vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan_name].call(vlan_space)).when_it is(options_hash[:vlan_name]) } if options_hash[:vlan_name]
222
+
223
+ [ :vlan_names, :vlan_numbers, :vlan_tags ].each do |option|
224
+ if options_hash[option]
225
+ vlan_object_filter.set_criteria_for_key_path(option_to_filter_path[option].call(vlan_space),
226
+ {
227
+ 'operation' => 'in',
228
+ 'options' => [{
229
+ 'name' => 'data',
230
+ 'value' => options_hash[option].collect{ |tag_value| tag_value.to_s }
231
+ }]
232
+ })
233
+ end
234
+ end
235
+
236
+ option_to_filter_path[:vlan_firewall].each do |option, filter_path|
237
+ vlan_firewall_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
238
+ end
239
+
240
+ if options_hash[:vlan_fw_tags]
241
+ vlan_firewall_object_filter.set_criteria_for_key_path(option_to_filter_path[:vlan_fw_tags],
242
+ {
243
+ 'operation' => 'in',
244
+ 'options' => [{
245
+ 'name' => 'data',
246
+ 'value' => options_hash[:vlan_fw_tags].collect{ |tag_value| tag_value.to_s }
247
+ }]
248
+ })
249
+ end
250
+
251
+ account_service = softlayer_client[:Account]
252
+ account_service = account_service.object_filter(vlan_object_filter) unless vlan_object_filter.empty?
253
+ account_service = account_service.object_mask("mask[id]")
254
+
255
+ case vlan_space
256
+ when :all
257
+ vlan_data = account_service.getNetworkVlans
258
+ when :private
259
+ vlan_data = account_service.getPrivateNetworkVlans
260
+ when :public
261
+ vlan_data = account_service.getPublicNetworkVlans
262
+ end
263
+
264
+ vlan_fw_passwords = vlan_data.collect do |vlan|
265
+ vlan_service = softlayer_client[:Network_Vlan].object_with_id(vlan['id'])
266
+ vlan_service = vlan_service.object_filter(vlan_firewall_object_filter) unless vlan_firewall_object_filter.empty?
267
+ vlan_service = vlan_service.object_mask("mask[id]")
268
+
269
+ vlan_fw = vlan_service.getNetworkVlanFirewall
270
+
271
+ unless vlan_fw.empty?
272
+ vlan_fw_service = softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_fw['id'])
273
+ vlan_fw_service = vlan_fw_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
274
+ vlan_fw_service = vlan_fw_service.object_mask(SoftwarePassword.default_object_mask)
275
+ vlan_fw_service = vlan_fw_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]
276
+
277
+ vlan_fw_password_data = vlan_fw_service.getManagementCredentials
278
+ SoftwarePassword.new(softlayer_client, vlan_fw_password_data) unless vlan_fw_password_data.empty?
279
+ end
280
+ end
281
+
282
+ vlan_fw_passwords.compact
283
+ end
284
+
285
+ ##
286
+ # Retrieve a list of software passwords from software on hardware devices.
287
+ #
288
+ # The options parameter should contain:
289
+ #
290
+ # <b>+:client+</b> - The client used to connect to the API
291
+ #
292
+ # If no client is given, then the routine will try to use Client.default_client
293
+ # If no client can be found the routine will raise an error.
294
+ #
295
+ # You may filter the list returned by adding options:
296
+ # * <b>+:datacenter+</b> (string) - Include software passwords from software on hardware matching this datacenter
297
+ # * <b>+:description+</b> (string) - Include software passwords from software that matches this description
298
+ # * <b>+:domain+</b> (string) - Include software passwords from software on hardware matching this domain
299
+ # * <b>+:hardware_type+</b> (string) - Include software passwords from software on hardware matching this hardware type
300
+ # * <b>+:hostname+</b> (string) - Include software passwords from software on hardware matching this hostname
301
+ # * <b>+:manufacturer+</b> (string) - Include software passwords from software that matches this manufacturer
302
+ # * <b>+:name+</b> (string) - Include software passwords from software that matches this name
303
+ # * <b>+:username+</b> (string) - Include software passwords for username matching this username
304
+ #
305
+ # You may use the following properties to provide hardware or software object filter instances:
306
+ # * <b>+:hardware_object_filter+</b> (ObjectFilter) - Include software passwords from software on hardware that matches the criteria of this object filter
307
+ # * <b>+:software_object_filter+</b> (ObjectFilter) - Include software passwords from software that matches the criteria of this object filter
308
+ # * <b>+:software_password_object_filter*</b> (ObjectFilter) - Include software passwords that match the criteria of this object filter
309
+ # * <b>+:software_password_object_mask+</b> (string) - Include software password properties that matches the criteria of this object mask
310
+ #
311
+ def self.find_passwords_for_software_on_hardware(options_hash = {})
312
+ softlayer_client = options_hash[:client] || Client.default_client
313
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
314
+
315
+ if(options_hash.has_key? :hardware_object_filter)
316
+ hardware_object_filter = options_hash[:hardware_object_filter]
317
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless hardware_object_filter.kind_of?(SoftLayer::ObjectFilter)
318
+ else
319
+ hardware_object_filter = ObjectFilter.new()
320
+ end
321
+
322
+ if(options_hash.has_key? :software_object_filter)
323
+ software_object_filter = options_hash[:software_object_filter]
324
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
325
+ else
326
+ software_object_filter = ObjectFilter.new()
327
+ end
328
+
329
+ if(options_hash.has_key? :software_password_object_filter)
330
+ software_password_object_filter = options_hash[:software_password_object_filter]
331
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
332
+ else
333
+ software_password_object_filter = ObjectFilter.new()
334
+ end
335
+
336
+ filter_label = {
337
+ :bare_metal_instance => "bareMetalInstances",
338
+ :hardware => "hardware",
339
+ :network_hardware => "networkHardware",
340
+ :router => "routers"
341
+ }
342
+
343
+ option_to_filter_path = {
344
+ :datacenter => lambda { |hardware_type| return [ filter_label[hardware_type], '.datacenter.name' ].join },
345
+ :domain => lambda { |hardware_type| return [ filter_label[hardware_type], '.domain' ].join },
346
+ :hostname => lambda { |hardware_type| return [ filter_label[hardware_type], '.hostname' ].join },
347
+ :tags => lambda { |hardware_type| return [ filter_label[hardware_type], '.tagReferences.tag.name' ].join },
348
+ :software => {
349
+ :description => "softwareComponents.softwareDescription.longDescription",
350
+ :manufacturer => "softwareComponents.softwareDescription.manufacturer",
351
+ :name => "softwareComponents.softwareDescription.name",
352
+ :username => "softwareComponents.passwords.username"
353
+ },
354
+ :software_password => {
355
+ :username => "passwords.username"
356
+ }
357
+ }
358
+
359
+ if options_hash[:hardware_type]
360
+ unless filter_label.keys.include?(options_hash[:hardware_type])
361
+ raise "Expected :bare_metal_instance, :hardware, :network_hardware, or :router for option :hardware_type in #{__method__}"
362
+ end
363
+ end
364
+
365
+ [ :datacenter, :domain, :hostname ].each do |option|
366
+ if options_hash[option]
367
+ hardware_object_filter.modify { |filter| filter.accept(option_to_filter_path[option].call(options_hash[:hardware_type] || :hardware)).when_it is(options_hash[option]) }
368
+ end
369
+ end
370
+
371
+ if options_hash[:tags]
372
+ hardware_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(options_hash[:hardware_type] || :hardware),
373
+ {
374
+ 'operation' => 'in',
375
+ 'options' => [{
376
+ 'name' => 'data',
377
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
378
+ }]
379
+ })
380
+ end
381
+
382
+ option_to_filter_path[:software].each do |option, filter_path|
383
+ software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
384
+ end
385
+
386
+ option_to_filter_path[:software_password].each do |option, filter_path|
387
+ software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
388
+ end
389
+
390
+ account_service = softlayer_client[:Account]
391
+ account_service = account_service.object_filter(hardware_object_filter) unless hardware_object_filter.empty?
392
+ account_service = account_service.object_mask("mask[id]")
393
+
394
+ case options_hash[:hardware_type]
395
+ when :bare_metal_instance
396
+ hardware_data = account_service.getBareMetalInstances
397
+ when :hardware, nil
398
+ hardware_data = account_service.getHardware
399
+ when :network_hardware
400
+ hardware_data = account_service.getNetworkHardware
401
+ when :router
402
+ hardware_data = account_service.getRouters
403
+ end
404
+
405
+ software_passwords = hardware_data.collect do |hardware|
406
+ hardware_service = softlayer_client[:Hardware].object_with_id(hardware['id'])
407
+ hardware_service = hardware_service.object_filter(software_object_filter) unless software_object_filter.empty?
408
+ hardware_service = hardware_service.object_mask("mask[id]")
409
+
410
+ software_data = hardware_service.getSoftwareComponents
411
+
412
+ software_data.collect do |software|
413
+ next if software.empty?
414
+
415
+ software_service = softlayer_client[:Software_Component].object_with_id(software['id'])
416
+ software_service = software_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
417
+ software_service = software_service.object_mask(SoftwarePassword.default_object_mask)
418
+ software_service = software_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]
419
+
420
+ software_passwords_data = software_service.getPasswords
421
+ software_passwords_data.map { |password| SoftwarePassword.new(softlayer_client, password) unless password.empty? }.compact
422
+ end
423
+ end
424
+
425
+ software_passwords.flatten
426
+ end
427
+
428
+ ##
429
+ # Retrieve a list of software passwords from software virtual servers.
430
+ #
431
+ # The options parameter should contain:
432
+ #
433
+ # <b>+:client+</b> - The client used to connect to the API
434
+ #
435
+ # If no client is given, then the routine will try to use Client.default_client
436
+ # If no client can be found the routine will raise an error.
437
+ #
438
+ # You may filter the list returned by adding options:
439
+ # * <b>+:datacenter+</b> (string) - Include software passwords from software on virtual servers matching this datacenter
440
+ # * <b>+:description+</b> (string) - Include software passwords from software that matches this description
441
+ # * <b>+:domain+</b> (string) - Include software passwords from software on virtual servers matching this domain
442
+ # * <b>+:hostname+</b> (string) - Include software passwords from software on virtual servers matching this hostname
443
+ # * <b>+:manufacturer+</b> (string) - Include software passwords from software that matches this manufacturer
444
+ # * <b>+:name+</b> (string) - Include software passwords from software that matches this name
445
+ # * <b>+:username+</b> (string) - Include software passwords for username matching this username
446
+ #
447
+ # You may use the following properties to provide virtual server or software object filter instances:
448
+ # * <b>+:virtual_server_object_filter+</b> (ObjectFilter) - Include software passwords from software on virtual servers that matches the criteria of this object filter
449
+ # * <b>+:software_object_filter+</b> (ObjectFilter) - Include software passwords from softwarethat matches the criteria of this object filter
450
+ # * <b>+:software_password_object_filter*</b> (ObjectFilter) - Include software passwords that match the criteria of this object filter
451
+ # * <b>+:software_password_object_mask+</b> (string) - Include software password properties that matches the criteria of this object mask
452
+ #
453
+ def self.find_passwords_for_software_on_virtual_servers(options_hash = {})
454
+ softlayer_client = options_hash[:client] || Client.default_client
455
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
456
+
457
+ if(options_hash.has_key? :virtual_server_object_filter)
458
+ virtual_server_object_filter = options_hash[:virtual_server_object_filter]
459
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless virtual_server_object_filter.kind_of?(SoftLayer::ObjectFilter)
460
+ else
461
+ virtual_server_object_filter = ObjectFilter.new()
462
+ end
463
+
464
+ if(options_hash.has_key? :software_object_filter)
465
+ software_object_filter = options_hash[:software_object_filter]
466
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
467
+ else
468
+ software_object_filter = ObjectFilter.new()
469
+ end
470
+
471
+ if(options_hash.has_key? :software_password_object_filter)
472
+ software_password_object_filter = options_hash[:software_password_object_filter]
473
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
474
+ else
475
+ software_password_object_filter = ObjectFilter.new()
476
+ end
477
+
478
+ option_to_filter_path = {
479
+ :software => {
480
+ :description => "softwareComponents.softwareDescription.longDescription",
481
+ :manufacturer => "softwareComponents.softwareDescription.manufacturer",
482
+ :name => "softwareComponents.softwareDescription.name",
483
+ :username => "softwareComponents.passwords.username"
484
+ },
485
+ :virtual_server => {
486
+ :datacenter => "virtualGuests.datacenter.name",
487
+ :domain => "virtualGuests.domain",
488
+ :hostname => "virtualGuests.hostname",
489
+ :tags => "virtualGuests.tagReferences.tag.name"
490
+ },
491
+ :software_password => {
492
+ :username => "passwords.username"
493
+ }
494
+ }
495
+
496
+ if options_hash[:tags]
497
+ virtual_server_object_filter.set_criteria_for_key_path(option_to_filter_path[:virtual_server][:tags],
498
+ {
499
+ 'operation' => 'in',
500
+ 'options' => [{
501
+ 'name' => 'data',
502
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
503
+ }]
504
+ })
505
+ end
506
+
507
+ option_to_filter_path[:virtual_server].each do |option, filter_path|
508
+ next if option == :tags
509
+ virtual_server_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
510
+ end
511
+
512
+ option_to_filter_path[:software].each do |option, filter_path|
513
+ software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
514
+ end
515
+
516
+ option_to_filter_path[:software_password].each do |option, filter_path|
517
+ software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
518
+ end
519
+
520
+ account_service = softlayer_client[:Account]
521
+ account_service = account_service.object_filter(virtual_server_object_filter) unless virtual_server_object_filter.empty?
522
+ account_service = account_service.object_mask("mask[id]")
523
+
524
+ virtual_server_data = account_service.getVirtualGuests
525
+
526
+ software_passwords = virtual_server_data.collect do |virtual_server|
527
+ virtual_server_service = softlayer_client[:Virtual_Guest].object_with_id(virtual_server['id'])
528
+ virtual_server_service = virtual_server_service.object_filter(software_object_filter) unless software_object_filter.empty?
529
+ virtual_server_service = virtual_server_service.object_mask("mask[id]")
530
+
531
+ software_data = virtual_server_service.getSoftwareComponents
532
+ software_data.collect do |software|
533
+ next if software.empty?
534
+
535
+ software_service = softlayer_client[:Software_Component].object_with_id(software['id'])
536
+ software_service = software_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
537
+ software_service = software_service.object_mask(SoftwarePassword.default_object_mask)
538
+ software_service = software_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]
539
+
540
+ software_passwords_data = software_service.getPasswords
541
+ software_passwords_data.map { |password| SoftwarePassword.new(softlayer_client, password) unless password.empty? }.compact
542
+ end
543
+ end
544
+
545
+ software_passwords.flatten
546
+ end
547
+
548
+ ##
549
+ # Update the passwords for a list of software passwords
550
+ #
551
+ # The options parameter should contain:
552
+ #
553
+ # <b>+:client+</b> - The client used to connect to the API
554
+ #
555
+ # If no client is given, then the routine will try to use Client.default_client
556
+ # If no client can be found the routine will raise an error.
557
+ #
558
+ def self.update_passwords(passwords, password, options_hash = {})
559
+ softlayer_client = options_hash[:client] || Client.default_client
560
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client
561
+
562
+ raise ArgumentError, "The new password cannot be nil" unless password
563
+ raise ArgumentError, "The new password cannot be empty" if password.empty?
564
+
565
+ if ! passwords.kind_of?(Array) || ! passwords.select { |password| ! password.kind_of?(SoftLayer::SoftwarePassword) }.empty?
566
+ raise ArgumentError, "Expected an array of SoftLayer::SoftwarePassword instances"
567
+ end
568
+
569
+ software_password_service = softlayer_client[:Software_Component_Password]
570
+ software_password_service.editObjects(passwords.map { |pw| { 'id' => pw['id'], 'password' => password.to_s } })
571
+ end
572
+
573
+ ##
574
+ # Returns the service for interacting with this software component password through the network API
575
+ #
576
+ def service
577
+ softlayer_client[:Software_Component_Password].object_with_id(self.id)
578
+ end
579
+
580
+ ##
581
+ # Make an API request to SoftLayer and return the latest properties hash
582
+ # for this object.
583
+ #
584
+ def softlayer_properties(object_mask = nil)
585
+ my_service = self.service
586
+
587
+ if(object_mask)
588
+ my_service = my_service.object_mask(object_mask)
589
+ else
590
+ my_service = my_service.object_mask(self.class.default_object_mask)
591
+ end
592
+
593
+ my_service.getObject()
594
+ end
595
+
596
+ protected
597
+
598
+ def self.default_object_mask
599
+ {
600
+ "mask(SoftLayer_Software_Component_Password)" => [
601
+ 'createDate',
602
+ 'id',
603
+ 'modifyDate',
604
+ 'notes',
605
+ 'password',
606
+ 'port',
607
+ 'username'
608
+ ]
609
+ }.to_sl_object_mask
610
+ end
611
+ end
612
+ end #SoftLayer