Class: SoftLayer::NetworkStorageCredential
- Includes:
- DynamicAttribute
- Defined in:
- lib/softlayer/NetworkStorageCredential.rb
Overview
Each SoftLayer NetworkStorageCredential instance provides information on a username/password credential combination used to access a specific Network Storage.
This class roughly corresponds to the entity SoftLayer_Network_Storage_Credential in the API.
Instance Attribute Summary
Attributes inherited from ModelBase
Class Method Summary collapse
-
.find_network_storage_credentials(options_hash = {}) ⇒ Object
Retrieve a list of network storage credentials from all network storage devices.
Instance Method Summary collapse
-
#created ⇒ Object
:attr_reader: created This is the data that the record was created in the table.
-
#created_at ⇒ Object
:attr_reader: created_at This is the data that the record was created in the table.
-
#description ⇒ Object
Returns a description of the Network Storage Credential type.
-
#modified ⇒ Object
:attr_reader: modified This is the date that the record was last updated in the table.
-
#modified_at ⇒ Object
:attr_reader: modified_at This is the date that the record was last updated in the table.
-
#name ⇒ Object
Returns the name of the Network Storage Credential type.
-
#password ⇒ Object
:attr_reader: This is the password associated with the volume.
-
#username ⇒ Object
:attr_reader: This is the username associated with the volume.
Methods included from DynamicAttribute
Methods inherited from ModelBase
#[], #has_sl_property?, #initialize, #refresh_details, #service, sl_attr, #to_ary
Constructor Details
This class inherits a constructor from SoftLayer::ModelBase
Class Method Details
.find_network_storage_credentials(options_hash = {}) ⇒ Object
Retrieve a list of network storage credentials from all network storage 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/array) - Include network storage credentials associated with servers matching this datacenter -
:domain
(string/array) - Include network storage credentials associated with servers matching this domain -
:hostname
(string/array) - Include network storage credentials associated with servers matching this hostname -
:network_storage_server_type
(symbol) - Include network storage credentials associated with services of this server type -
:network_storage_type
(symbol) - Include network storage credentials from devices of this storage type -
:service
(string/array) - Include network storage credentials from devices with this service fqdn -
:tags
(string/array) - Include network storage credentials associated with servers matching these tags -
:username
(string/array) - Include network storage credentials with this username only
Additionally you may provide options related to the request itself:
-
:network_storage_credential_object_filter (ObjectFilter) - Include network storage credentials that match the
criteria of this object filter
-
:network_storage_credential_object_mask (string) - The object mask of properties you wish to receive for the items returned.
If not provided, the result will use the default object mask
-
:network_storage_object_filter (ObjectFilter) - Include network storage credentials from network storage that matches the
criteria of this object filter
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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 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 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 95 def self.find_network_storage_credentials( = {}) softlayer_client = [:client] || Client.default_client raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !softlayer_client if(.has_key? :network_storage_object_filter) network_storage_object_filter = [:network_storage_object_filter] raise "Expected an instance of SoftLayer::ObjectFilter" unless network_storage_object_filter.kind_of?(SoftLayer::ObjectFilter) else network_storage_object_filter = ObjectFilter.new() end if(.has_key? :network_storage_credential_object_filter) network_storage_credential_object_filter = [:network_storage_credential_object_filter] raise "Expected an instance of SoftLayer::ObjectFilter" unless network_storage_credential_object_filter.kind_of?(SoftLayer::ObjectFilter) else network_storage_credential_object_filter = ObjectFilter.new() end if .has_key?(:network_storage_server_type) && ! [ :hardware, :virtual_server ].include?([:network_storage_server_type]) raise "Expected one of :hardware or :virtual_server for :network_storage_server_type option in #{__method__}" end filter_label = { :evault => "evaultNetworkStorage", :hardware => "hardware", :hub => "hubNetworkStorage", :iscsi => "iscsiNetworkStorage", :lockbox => "lockboxNetworkStorage", :nas => "nasNetworkStorage", :network_storage => "networkStorage", :virtual_server => "virtualGuest" } option_to_filter_path = { :network_storage => { :datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join }, :domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join }, :hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join }, :service => lambda { |storage_type| return [ filter_label[storage_type], '.serviceResource.backendIpAddress' ].join }, :tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join } }, :network_storage_credential => { :username => "credentials.username" } } if [:network_storage_type] unless filter_label.select{|label,filter| filter.end_with?("Storage")}.keys.include?([:network_storage_type]) raise "Expected :evault, :hub, :iscsi, :lockbox, :nas or :network_storage for option :network_storage_type in #{__method__}" end end network_storage_type = [:network_storage_type] || :network_storage if [:service] network_storage_object_filter.modify do |filter| filter.accept(option_to_filter_path[:network_storage][:service].call(network_storage_type)).when_it is([:service]) end end if [:network_storage_server_type] option_to_filter_path[:network_storage].keys.each do |option| next if option == :service if [option] network_storage_object_filter.modify do |filter| filter.accept(option_to_filter_path[:network_storage][option].call(network_storage_type, [:network_storage_server_type])).when_it is([option]) end end end end option_to_filter_path[:network_storage_credential].each do |option, filter_path| network_storage_credential_object_filter.modify { |filter| filter.accept(filter_path).when_it is([option]) } if [option] end account_service = softlayer_client[:Account] account_service = account_service.object_filter(network_storage_object_filter) unless network_storage_object_filter.empty? account_service = account_service.object_mask("mask[id]") case [:network_storage_type] when :evault network_storage_data = account_service.getEvaultNetworkStorage when :hub network_storage_data = account_service.getHubNetworkStorage when :iscsi network_storage_data = account_service.getIscsiNetworkStorage when :lockbox network_storage_data = account_service.getLockboxNetworkStorage when :nas network_storage_data = account_service.getNasNetworkStorage when :network_storage, nil network_storage_data = account_service.getNetworkStorage end network_storage_credentials = network_storage_data.collect do |network_storage| network_storage_service = softlayer_client[:Network_Storage].object_with_id(network_storage['id']) network_storage_service = network_storage_service.object_filter(network_storage_credential_object_filter) unless network_storage_credential_object_filter.empty? network_storage_service = network_storage_service.object_mask(NetworkStorageCredential.default_object_mask) network_storage_service = network_storage_service.object_mask([:network_storage_credential_object_mask]) if [:network_storage_credential_object_mask] network_storage_credentials_data = network_storage_service.getCredentials network_storage_credentials_data.map { |credential| NetworkStorageCredential.new(softlayer_client, credential) unless credential.empty? }.compact end network_storage_credentials.flatten end |
Instance Method Details
#created ⇒ Object
:attr_reader: created This is the data that the record was created in the table. DEPRECATION WARNING: This attribute is deprecated in favor of created_at and will be removed in the next major release.
29 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 29 sl_attr :created, 'createDate' |
#created_at ⇒ Object
:attr_reader: created_at This is the data that the record was created in the table.
22 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 22 sl_attr :created_at, 'createDate' |
#description ⇒ Object
Returns a description of the Network Storage Credential type
56 57 58 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 56 def description self['type']['description'] end |
#modified ⇒ Object
:attr_reader: modified This is the date that the record was last updated in the table. DEPRECATION WARNING: This attribute is deprecated in favor of modified_at and will be removed in the next major release.
41 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 41 sl_attr :modified, 'modifyDate' |
#modified_at ⇒ Object
:attr_reader: modified_at This is the date that the record was last updated in the table.
34 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 34 sl_attr :modified_at, 'modifyDate' |
#name ⇒ Object
Returns the name of the Network Storage Credential type
63 64 65 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 63 def name self['type']['name'] end |
#password ⇒ Object
:attr_reader: This is the password associated with the volume.
46 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 46 sl_attr :password |
#username ⇒ Object
:attr_reader: This is the username associated with the volume.
51 |
# File 'lib/softlayer/NetworkStorageCredential.rb', line 51 sl_attr :username |