Skip to content

Commit c1f1563

Browse files
committed
Update ObjectFilter usage in NetworkStorageCredential to accommodate the new object filters
1 parent 777a971 commit c1f1563

1 file changed

Lines changed: 20 additions & 27 deletions

File tree

lib/softlayer/NetworkStorageCredential.rb

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def name
6161
# If no client can be found the routine will raise an error.
6262
#
6363
# You may filter the list returned by adding options:
64-
# * <b>+:datacenter+</b> (string) - Include network storage account passwords associated with servers matching this datacenter
65-
# * <b>+:domain+</b> (string) - Include network storage account passwords associated with servers matching this domain
66-
# * <b>+:hostname+</b> (string) - Include network storage account passwords associated with servers matching this hostname
67-
# * <b>+:network_storage_server_type+</b> (string) - Include network storage account passwords associated with services of this server type
68-
# * <b>+:network_storage_type+</b> (string) - Include network storage account passwords from devices of this storage type
69-
# * <b>+:service+</b> (string) - Include network storage account passwords from devices with this service fqdn
70-
# * <b>+:tags+</b> (Array) - Include network storage account passwords associated with servers matching these tags
71-
# * <b>+:username+</b> (string) - Include network storage account passwords with this username only
64+
# * <b>+:datacenter+</b> (string/array) - Include network storage account passwords associated with servers matching this datacenter
65+
# * <b>+:domain+</b> (string/array) - Include network storage account passwords associated with servers matching this domain
66+
# * <b>+:hostname+</b> (string/array) - Include network storage account passwords associated with servers matching this hostname
67+
# * <b>+:network_storage_server_type+</b> (string) - Include network storage account passwords associated with services of this server type
68+
# * <b>+:network_storage_type+</b> (string) - Include network storage account passwords from devices of this storage type
69+
# * <b>+:service+</b> (string/array) - Include network storage account passwords from devices with this service fqdn
70+
# * <b>+:tags+</b> (string/array) - Include network storage account passwords associated with servers matching these tags
71+
# * <b>+:username+</b> (string/array) - Include network storage account passwords with this username only
7272
#
7373
def self.find_network_storage_credentials(options_hash = {})
7474
softlayer_client = options_hash[:client] || Client.default_client
@@ -104,11 +104,13 @@ def self.find_network_storage_credentials(options_hash = {})
104104
}
105105

106106
option_to_filter_path = {
107-
:datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
108-
:domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
109-
:hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
110-
:service => lambda { |storage_type| return [ filter_label[storage_type], '.serviceResource.backendIpAddress' ].join },
111-
:tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join },
107+
:network_storage => {
108+
:datacenter => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.datacenter.name' ].join },
109+
:domain => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.domain' ].join },
110+
:hostname => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.hostname' ].join },
111+
:service => lambda { |storage_type| return [ filter_label[storage_type], '.serviceResource.backendIpAddress' ].join },
112+
:tags => lambda { |storage_type, server_type| return [ filter_label[storage_type], '.', filter_label[server_type], '.tagReferences.tag.name' ].join }
113+
},
112114
:network_storage_credential => {
113115
:username => "credentials.username"
114116
}
@@ -124,29 +126,20 @@ def self.find_network_storage_credentials(options_hash = {})
124126

125127
if options_hash[:service]
126128
network_storage_object_filter.modify do |filter|
127-
filter.accept(option_to_filter_path[:service].call(network_storage_type)).when_it is(options_hash[:service])
129+
filter.accept(option_to_filter_path[:network_storage][:service].call(network_storage_type)).when_it is(options_hash[:service])
128130
end
129131
end
130132

131133
if options_hash[:network_storage_server_type]
132-
[ :datacenter, :domain, :hostname ].each do |option|
134+
option_to_filter_path[:network_storage].keys.each do |option|
135+
next if option == :service
136+
133137
if options_hash[option]
134138
network_storage_object_filter.modify do |filter|
135-
filter.accept(option_to_filter_path[option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
139+
filter.accept(option_to_filter_path[:network_storage][option].call(network_storage_type, options_hash[:network_storage_server_type])).when_it is(options_hash[option])
136140
end
137141
end
138142
end
139-
140-
if options_hash[:tags]
141-
network_storage_object_filter.set_criteria_for_key_path(option_to_filter_path[:tags].call(network_storage_type, options_hash[:network_storage_server_type]),
142-
{
143-
'operation' => 'in',
144-
'options' => [{
145-
'name' => 'data',
146-
'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
147-
}]
148-
})
149-
end
150143
end
151144

152145
option_to_filter_path[:network_storage_credential].each do |option, filter_path|

0 commit comments

Comments
 (0)