Class: SoftLayer::SoftwarePassword

Inherits:
ModelBase
  • Object
show all
Includes:
DynamicAttribute
Defined in:
lib/softlayer/SoftwarePassword.rb

Overview

Each SoftLayer SoftwarePassword instance provides information about a user’s password associated with a SoftLayer Software instance.

This class roughly corresponds to the entity SoftLayer_Software_Component_Password in the API.

Instance Attribute Summary

Attributes inherited from ModelBase

#softlayer_client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DynamicAttribute

included

Methods inherited from ModelBase

#[], #has_sl_property?, #initialize, #refresh_details, sl_attr, #to_ary

Constructor Details

This class inherits a constructor from SoftLayer::ModelBase

Class Method Details

.find_passwords_for_application_delivery_controllers(options_hash = {}) ⇒ Object

Retrieve a list of software passwords from application delivery controllers.

The options parameter should contain:

:client - The client used to connect to the API

If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.

You may filter the list returned by adding options:

  • :datacenter (string) - Include software passwords from application delivery controllers matching this datacenter

  • :name (string) - Include software passwords from application delivery controllers that matches this name

  • :tags (Array) - Include software passwords from application delivery controllers that matches these tags

  • :username (string) - Include software passwords that match this username



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/softlayer/SoftwarePassword.rb', line 73

def self.find_passwords_for_application_delivery_controllers(options_hash = {})
  softlayer_client = options_hash[:client] || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

  if(options_hash.has_key? :application_delivery_controller_object_filter)
    application_delivery_controller_object_filter = options_hash[:application_delivery_controller_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless application_delivery_controller_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    application_delivery_controller_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_password_object_filter)
    software_password_object_filter = options_hash[:software_password_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_password_object_filter = ObjectFilter.new()
  end

  option_to_filter_path = {
    :advanced_mode     => "applicationDeliveryControllers.advancedModeFlag",
    :datacenter        => "applicationDeliveryControllers.datacenter.name",
    :name              => "applicationDeliveryControllers.name",
    :tags              => "applicationDeliveryControllers.tagReferences.tag.name",
    :software_password => {
      :username        => "password.username"
    }
  }

  application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[:advanced_mode]).when_it is(true) }

  [ :datacenter, :name ].each do |option|
    if options_hash[option]
      application_delivery_controller_object_filter.modify { |filter| filter.accept(option_to_filter_path[option]).when_it is(options_hash[option]) }
    end
  end

  if options_hash[:tags]
    application_delivery_controller_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags],
                                                                            {
                                                                              'operation' => 'in',
                                                                              'options' => [{
                                                                                              'name' => 'data',
                                                                                              'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
                                                                                            }]
                                                                            })
  end

  option_to_filter_path[:software_password].each do |option, filter_path|
    software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

   = softlayer_client[:Account]
   = .object_filter(application_delivery_controller_object_filter) unless application_delivery_controller_object_filter.empty?
   = .object_mask("mask[id]")

  application_delivery_controller_data = .getApplicationDeliveryControllers
  software_passwords                   = application_delivery_controller_data.collect do |application_delivery_controller|
    application_delivery_controller_service = softlayer_client[:Network_Application_Delivery_Controller].object_with_id(application_delivery_controller['id'])
    application_delivery_controller_service = application_delivery_controller_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
    application_delivery_controller_service = application_delivery_controller_service.object_mask(SoftwarePassword.default_object_mask)
    application_delivery_controller_service = application_delivery_controller_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]

    software_password_data = application_delivery_controller_service.getPassword
    SoftwarePassword.new(softlayer_client, software_password_data) unless software_password_data.empty?
  end

  software_passwords.compact
end

.find_passwords_for_software_on_hardware(options_hash = {}) ⇒ Object

Retrieve a list of software passwords from software on hardware devices.

The options parameter should contain:

:client - The client used to connect to the API

If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.

You may filter the list returned by adding options:

  • :datacenter (string) - Include software passwords from software on hardware matching this datacenter

  • :description (string) - Include software passwords from software that matches this description

  • :domain (string) - Include software passwords from software on hardware matching this domain

  • :hardware_type (string) - Include software passwords from software on hardware matching this hardware type

  • :hostname (string) - Include software passwords from software on hardware matching this hostname

  • :manufacturer (string) - Include software passwords from software that matches this manufacturer

  • :name (string) - Include software passwords from software that matches this name

  • :username (string) - Include software passwords for username matching this username

You may use the following properties to provide hardware or software object filter instances:

  • :hardware_object_filter (ObjectFilter) - Include software passwords from software on hardware that matches the criteria of this object filter

  • :software_object_filter (ObjectFilter) - Include software passwords from software that matches the criteria of this object filter

  • +:software_password_object_filter* (ObjectFilter) - Include software passwords that match the criteria of this object filter

  • :software_password_object_mask (string) - Include software password properties that matches the criteria of this object mask



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/softlayer/SoftwarePassword.rb', line 311

def self.find_passwords_for_software_on_hardware(options_hash = {})
  softlayer_client = options_hash[:client] || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

  if(options_hash.has_key? :hardware_object_filter)
    hardware_object_filter = options_hash[:hardware_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless hardware_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    hardware_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_object_filter)
    software_object_filter = options_hash[:software_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_password_object_filter)
    software_password_object_filter = options_hash[:software_password_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_password_object_filter = ObjectFilter.new()
  end

  filter_label = {
    :bare_metal_instance => "bareMetalInstances",
    :hardware            => "hardware",
    :network_hardware    => "networkHardware",
    :router              => "routers"
  }

  option_to_filter_path = {
    :datacenter        => lambda { |hardware_type| return [ filter_label[hardware_type], '.datacenter.name' ].join        },
    :domain            => lambda { |hardware_type| return [ filter_label[hardware_type], '.domain' ].join                 },
    :hostname          => lambda { |hardware_type| return [ filter_label[hardware_type], '.hostname' ].join               },
    :tags              => lambda { |hardware_type| return [ filter_label[hardware_type], '.tagReferences.tag.name' ].join },
    :software          => {
      :description     => "softwareComponents.softwareDescription.longDescription",
      :manufacturer    => "softwareComponents.softwareDescription.manufacturer",
      :name            => "softwareComponents.softwareDescription.name",
      :username        => "softwareComponents.passwords.username"
    },
    :software_password => {
      :username        => "passwords.username"
    }
  }

  if options_hash[:hardware_type]
    unless filter_label.keys.include?(options_hash[:hardware_type])
      raise "Expected :bare_metal_instance, :hardware, :network_hardware, or :router for option :hardware_type in #{__method__}"
    end
  end

  [ :datacenter, :domain, :hostname ].each do |option|
    if options_hash[option]
      hardware_object_filter.modify { |filter| filter.accept(option_to_filter_path[option].call(options_hash[:hardware_type] || :hardware)).when_it is(options_hash[option]) }
    end
  end

  if options_hash[:tags]
    hardware_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(options_hash[:hardware_type] || :hardware),
                                                     {
                                                       'operation' => 'in',
                                                       'options' => [{
                                                                       'name' => 'data',
                                                                       'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
                                                                     }]
                                                     })
  end

  option_to_filter_path[:software].each do |option, filter_path|
    software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

  option_to_filter_path[:software_password].each do |option, filter_path|
    software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

   = softlayer_client[:Account]
   = .object_filter(hardware_object_filter) unless hardware_object_filter.empty?
   = .object_mask("mask[id]")

  case options_hash[:hardware_type]
  when :bare_metal_instance
    hardware_data = .getBareMetalInstances
  when :hardware, nil
    hardware_data = .getHardware
  when :network_hardware
    hardware_data = .getNetworkHardware
  when :router
    hardware_data = .getRouters
  end

  software_passwords = hardware_data.collect do |hardware|
    hardware_service = softlayer_client[:Hardware].object_with_id(hardware['id'])
    hardware_service = hardware_service.object_filter(software_object_filter) unless software_object_filter.empty?
    hardware_service = hardware_service.object_mask("mask[id]")

    software_data    = hardware_service.getSoftwareComponents

    software_data.collect do |software|
      next if software.empty?

      software_service = softlayer_client[:Software_Component].object_with_id(software['id'])
      software_service = software_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
      software_service = software_service.object_mask(SoftwarePassword.default_object_mask)
      software_service = software_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]

      software_passwords_data = software_service.getPasswords
      software_passwords_data.map { |password| SoftwarePassword.new(softlayer_client, password) unless password.empty? }.compact
    end
  end

  software_passwords.flatten
end

.find_passwords_for_software_on_virtual_servers(options_hash = {}) ⇒ Object

Retrieve a list of software passwords from software virtual servers.

The options parameter should contain:

:client - The client used to connect to the API

If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.

You may filter the list returned by adding options:

  • :datacenter (string) - Include software passwords from software on virtual servers matching this datacenter

  • :description (string) - Include software passwords from software that matches this description

  • :domain (string) - Include software passwords from software on virtual servers matching this domain

  • :hostname (string) - Include software passwords from software on virtual servers matching this hostname

  • :manufacturer (string) - Include software passwords from software that matches this manufacturer

  • :name (string) - Include software passwords from software that matches this name

  • :username (string) - Include software passwords for username matching this username

You may use the following properties to provide virtual server or software object filter instances:

  • :virtual_server_object_filter (ObjectFilter) - Include software passwords from software on virtual servers that matches the criteria of this object filter

  • :software_object_filter (ObjectFilter) - Include software passwords from softwarethat matches the criteria of this object filter

  • +:software_password_object_filter* (ObjectFilter) - Include software passwords that match the criteria of this object filter

  • :software_password_object_mask (string) - Include software password properties that matches the criteria of this object mask



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/softlayer/SoftwarePassword.rb', line 453

def self.find_passwords_for_software_on_virtual_servers(options_hash = {})
  softlayer_client = options_hash[:client] || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

  if(options_hash.has_key? :virtual_server_object_filter)
    virtual_server_object_filter = options_hash[:virtual_server_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless virtual_server_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    virtual_server_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_object_filter)
    software_object_filter = options_hash[:software_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_password_object_filter)
    software_password_object_filter = options_hash[:software_password_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_password_object_filter = ObjectFilter.new()
  end

  option_to_filter_path = {
    :software          => {
      :description     => "softwareComponents.softwareDescription.longDescription",
      :manufacturer    => "softwareComponents.softwareDescription.manufacturer",
      :name            => "softwareComponents.softwareDescription.name",
      :username        => "softwareComponents.passwords.username"
    },
    :virtual_server    => {
      :datacenter      => "virtualGuests.datacenter.name",
      :domain          => "virtualGuests.domain",
      :hostname        => "virtualGuests.hostname",
      :tags            => "virtualGuests.tagReferences.tag.name"
    },
    :software_password => {
      :username        => "passwords.username"
    }
  }

  if options_hash[:tags]
    virtual_server_object_filter.set_criteria_for_key_path(option_to_filter_path[:virtual_server][:tags],
                                                            {
                                                              'operation' => 'in',
                                                              'options' => [{
                                                                              'name' => 'data',
                                                                              'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
                                                                            }]
                                                            })
  end

  option_to_filter_path[:virtual_server].each do |option, filter_path|
    next if option == :tags
    virtual_server_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

  option_to_filter_path[:software].each do |option, filter_path|
    software_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

  option_to_filter_path[:software_password].each do |option, filter_path|
    software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

   = softlayer_client[:Account]
   = .object_filter(virtual_server_object_filter) unless virtual_server_object_filter.empty?
   = .object_mask("mask[id]")

  virtual_server_data = .getVirtualGuests

  software_passwords = virtual_server_data.collect do |virtual_server|
    virtual_server_service = softlayer_client[:Virtual_Guest].object_with_id(virtual_server['id'])
    virtual_server_service = virtual_server_service.object_filter(software_object_filter) unless software_object_filter.empty?
    virtual_server_service = virtual_server_service.object_mask("mask[id]")

    software_data          = virtual_server_service.getSoftwareComponents
    software_data.collect do |software| 
      next if software.empty?

      software_service = softlayer_client[:Software_Component].object_with_id(software['id'])
      software_service = software_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
      software_service = software_service.object_mask(SoftwarePassword.default_object_mask)
      software_service = software_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]

      software_passwords_data = software_service.getPasswords
      software_passwords_data.map { |password| SoftwarePassword.new(softlayer_client, password) unless password.empty? }.compact
    end
  end

  software_passwords.flatten
end

.find_passwords_for_vlan_firewalls(options_hash = {}) ⇒ Object

Retrieve a list of software passwords from vlan firewalls management credentials.

The options parameter should contain:

:client - The client used to connect to the API

If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.

You may filter the list returned by adding options:

  • :datacenter (string) - Include software passwords from vlan firewalls matching this datacenter

  • :vlan_name (Array) - Include software passwords from vlans that matches these names

  • :vlan_numbers (Array) - Include software passwords from vlans that matches these numbers

  • :vlan_space (symbol) - Include software passwords from vlans that match this space

  • :vlan_tags (Array) - Include software passwords from vlans that matches these tags

  • :vlan_fw_fqdn (string) - Include software passwords from vlan firewalls that match this fqdn

  • :vlan_fw_tags (Array) - Include software passwords from vlan firewalls that matches these tags

  • :vlan_fw_type (string) - Include software passwords from vlan firewalls that match this type

  • :username (string) - Include software passwords that match this username



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/softlayer/SoftwarePassword.rb', line 163

def self.find_passwords_for_vlan_firewalls(options_hash = {})
  softlayer_client = options_hash[:client] || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

  if(options_hash.has_key? :vlan_object_filter)
    vlan_object_filter = options_hash[:vlan_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless vlan_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    vlan_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :vlan_firewall_object_filter)
    vlan_firewall_object_filter = options_hash[:vlan_firewall_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless vlan_firewall_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    vlan_firewall_object_filter = ObjectFilter.new()
  end

  if(options_hash.has_key? :software_password_object_filter)
    software_password_object_filter = options_hash[:software_password_object_filter]
    raise "Expected an instance of SoftLayer::ObjectFilter" unless software_password_object_filter.kind_of?(SoftLayer::ObjectFilter)
  else
    software_password_object_filter = ObjectFilter.new()
  end

  filter_label = {
    :all     => 'networkVlans',
    :private => 'privateNetworkVlans',
    :public  => 'publicNetworkVlans'
  }

  option_to_filter_path = {
    :software_password => {
      :username        => "managementCredentials.username"
      },
    :vlan_dedicated_fw => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'dedicatedFirewallFlag' ].join  },
    :vlan_names        => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'name' ].join                   },
    :vlan_numbers      => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'vlanNumber' ].join             },
    :vlan_tags         => lambda { |vlan_space| return [ filter_label[vlan_space], '.', 'tagReferences.tag.name' ].join },
    :vlan_firewall     => {
      :vlan_fw_datacenter => "networkVlanFirewall.datacenter.name",
      :vlan_fw_fqdn       => "networkVlanFirewall.fullyQualifiedDomainName",
      :vlan_fw_type       => "networkVlanFirewall.firewallType"
    },
    :vlan_fw_tags      => "networkVlanFirewall.tagReferences.tag.name"
  }

  if options_hash[:vlan_space] && ! filter_label.keys.include?(options_hash[:vlan_space])
    raise "Expected one of :all, :private, or :public for option :vlan_space in #{__method__}"
  end

  option_to_filter_path[:software_password].each do |option, filter_path|
    software_password_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

  vlan_space = options_hash[:vlan_space] || :all

  vlan_object_filter.modify { |filter| filter.accept(option_to_filter_path[:vlan_dedicated_fw].call(vlan_space)).when_it is(1) }
  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]

  [ :vlan_names, :vlan_numbers, :vlan_tags ].each do |option|
    if options_hash[option]
      vlan_object_filter.set_criteria_for_key_path(option_to_filter_path[option].call(vlan_space),
                                                   {
                                                     'operation' => 'in',
                                                     'options' => [{
                                                                     'name' => 'data',
                                                                     'value' => options_hash[option].collect{ |tag_value| tag_value.to_s }
                                                                   }]
                                                 })
    end
  end

  option_to_filter_path[:vlan_firewall].each do |option, filter_path|
    vlan_firewall_object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option]) } if options_hash[option]
  end

  if options_hash[:vlan_fw_tags]
    vlan_firewall_object_filter.set_criteria_for_key_path(option_to_filter_path[:vlan_fw_tags],
                                                          {
                                                            'operation' => 'in',
                                                            'options' => [{
                                                                            'name' => 'data',
                                                                            'value' => options_hash[:vlan_fw_tags].collect{ |tag_value| tag_value.to_s }
                                                                          }]
                                                          })
  end

   = softlayer_client[:Account]
   = .object_filter(vlan_object_filter) unless vlan_object_filter.empty?
   = .object_mask("mask[id]")

  case vlan_space
  when :all
    vlan_data = .getNetworkVlans
  when :private
    vlan_data = .getPrivateNetworkVlans
  when :public
    vlan_data = .getPublicNetworkVlans
  end

  vlan_fw_passwords = vlan_data.collect do |vlan|
    vlan_service = softlayer_client[:Network_Vlan].object_with_id(vlan['id'])
    vlan_service = vlan_service.object_filter(vlan_firewall_object_filter) unless vlan_firewall_object_filter.empty?
    vlan_service = vlan_service.object_mask("mask[id]")

    vlan_fw = vlan_service.getNetworkVlanFirewall

    unless vlan_fw.empty?
      vlan_fw_service = softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_fw['id'])
      vlan_fw_service = vlan_fw_service.object_filter(software_password_object_filter) unless software_password_object_filter.empty?
      vlan_fw_service = vlan_fw_service.object_mask(SoftwarePassword.default_object_mask)
      vlan_fw_service = vlan_fw_service.object_mask(options_hash[:software_password_object_mask]) if options_hash[:software_password_object_mask]

      vlan_fw_password_data = vlan_fw_service.getManagementCredentials
      SoftwarePassword.new(softlayer_client, vlan_fw_password_data) unless vlan_fw_password_data.empty?
    end
  end

  vlan_fw_passwords.compact
end

.update_passwords(passwords, password, options_hash = {}) ⇒ Object

Update the passwords for a list of software passwords

The options parameter should contain:

:client - The client used to connect to the API

If no client is given, then the routine will try to use Client.default_client If no client can be found the routine will raise an error.

Raises:

  • (ArgumentError)


558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'lib/softlayer/SoftwarePassword.rb', line 558

def self.update_passwords(passwords, password, options_hash = {})
  softlayer_client = options_hash[:client] || Client.default_client
  raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client

  raise ArgumentError, "The new password cannot be nil"   unless password
  raise ArgumentError, "The new password cannot be empty" if password.empty?

  if ! passwords.kind_of?(Array) || ! passwords.select { |password| ! password.kind_of?(SoftLayer::SoftwarePassword) }.empty?
    raise ArgumentError, "Expected an array of SoftLayer::SoftwarePassword instances"
  end

  software_password_service = softlayer_client[:Software_Component_Password]
  software_password_service.editObjects(passwords.map { |pw| { 'id' => pw['id'], 'password' => password.to_s } })
end

Instance Method Details

#createdObject

:attr_reader: The date this username/password pair was created.



21
# File 'lib/softlayer/SoftwarePassword.rb', line 21

sl_attr :created, 'createDate'

#modifiedObject

:attr_reader: The date of the last modification to this username/password pair.



26
# File 'lib/softlayer/SoftwarePassword.rb', line 26

sl_attr :modified, 'modifyDate'

#notesObject

:attr_reader: A note string stored for this username/password pair.



31
# File 'lib/softlayer/SoftwarePassword.rb', line 31

sl_attr :notes

#passwordObject

:attr_reader: The password part of the username/password pair.



36
# File 'lib/softlayer/SoftwarePassword.rb', line 36

sl_attr :password

#password=(password) ⇒ Object

Updates the password for the current software user.

Raises:

  • (ArgumentError)


49
50
51
52
53
54
55
# File 'lib/softlayer/SoftwarePassword.rb', line 49

def password=(password)
  raise ArgumentError, "The new password cannot be nil"   unless password
  raise ArgumentError, "The new password cannot be empty" if password.empty?

  self.service.editObject({ "password" => password.to_s })
  self.refresh_details()
end

#portObject

:attr_reader:



40
# File 'lib/softlayer/SoftwarePassword.rb', line 40

sl_attr :port

#serviceObject

Returns the service for interacting with this software component password through the network API



576
577
578
# File 'lib/softlayer/SoftwarePassword.rb', line 576

def service
  softlayer_client[:Software_Component_Password].object_with_id(self.id)
end

#softlayer_properties(object_mask = nil) ⇒ Object

Make an API request to SoftLayer and return the latest properties hash for this object.



584
585
586
587
588
589
590
591
592
593
594
# File 'lib/softlayer/SoftwarePassword.rb', line 584

def softlayer_properties(object_mask = nil)
  my_service = self.service

  if(object_mask)
    my_service = my_service.object_mask(object_mask)
  else
    my_service = my_service.object_mask(self.class.default_object_mask)
  end

  my_service.getObject()
end

#usernameObject

The username part of the username/password pair.



44
# File 'lib/softlayer/SoftwarePassword.rb', line 44

sl_attr :username