зеркало из https://github.com/github/fog.git
Standardise on collection methods
Done with `rubocop --auto-correct --only CollectionMethods`
This commit is contained in:
Родитель
814cb82f22
Коммит
ec8b940b2c
|
@ -23,7 +23,7 @@ module Fog
|
|||
files = data[:DirectoryEntry].select {|de| de[:FileType] == 'regular'}
|
||||
files.each do |s|
|
||||
data = service.head_namespace(directory.key + s[:Filename], :parse => false)
|
||||
headers = Hash[data.headers["x-emc-meta"].split(", ").collect{|s|s.split("=")}]
|
||||
headers = Hash[data.headers["x-emc-meta"].split(", ").map{|s|s.split("=")}]
|
||||
s[:content_length] = data.headers["Content-Length"]
|
||||
s[:content_type] = data.headers["Content-Type"]
|
||||
s[:created_at] = headers["ctime"]
|
||||
|
|
|
@ -161,7 +161,7 @@ module Fog
|
|||
|
||||
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-supported-platforms.html
|
||||
def supported_platforms
|
||||
describe_account_attributes.body["accountAttributeSet"].detect{ |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
describe_account_attributes.body["accountAttributeSet"].find{ |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -299,7 +299,7 @@ module Fog
|
|||
end
|
||||
|
||||
def visible_images
|
||||
images = self.data[:images].values.inject({}) do |h, image|
|
||||
images = self.data[:images].values.reduce({}) do |h, image|
|
||||
h.update(image['imageId'] => image)
|
||||
end
|
||||
|
||||
|
@ -315,7 +315,7 @@ module Fog
|
|||
end
|
||||
|
||||
def supported_platforms
|
||||
describe_account_attributes.body["accountAttributeSet"].detect{ |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
describe_account_attributes.body["accountAttributeSet"].find{ |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
end
|
||||
|
||||
def enable_ec2_classic
|
||||
|
@ -327,7 +327,7 @@ module Fog
|
|||
end
|
||||
|
||||
def set_supported_platforms(values)
|
||||
self.data[:account_attributes].detect { |h| h["attributeName"] == "supported-platforms" }["values"] = values
|
||||
self.data[:account_attributes].find { |h| h["attributeName"] == "supported-platforms" }["values"] = values
|
||||
end
|
||||
|
||||
def apply_tag_filters(resources, filters, resource_id_key)
|
||||
|
|
|
@ -69,7 +69,7 @@ module Fog
|
|||
|
||||
def self.indexed_request_param(name, values)
|
||||
idx = -1
|
||||
Array(values).inject({}) do |params, value|
|
||||
Array(values).reduce({}) do |params, value|
|
||||
params["#{name}.#{idx += 1}"] = value
|
||||
params
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ module Fog
|
|||
|
||||
def reduce_digests(digests)
|
||||
while digests.length > 1
|
||||
digests = digests.each_slice(2).collect do |pair|
|
||||
digests = digests.each_slice(2).map do |pair|
|
||||
if pair.length == 2
|
||||
Digest::SHA256.digest(pair[0]+pair[1])
|
||||
else
|
||||
|
@ -67,13 +67,13 @@ module Fog
|
|||
def digest_for_part(body)
|
||||
chunk_count = [body.bytesize / MEGABYTE + (body.bytesize % MEGABYTE > 0 ? 1 : 0), 1].max
|
||||
if body.respond_to? :byteslice
|
||||
digests_for_part = chunk_count.times.collect {|chunk_index| Digest::SHA256.digest(body.byteslice(chunk_index * MEGABYTE, MEGABYTE))}
|
||||
digests_for_part = chunk_count.times.map {|chunk_index| Digest::SHA256.digest(body.byteslice(chunk_index * MEGABYTE, MEGABYTE))}
|
||||
else
|
||||
if body.respond_to? :encoding
|
||||
old_encoding = body.encoding
|
||||
body.force_encoding('BINARY')
|
||||
end
|
||||
digests_for_part = chunk_count.times.collect {|chunk_index| Digest::SHA256.digest(body.slice(chunk_index * MEGABYTE, MEGABYTE))}
|
||||
digests_for_part = chunk_count.times.map {|chunk_index| Digest::SHA256.digest(body.slice(chunk_index * MEGABYTE, MEGABYTE))}
|
||||
if body.respond_to? :encoding
|
||||
body.force_encoding(old_encoding)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
def get(namespace, metric_name, dimensions=nil, period=nil, statistic=nil, unit=nil)
|
||||
list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
|
||||
if dimensions
|
||||
dimensions_array = dimensions.collect do |name, value|
|
||||
dimensions_array = dimensions.map do |name, value|
|
||||
{'Name' => name, 'Value' => value}
|
||||
end
|
||||
list_opts.merge!('Dimensions' => dimensions_array)
|
||||
|
|
|
@ -13,7 +13,7 @@ module Fog
|
|||
dimensions = conditions['Dimensions']
|
||||
get_metric_opts = {"StartTime" => (Time.now-3600).iso8601, "EndTime" => Time.now.iso8601, "Period" => 300}.merge(conditions)
|
||||
data = service.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints']
|
||||
data.collect! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) }
|
||||
data.map! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) }
|
||||
load(data) # data is an array of attribute hashes
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
|||
def get(namespace, metric_name, dimensions=nil)
|
||||
list_opts = {'Namespace' => namespace, 'MetricName' => metric_name}
|
||||
if dimensions
|
||||
dimensions_array = dimensions.collect do |name, value|
|
||||
dimensions_array = dimensions.map do |name, value|
|
||||
{'Name' => name, 'Value' => value}
|
||||
end
|
||||
# list_opts.merge!('Dimensions' => dimensions_array)
|
||||
|
|
|
@ -518,7 +518,7 @@ module Fog
|
|||
#
|
||||
|
||||
def get(flavor_id)
|
||||
self.class.new(:service => service).all.detect {|flavor| flavor.id == flavor_id}
|
||||
self.class.new(:service => service).all.find {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ module Fog
|
|||
service.deregister_image(id)
|
||||
|
||||
if(delete_snapshot && root_device_type == "ebs")
|
||||
block_device = block_device_mapping.detect {|block_device| block_device['deviceName'] == root_device_name}
|
||||
block_device = block_device_mapping.find {|block_device| block_device['deviceName'] == root_device_name}
|
||||
service.snapshots.new(:id => block_device['snapshotId']).destroy
|
||||
else
|
||||
true
|
||||
|
|
|
@ -133,7 +133,7 @@ module Fog
|
|||
requires :network_acl_id
|
||||
|
||||
# We have to manually find out the network ACL the subnet is currently associated with
|
||||
old_id = service.network_acls.all('association.subnet-id' => subnet.subnet_id).first.associations.detect { |a| a['subnetId'] == subnet.subnet_id }['networkAclAssociationId']
|
||||
old_id = service.network_acls.all('association.subnet-id' => subnet.subnet_id).first.associations.find { |a| a['subnetId'] == subnet.subnet_id }['networkAclAssociationId']
|
||||
service.replace_network_acl_association(old_id, network_acl_id)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -116,7 +116,7 @@ module Fog
|
|||
end
|
||||
|
||||
def flavor
|
||||
@flavor ||= service.flavors.all.detect {|flavor| flavor.id == flavor_id}
|
||||
@flavor ||= service.flavors.all.find {|flavor| flavor.id == flavor_id}
|
||||
end
|
||||
|
||||
def key_pair
|
||||
|
|
|
@ -91,7 +91,7 @@ module Fog
|
|||
end
|
||||
|
||||
# make sure port 22 is open in the first security group
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
authorized = security_group.ip_permissions.find do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
ip_permission['ipProtocol'] == 'tcp' &&
|
||||
|
|
|
@ -49,7 +49,7 @@ module Fog
|
|||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = service.security_groups.get(spot_request.groups.first)
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
authorized = security_group.ip_permissions.find do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
ip_permission['ipProtocol'] == 'tcp' &&
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(instance_port)
|
||||
all.detect{|e| e.instance_port == instance_port}
|
||||
all.find{|e| e.instance_port == instance_port}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get(lb_port)
|
||||
all.detect{|listener| listener.lb_port == lb_port}
|
||||
all.find{|listener| listener.lb_port == lb_port}
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -12,12 +12,12 @@ module Fog
|
|||
end
|
||||
|
||||
def get(id)
|
||||
all.detect{|policy| id == policy.id}
|
||||
all.find{|policy| id == policy.id}
|
||||
end
|
||||
|
||||
private
|
||||
def munged_data
|
||||
data.inject([]){|m,e|
|
||||
data.reduce([]){|m,e|
|
||||
policy_attribute_descriptions = e["PolicyAttributeDescriptions"]
|
||||
|
||||
policy = {
|
||||
|
@ -28,10 +28,10 @@ module Fog
|
|||
|
||||
case e["PolicyTypeName"]
|
||||
when 'AppCookieStickinessPolicyType'
|
||||
cookie_name = policy_attribute_descriptions.detect{|h| h['AttributeName'] == 'CookieName'}['AttributeValue']
|
||||
cookie_name = policy_attribute_descriptions.find{|h| h['AttributeName'] == 'CookieName'}['AttributeValue']
|
||||
policy['CookieName'] = cookie_name if cookie_name
|
||||
when 'LBCookieStickinessPolicyType'
|
||||
cookie_expiration_period = policy_attribute_descriptions.detect{|h| h['AttributeName'] == 'CookieExpirationPeriod'}['AttributeValue'].to_i
|
||||
cookie_expiration_period = policy_attribute_descriptions.find{|h| h['AttributeName'] == 'CookieExpirationPeriod'}['AttributeValue'].to_i
|
||||
policy['CookieExpirationPeriod'] = cookie_expiration_period if cookie_expiration_period > 0
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ module Fog
|
|||
end
|
||||
|
||||
def policy_attributes(policy_attribute_descriptions)
|
||||
policy_attribute_descriptions.inject({}){|m,e|
|
||||
policy_attribute_descriptions.reduce({}){|m,e|
|
||||
m[e["AttributeName"]] = e["AttributeValue"]
|
||||
m
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
end
|
||||
|
||||
def modify(changes)
|
||||
service.modify_db_parameter_group id, changes.collect {|c| {'ParameterName' => c[:name], 'ParameterValue' => c[:value], 'ApplyMethod' => c[:apply_method]}}
|
||||
service.modify_db_parameter_group id, changes.map {|c| {'ParameterName' => c[:name], 'ParameterValue' => c[:value], 'ApplyMethod' => c[:apply_method]}}
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -78,7 +78,7 @@ module Fog
|
|||
|
||||
def public_url
|
||||
requires :key
|
||||
if service.get_bucket_acl(key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
||||
if service.get_bucket_acl(key).body['AccessControlList'].find {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
||||
service.request_url(
|
||||
:bucket_name => key
|
||||
)
|
||||
|
|
|
@ -150,7 +150,7 @@ module Fog
|
|||
#
|
||||
def public_url
|
||||
requires :directory, :key
|
||||
if service.get_object_acl(directory.key, key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
||||
if service.get_object_acl(directory.key, key).body['AccessControlList'].find {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
||||
service.request_url(
|
||||
:bucket_name => directory.key,
|
||||
:object_name => key
|
||||
|
|
|
@ -24,8 +24,8 @@ module Fog
|
|||
|
||||
def describe_alarms_for_metric(options)
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.map {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.map {|dimension| dimension['Value']}))
|
||||
end
|
||||
request({
|
||||
'Action' => 'DescribeAlarmsForMetric',
|
||||
|
|
|
@ -31,8 +31,8 @@ module Fog
|
|||
options.merge!(AWS.indexed_param('Statistics.member.%d', [*statistics]))
|
||||
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.map {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.map {|dimension| dimension['Value']}))
|
||||
end
|
||||
|
||||
request({
|
||||
|
|
|
@ -21,8 +21,8 @@ module Fog
|
|||
#
|
||||
def list_metrics(options={})
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.map {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.map {|dimension| dimension['Value']}))
|
||||
end
|
||||
|
||||
request({
|
||||
|
|
|
@ -32,8 +32,8 @@ module Fog
|
|||
#
|
||||
def put_metric_alarm(options)
|
||||
if dimensions = options.delete('Dimensions')
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.map {|dimension| dimension['Name']}))
|
||||
options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.map {|dimension| dimension['Value']}))
|
||||
end
|
||||
if alarm_actions = options.delete('AlarmActions')
|
||||
options.merge!(AWS.indexed_param('AlarmActions.member.%d', [*alarm_actions]))
|
||||
|
|
|
@ -31,15 +31,15 @@ module Fog
|
|||
options = {'Namespace' => namespace}
|
||||
|
||||
#first index the dimensions for any of the datums that have dimensions
|
||||
metric_data.collect! do |metric_datum|
|
||||
metric_data.map! do |metric_datum|
|
||||
if dimensions = metric_datum.delete('Dimensions')
|
||||
metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']}))
|
||||
metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']}))
|
||||
metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.map {|dimension| dimension['Name']}))
|
||||
metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.map {|dimension| dimension['Value']}))
|
||||
end
|
||||
metric_datum
|
||||
end
|
||||
#then flatten out an hashes in the metric_data array
|
||||
metric_data.collect! { |metric_datum| flatten_hash(metric_datum) }
|
||||
metric_data.map! { |metric_datum| flatten_hash(metric_datum) }
|
||||
#then index the metric_data array
|
||||
options.merge!(AWS.indexed_param('MetricData.member.%d', [*metric_data]))
|
||||
#then finally flatten out an hashes in the overall options array
|
||||
|
|
|
@ -214,7 +214,7 @@ module Fog
|
|||
end
|
||||
|
||||
def find_matching_permission(group, permission)
|
||||
group['ipPermissions'].detect {|group_permission|
|
||||
group['ipPermissions'].find {|group_permission|
|
||||
permission['ipProtocol'] == group_permission['ipProtocol'] &&
|
||||
permission['fromPort'] == group_permission['fromPort'] &&
|
||||
permission['toPort'] == group_permission['toPort'] }
|
||||
|
|
|
@ -53,7 +53,7 @@ module Fog
|
|||
if vpcId
|
||||
id = Fog::AWS::Mock.network_acl_id
|
||||
|
||||
unless self.data[:vpcs].detect { |s| s['vpcId'] == vpcId }
|
||||
unless self.data[:vpcs].find { |s| s['vpcId'] == vpcId }
|
||||
raise Fog::Compute::AWS::Error.new("Unknown VPC '#{vpcId}' specified")
|
||||
end
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
if self.data[:network_acls][network_acl_id]
|
||||
|
||||
if self.data[:network_acls][network_acl_id]['entrySet'].detect { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
if self.data[:network_acls][network_acl_id]['entrySet'].find { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
raise Fog::Compute::AWS::Error.new("Already a rule with that number")
|
||||
end
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ module Fog
|
|||
|
||||
# Add this subnet to the default network ACL
|
||||
accid = Fog::AWS::Mock.network_acl_association_id
|
||||
default_nacl = self.data[:network_acls].values.detect { |nacl| nacl['vpcId'] == vpcId && nacl['default'] }
|
||||
default_nacl = self.data[:network_acls].values.find { |nacl| nacl['vpcId'] == vpcId && nacl['default'] }
|
||||
default_nacl['associationSet'] << {
|
||||
'networkAclAssociationId' => accid,
|
||||
'networkAclId' => default_nacl['networkAclId'],
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
def delete_network_acl_entry(network_acl_id, rule_number, egress)
|
||||
response = Excon::Response.new
|
||||
if self.data[:network_acls][network_acl_id]
|
||||
if self.data[:network_acls][network_acl_id]['entrySet'].detect { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
if self.data[:network_acls][network_acl_id]['entrySet'].find { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
self.data[:network_acls][network_acl_id]['entrySet'].delete_if { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
else
|
||||
raise Fog::Compute::AWS::Error.new("No rule with that number and egress value")
|
||||
|
|
|
@ -139,7 +139,7 @@ module Fog
|
|||
for filter_key, filter_value in filters
|
||||
if block_device_mapping_key = filter_key.split('block-device-mapping.')[1]
|
||||
aliased_key = block_device_mapping_aliases[block_device_mapping_key]
|
||||
instance_set = instance_set.reject{|instance| !instance['blockDeviceMapping'].detect {|block_device_mapping| [*filter_value].include?(block_device_mapping[aliased_key])}}
|
||||
instance_set = instance_set.reject{|instance| !instance['blockDeviceMapping'].find {|block_device_mapping| [*filter_value].include?(block_device_mapping[aliased_key])}}
|
||||
elsif instance_state_key = filter_key.split('instance-state-')[1]
|
||||
aliased_key = instance_state_aliases[instance_state_key]
|
||||
instance_set = instance_set.reject{|instance| ![*filter_value].include?(instance['instanceState'][aliased_key])}
|
||||
|
@ -158,7 +158,7 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
brand_new_instances = instance_set.find_all do |instance|
|
||||
brand_new_instances = instance_set.select do |instance|
|
||||
instance['instanceState']['name'] == 'pending' &&
|
||||
Time.now - instance['launchTime'] < Fog::Mock.delay * 2
|
||||
end
|
||||
|
|
|
@ -76,14 +76,14 @@ module Fog
|
|||
filter_key = filter_key.to_s
|
||||
if association_key = filter_key.split('association.')[1]
|
||||
aliased_key = association_aliases[association_key]
|
||||
network_acls = network_acls.reject{|nacl| !nacl['associationSet'].detect {|association| [*filter_value].include?(association[aliased_key])}}
|
||||
network_acls = network_acls.reject{|nacl| !nacl['associationSet'].find {|association| [*filter_value].include?(association[aliased_key])}}
|
||||
elsif entry_key = filter_key.split('entry.icmp.')[1]
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].detect {|association| [*filter_value].include?(association['icmpTypeCode'][entry_key])}}
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].find {|association| [*filter_value].include?(association['icmpTypeCode'][entry_key])}}
|
||||
elsif entry_key = filter_key.split('entry.port-range.')[1]
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].detect {|association| [*filter_value].include?(association['portRange'][entry_key])}}
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].find {|association| [*filter_value].include?(association['portRange'][entry_key])}}
|
||||
elsif entry_key = filter_key.split('entry.')[1]
|
||||
aliased_key = entry_aliases[entry_key]
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].detect {|association| [*filter_value].include?(association[aliased_key])}}
|
||||
network_acls = network_acls.reject{|nacl| !nacl['entrySet'].find {|association| [*filter_value].include?(association[aliased_key])}}
|
||||
else
|
||||
aliased_key = aliases[filter_key]
|
||||
network_acls = network_acls.reject{|nacl| ![*filter_value].include?(nacl[aliased_key])}
|
||||
|
|
|
@ -70,14 +70,14 @@ module Fog
|
|||
for filter_key, filter_value in filters
|
||||
if permission_key = filter_key.split('ip-permission.')[1]
|
||||
if permission_key == 'group-name'
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).detect {|group| [*filter_value].include?(group['groupName'])}}
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).find {|group| [*filter_value].include?(group['groupName'])}}
|
||||
elsif permission_key == 'group-id'
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).detect {|group| [*filter_value].include?(group['groupId'])}}
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).find {|group| [*filter_value].include?(group['groupId'])}}
|
||||
elsif permission_key == 'user-id'
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).detect {|group| [*filter_value].include?(group['userId'])}}
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group_groups.call(security_group).find {|group| [*filter_value].include?(group['userId'])}}
|
||||
else
|
||||
aliased_key = permission_aliases[filter_key]
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions'].detect {|permission| [*filter_value].include?(permission[aliased_key])}}
|
||||
security_group_info = security_group_info.reject{|security_group| !security_group['ipPermissions'].find {|permission| [*filter_value].include?(permission[aliased_key])}}
|
||||
end
|
||||
else
|
||||
aliased_key = aliases[filter_key]
|
||||
|
|
|
@ -91,7 +91,7 @@ module Fog
|
|||
def deep_clone(obj)
|
||||
case obj
|
||||
when Hash
|
||||
obj.inject({}) { |h, pair| h[pair.first] = deep_clone(pair.last); h }
|
||||
obj.reduce({}) { |h, pair| h[pair.first] = deep_clone(pair.last); h }
|
||||
when Array
|
||||
obj.map { |o| deep_clone(o) }
|
||||
else
|
||||
|
|
|
@ -77,7 +77,7 @@ module Fog
|
|||
for filter_key, filter_value in filters
|
||||
if attachment_key = filter_key.split('attachment.')[1]
|
||||
aliased_key = attachment_aliases[filter_key]
|
||||
volume_set = volume_set.reject{|volume| !volume['attachmentSet'].detect {|attachment| [*filter_value].include?(attachment[aliased_key])}}
|
||||
volume_set = volume_set.reject{|volume| !volume['attachmentSet'].find {|attachment| [*filter_value].include?(attachment[aliased_key])}}
|
||||
else
|
||||
aliased_key = aliases[filter_key]
|
||||
volume_set = volume_set.reject{|volume| ![*filter_value].include?(volume[aliased_key])}
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids}' does not exist")
|
||||
end
|
||||
end
|
||||
instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'enabled'} }
|
||||
instances_set = [*instance_ids].reduce([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'enabled'} }
|
||||
response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
|
||||
response
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ module Fog
|
|||
def release_address(public_ip_or_allocation_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
address = self.data[:addresses][public_ip_or_allocation_id] || self.data[:addresses].values.detect {|a| a['allocationId'] == public_ip_or_allocation_id }
|
||||
address = self.data[:addresses][public_ip_or_allocation_id] || self.data[:addresses].values.find {|a| a['allocationId'] == public_ip_or_allocation_id }
|
||||
|
||||
if address
|
||||
if address['allocationId'] && public_ip_or_allocation_id == address['publicIp']
|
||||
|
|
|
@ -32,15 +32,15 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
if self.data[:network_acls][network_acl_id]
|
||||
# find the old assoc
|
||||
old_nacl = self.data[:network_acls].values.detect do |n|
|
||||
n['associationSet'].detect { |assoc| assoc['networkAclAssociationId'] == association_id }
|
||||
old_nacl = self.data[:network_acls].values.find do |n|
|
||||
n['associationSet'].find { |assoc| assoc['networkAclAssociationId'] == association_id }
|
||||
end
|
||||
|
||||
unless old_nacl
|
||||
raise Fog::Compute::AWS::Error.new("Invalid association_id #{association_id}")
|
||||
end
|
||||
|
||||
subnet_id = old_nacl['associationSet'].detect { |assoc| assoc['networkAclAssociationId'] == association_id }['subnetId']
|
||||
subnet_id = old_nacl['associationSet'].find { |assoc| assoc['networkAclAssociationId'] == association_id }['subnetId']
|
||||
old_nacl['associationSet'].delete_if { |assoc| assoc['networkAclAssociationId'] == association_id }
|
||||
|
||||
id = Fog::AWS::Mock.network_acl_association_id
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
response = Excon::Response.new
|
||||
if self.data[:network_acls][network_acl_id]
|
||||
|
||||
unless self.data[:network_acls][network_acl_id]['entrySet'].detect { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
unless self.data[:network_acls][network_acl_id]['entrySet'].find { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
raise Fog::Compute::AWS::Error.new("No rule with that number")
|
||||
end
|
||||
self.data[:network_acls][network_acl_id]['entrySet'].delete_if { |r| r['ruleNumber'] == rule_number && r['egress'] == egress }
|
||||
|
|
|
@ -164,7 +164,7 @@ module Fog
|
|||
instance_id = Fog::AWS::Mock.instance_id
|
||||
availability_zone = options['Placement.AvailabilityZone'] || Fog::AWS::Mock.availability_zone(@region)
|
||||
|
||||
block_device_mapping = (options['BlockDeviceMapping'] || []).inject([]) do |mapping, device|
|
||||
block_device_mapping = (options['BlockDeviceMapping'] || []).reduce([]) do |mapping, device|
|
||||
device_name = device.fetch("DeviceName", "/dev/sda1")
|
||||
volume_size = device.fetch("Ebs.VolumeSize", 15) # @todo should pull this from the image
|
||||
delete_on_termination = device.fetch("Ebs.DeleteOnTermination", true) # @todo should pull this from the image
|
||||
|
@ -192,7 +192,7 @@ module Fog
|
|||
network_interface_id = create_network_interface(options['SubnetId'], ni_options).body['networkInterface']['networkInterfaceId']
|
||||
end
|
||||
|
||||
network_interfaces = (options['NetworkInterfaces'] || []).inject([]) do |mapping, device|
|
||||
network_interfaces = (options['NetworkInterfaces'] || []).reduce([]) do |mapping, device|
|
||||
device_index = device.fetch("DeviceIndex", 0)
|
||||
subnet_id = device.fetch("SubnetId", options[:subnet_id] || Fog::AWS::Mock.subnet_id)
|
||||
private_ip_address = device.fetch("PrivateIpAddress", options[:private_ip_address] || Fog::AWS::Mock.private_ip_address)
|
||||
|
|
|
@ -32,7 +32,7 @@ module Fog
|
|||
|
||||
instance_set = self.data[:instances].values
|
||||
instance_set = apply_tag_filters(instance_set, {'instance_id' => instance_ids}, 'instanceId')
|
||||
instance_set = instance_set.find_all {|x| instance_ids.include?(x["instanceId"]) }
|
||||
instance_set = instance_set.select {|x| instance_ids.include?(x["instanceId"]) }
|
||||
|
||||
if instance_set.empty?
|
||||
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids.first}' does not exist")
|
||||
|
@ -41,7 +41,7 @@ module Fog
|
|||
response.status = 200
|
||||
|
||||
response.body = {
|
||||
'instancesSet' => instance_set.inject([]) do |ia, instance|
|
||||
'instancesSet' => instance_set.reduce([]) do |ia, instance|
|
||||
ia << {'currentState' => { 'code' => 0, 'name' => 'pending' },
|
||||
'previousState' => instance['instanceState'],
|
||||
'instanceId' => instance['instanceId'] }
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
instance_set = self.data[:instances].values
|
||||
instance_set = apply_tag_filters(instance_set, {'instance_id' => instance_ids}, 'instanceId')
|
||||
instance_set = instance_set.find_all {|x| instance_ids.include?(x["instanceId"]) }
|
||||
instance_set = instance_set.select {|x| instance_ids.include?(x["instanceId"]) }
|
||||
|
||||
if instance_set.empty?
|
||||
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids.first}' does not exist")
|
||||
|
@ -42,7 +42,7 @@ module Fog
|
|||
response.status = 200
|
||||
|
||||
response.body = {
|
||||
'instancesSet' => instance_set.inject([]) do |ia, instance|
|
||||
'instancesSet' => instance_set.reduce([]) do |ia, instance|
|
||||
ia << {'currentState' => { 'code' => 0, 'name' => 'stopping' },
|
||||
'previousState' => instance['instanceState'],
|
||||
'instanceId' => instance['instanceId'] }
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids}' does not exist")
|
||||
end
|
||||
end
|
||||
instances_set = [*instance_ids].inject([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'disabled'} }
|
||||
instances_set = [*instance_ids].reduce([]) { |memo, id| memo << {'instanceId' => id, 'monitoring' => 'disabled'} }
|
||||
response.body = {'requestId' => 'some_request_id', 'instancesSet' => instances_set}
|
||||
response
|
||||
end
|
||||
|
|
|
@ -59,7 +59,7 @@ module Fog
|
|||
name = name + "." unless name.end_with?(".")
|
||||
|
||||
response = Excon::Response.new
|
||||
if list_hosted_zones.body['HostedZones'].find_all {|z| z['Name'] == name}.size < self.data[:limits][:duplicate_domains]
|
||||
if list_hosted_zones.body['HostedZones'].select {|z| z['Name'] == name}.size < self.data[:limits][:duplicate_domains]
|
||||
response.status = 201
|
||||
if options[:caller_ref]
|
||||
caller_ref = options[:caller_ref]
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
if sec_group = self.data[:security_groups][name]
|
||||
|
||||
if sec_group['EC2SecurityGroups'].detect{|h| h['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']}
|
||||
if sec_group['EC2SecurityGroups'].find{|h| h['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']}
|
||||
raise Fog::AWS::Elasticache::AuthorizationAlreadyExists.new("AuthorizationAlreadyExists => #{opts['EC2SecurityGroupName']} is alreay defined")
|
||||
end
|
||||
sec_group['EC2SecurityGroups'] << opts.merge({'Status' => 'authorizing'})
|
||||
|
|
|
@ -28,7 +28,7 @@ module Fog
|
|||
# Construct Cache Security Group parameters in the format:
|
||||
# CacheSecurityGroupNames.member.N => "security_group_name"
|
||||
group_names = options[:security_group_names] || []
|
||||
sec_group_params = group_names.inject({}) do |group_hash, name|
|
||||
sec_group_params = group_names.reduce({}) do |group_hash, name|
|
||||
index = group_names.index(name) + 1
|
||||
group_hash["CacheSecurityGroupNames.member.#{index}"] = name
|
||||
group_hash
|
||||
|
@ -36,7 +36,7 @@ module Fog
|
|||
# Construct CacheNodeIdsToRemove parameters in the format:
|
||||
# CacheNodeIdsToRemove.member.N => "node_id"
|
||||
node_ids = options[:nodes_to_remove] || []
|
||||
node_id_params = node_ids.inject({}) do |node_hash, node_id|
|
||||
node_id_params = node_ids.reduce({}) do |node_hash, node_id|
|
||||
index = node_ids.index(node_id) + 1
|
||||
node_hash["CacheNodeIdsToRemove.member.#{index}"] = node_id
|
||||
node_hash
|
||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
# ParameterNameValues.member.N.ParameterName => "param_name"
|
||||
# ParameterNameValues.member.N.ParameterValue => "param_value"
|
||||
n = 0 # n is the parameter index
|
||||
parameter_changes = new_parameters.inject({}) do |new_args,pair|
|
||||
parameter_changes = new_parameters.reduce({}) do |new_args,pair|
|
||||
n += 1
|
||||
new_args["ParameterNameValues.member.#{n}.ParameterName"] = pair[0]
|
||||
new_args["ParameterNameValues.member.#{n}.ParameterValue"] = pair[1]
|
||||
|
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
# Construct CacheNodeIdsToReboot parameters in the format:
|
||||
# CacheNodeIdsToReboot.member.N => "node_id"
|
||||
node_ids = nodes_to_reboot || []
|
||||
node_id_params = node_ids.inject({}) do |node_hash, node_id|
|
||||
node_id_params = node_ids.reduce({}) do |node_hash, node_id|
|
||||
index = node_ids.index(node_id) + 1
|
||||
node_hash["CacheNodeIdsToReboot.member.#{index}"] = node_id
|
||||
node_hash
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
def reset_cache_parameter_group(id, parameter_names = [])
|
||||
# Construct Parameter resets in the format:
|
||||
# ParameterNameValues.member.N => "param_name"
|
||||
parameter_changes = parameter_names.inject({}) do |new_args, param|
|
||||
parameter_changes = parameter_names.reduce({}) do |new_args, param|
|
||||
index = parameter_names.index(param) + 1
|
||||
new_args["ParameterNameValues.member.#{index}"] = param
|
||||
new_args
|
||||
|
|
|
@ -75,7 +75,7 @@ module Fog
|
|||
|
||||
availability_zones = [*availability_zones].compact
|
||||
region = availability_zones.empty? ? "us-east-1" : availability_zones.first.gsub(/[a-z]$/, '')
|
||||
supported_platforms = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:account_attributes].detect { |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
supported_platforms = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:account_attributes].find { |h| h["attributeName"] == "supported-platforms" }["values"]
|
||||
subnet_ids = options[:subnet_ids] || []
|
||||
subnets = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:subnets].select {|e| subnet_ids.include?(e["subnetId"]) }
|
||||
|
||||
|
@ -103,7 +103,7 @@ module Fog
|
|||
vpc = Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.0.0/24')
|
||||
end
|
||||
|
||||
default_sg = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.detect { |sg|
|
||||
default_sg = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.find { |sg|
|
||||
sg['groupName'] =~ /^default_elb/ &&
|
||||
sg["vpcId"] == vpc.id
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ module Fog
|
|||
when 'EC2-VPC'
|
||||
# find or create default vpc security group
|
||||
vpc_id = subnets.first["vpcId"]
|
||||
default_sg = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.detect { |sg|
|
||||
default_sg = Fog::Compute::AWS::Mock.data[region][@aws_access_key_id][:security_groups].values.find { |sg|
|
||||
sg['groupName'] == 'default' &&
|
||||
sg["vpcId"] == vpc_id
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
|||
raise Fog::AWS::ELB::NotFound unless load_balancer = self.data[:load_balancers][lb_name]
|
||||
|
||||
instance_ids = [*instance_ids]
|
||||
instance_ids = load_balancer['Instances'].collect { |i| i['InstanceId'] } unless instance_ids.any?
|
||||
instance_ids = load_balancer['Instances'].map { |i| i['InstanceId'] } unless instance_ids.any?
|
||||
data = instance_ids.map do |id|
|
||||
unless Fog::Compute::AWS::Mock.data[@region][@aws_access_key_id][:instances][id]
|
||||
raise Fog::AWS::ELB::InvalidInstance
|
||||
|
|
|
@ -103,13 +103,13 @@ module Fog
|
|||
'DescribeLoadBalancersResult' => {
|
||||
'LoadBalancerDescriptions' => load_balancers.map do |lb|
|
||||
lb['Instances'] = lb['Instances'].map { |i| i['InstanceId'] }
|
||||
lb['Policies'] = lb['Policies']['Proper'].inject({'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [], 'OtherPolicies' => []}) { |m, policy|
|
||||
lb['Policies'] = lb['Policies']['Proper'].reduce({'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [], 'OtherPolicies' => []}) { |m, policy|
|
||||
case policy['PolicyTypeName']
|
||||
when 'AppCookieStickinessPolicyType'
|
||||
cookie_name = policy['PolicyAttributeDescriptions'].detect{|h| h['AttributeName'] == 'CookieName'}['AttributeValue']
|
||||
cookie_name = policy['PolicyAttributeDescriptions'].find{|h| h['AttributeName'] == 'CookieName'}['AttributeValue']
|
||||
m['AppCookieStickinessPolicies'] << { 'PolicyName' => policy['PolicyName'], 'CookieName' => cookie_name }
|
||||
when 'LBCookieStickinessPolicyType'
|
||||
cookie_expiration_period = policy['PolicyAttributeDescriptions'].detect{|h| h['AttributeName'] == 'CookieExpirationPeriod'}['AttributeValue'].to_i
|
||||
cookie_expiration_period = policy['PolicyAttributeDescriptions'].find{|h| h['AttributeName'] == 'CookieExpirationPeriod'}['AttributeValue'].to_i
|
||||
lb_policy = { 'PolicyName' => policy['PolicyName'] }
|
||||
lb_policy['CookieExpirationPeriod'] = cookie_expiration_period if cookie_expiration_period > 0
|
||||
m['LBCookieStickinessPolicies'] << lb_policy
|
||||
|
|
|
@ -41,7 +41,7 @@ module Fog
|
|||
else
|
||||
access_keys_data = data[:access_keys]
|
||||
end
|
||||
key = access_keys_data.detect{|k| k["AccessKeyId"] == access_key_id}
|
||||
key = access_keys_data.find{|k| k["AccessKeyId"] == access_key_id}
|
||||
key["Status"] = status
|
||||
Excon::Response.new.tap do |response|
|
||||
response.status = 200
|
||||
|
|
|
@ -37,12 +37,12 @@ module Fog
|
|||
|
||||
if sec_group = self.data[:security_groups][name]
|
||||
if opts.key?('CIDRIP')
|
||||
if sec_group['IPRanges'].detect{|h| h['CIDRIP'] == opts['CIDRIP']}
|
||||
if sec_group['IPRanges'].find{|h| h['CIDRIP'] == opts['CIDRIP']}
|
||||
raise Fog::AWS::RDS::AuthorizationAlreadyExists.new("AuthorizationAlreadyExists => #{opts['CIDRIP']} is alreay defined")
|
||||
end
|
||||
sec_group['IPRanges'] << opts.merge({"Status" => 'authorizing'})
|
||||
else
|
||||
if sec_group['EC2SecurityGroups'].detect{|h| h['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']}
|
||||
if sec_group['EC2SecurityGroups'].find{|h| h['EC2SecurityGroupName'] == opts['EC2SecurityGroupName']}
|
||||
raise Fog::AWS::RDS::AuthorizationAlreadyExists.new("AuthorizationAlreadyExists => #{opts['EC2SecurityGroupName']} is alreay defined")
|
||||
end
|
||||
sec_group['EC2SecurityGroups'] << opts.merge({"Status" => 'authorizing'})
|
||||
|
|
|
@ -63,7 +63,7 @@ module Fog
|
|||
end
|
||||
response = Excon::Response.new
|
||||
if bucket = self.data[:buckets][bucket_name]
|
||||
contents = bucket[:objects].values.collect(&:first).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
|
||||
contents = bucket[:objects].values.map(&:first).sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
|
||||
(prefix && object['Key'][0...prefix.length] != prefix) ||
|
||||
(marker && object['Key'] <= marker) ||
|
||||
(delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
|
||||
|
|
|
@ -92,7 +92,7 @@ module Fog
|
|||
# We need to order results by S3 key, but since our data store is key => [versions], we want to ensure the integrity
|
||||
# of the versions as well. So, sort the keys, then fetch the versions, and then combine them all as a sorted list by
|
||||
# flattening the results.
|
||||
contents = bucket[:objects].keys.sort.collect { |key| bucket[:objects][key] }.flatten.reject do |object|
|
||||
contents = bucket[:objects].keys.sort.map { |key| bucket[:objects][key] }.flatten.reject do |object|
|
||||
(prefix && object['Key'][0...prefix.length] != prefix) ||
|
||||
(key_marker && object['Key'] <= key_marker) ||
|
||||
(delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
|
||||
|
|
|
@ -57,7 +57,7 @@ DATA
|
|||
end
|
||||
|
||||
def signed_headers(headers)
|
||||
headers.keys.collect {|key| key.to_s}.sort.collect {|key| key.downcase}.join(';')
|
||||
headers.keys.map {|key| key.to_s}.sort.map {|key| key.downcase}.join(';')
|
||||
end
|
||||
|
||||
def derived_hmac(date)
|
||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
|||
def delete_server(server_id)
|
||||
response = Excon::Response.new
|
||||
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'].to_i == server_id }
|
||||
if server = list_servers_detail.body['servers'].find {|_| _['id'].to_i == server_id }
|
||||
if server['status'] == 'is_install'
|
||||
response.status = 405
|
||||
raise(Excon::Errors.status_error({:expects => 204}, response))
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
class Mock
|
||||
def get_server_details(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == "#{server_id}"}
|
||||
if server = list_servers_detail.body['servers'].find {|_| _['id'] == "#{server_id}"}
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'server' => server }
|
||||
response.body['server']['id'] = server['id'].to_i
|
||||
|
|
|
@ -133,7 +133,7 @@ module Fog
|
|||
current_prices = resp.body['objects']
|
||||
|
||||
current_pricing_pairs = current_levels.map do |resource, level|
|
||||
price_for_resource_and_level = current_prices.detect do |price|
|
||||
price_for_resource_and_level = current_prices.find do |price|
|
||||
price['resource'] == resource
|
||||
end
|
||||
price_for_resource_and_level ||= {}
|
||||
|
@ -151,7 +151,7 @@ module Fog
|
|||
current_prices = resp.body['objects']
|
||||
|
||||
current_pricing_pairs = current_levels.map do |resource, level|
|
||||
price_for_resource_and_level = current_prices.detect do |price|
|
||||
price_for_resource_and_level = current_prices.find do |price|
|
||||
price['level'] == level && price['resource'] == resource
|
||||
end
|
||||
price_for_resource_and_level ||= {}
|
||||
|
@ -169,7 +169,7 @@ module Fog
|
|||
current_prices = resp.body['objects']
|
||||
|
||||
current_pricing_pairs = current_levels.map do |resource, level|
|
||||
price_for_resource_and_level = current_prices.detect do |price|
|
||||
price_for_resource_and_level = current_prices.find do |price|
|
||||
price['level'] == level && price['resource'] == resource
|
||||
end
|
||||
price_for_resource_and_level ||= {}
|
||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
|||
end
|
||||
|
||||
def self.signed_params(key,params)
|
||||
query = params.map{|k,v| [k.to_s, v]}.sort.collect{|c| "#{c[0]}=#{escape(c[1].to_s)}"}.join('&').downcase
|
||||
query = params.map{|k,v| [k.to_s, v]}.sort.map{|c| "#{c[0]}=#{escape(c[1].to_s)}"}.join('&').downcase
|
||||
|
||||
signed_string = Base64.encode64(OpenSSL::HMAC.digest(@@digest,key,query)).strip
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
end
|
||||
|
||||
def attr_value(name, attrs)
|
||||
(entry = attrs.detect {|a, v| a == name }) && entry.last
|
||||
(entry = attrs.find {|a, v| a == name }) && entry.last
|
||||
end
|
||||
|
||||
def reset
|
||||
|
|
|
@ -19,7 +19,7 @@ module Fog
|
|||
|
||||
credential = Fog.respond_to?(:credential) && Fog.credential || :default
|
||||
name = "fog_#{credential}"
|
||||
ssh_key = service.ssh_keys.detect { |key| key.name == name }
|
||||
ssh_key = service.ssh_keys.find { |key| key.name == name }
|
||||
if ssh_key.nil?
|
||||
ssh_key = service.ssh_keys.create(
|
||||
:name => name,
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def get_domain(id)
|
||||
domain = self.data[:domains].detect do |domain|
|
||||
domain = self.data[:domains].find do |domain|
|
||||
domain["domain"]["id"] == id || domain["domain"]["name"] == id
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ module Fog
|
|||
|
||||
if self.data[:records].has_key?(domain)
|
||||
response.status = 200
|
||||
response.body = self.data[:records][domain].detect { |record| record["record"]["id"] == record_id }
|
||||
response.body = self.data[:records][domain].find { |record| record["record"]["id"] == record_id }
|
||||
|
||||
if response.body.nil?
|
||||
response.status = 404
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def update_record(domain, record_id, options)
|
||||
record = self.data[:records][domain].detect { |record| record["record"]["id"] == record_id }
|
||||
record = self.data[:records][domain].find { |record| record["record"]["id"] == record_id }
|
||||
response = Excon::Response.new
|
||||
|
||||
if record.nil?
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
|
||||
def all
|
||||
clear
|
||||
data = service.list_domains.body['list'].collect{|domain| {:id => domain}}
|
||||
data = service.list_domains.body['list'].map{|domain| {:id => domain}}
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
def all(filter = {})
|
||||
clear
|
||||
if filter[:zone]
|
||||
data = service.list_records.body['data'].find_all { |r| r['zone'] == filter[:zone] }
|
||||
data = service.list_records.body['data'].select { |r| r['zone'] == filter[:zone] }
|
||||
else
|
||||
data = service.list_records.body['data']
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
|||
:type => tokens[2][0...-6] # everything before 'Record'
|
||||
}
|
||||
end
|
||||
record = records.detect {|record| record[:type] == type}
|
||||
record = records.find {|record| record[:type] == type}
|
||||
merge_attributes(record)
|
||||
|
||||
true
|
||||
|
|
|
@ -37,7 +37,7 @@ module Fog
|
|||
requires :zone
|
||||
|
||||
list = service.get_all_records(zone.domain, {}).body['data']
|
||||
url = list.detect { |e| e =~ /\/#{record_id}$/ }
|
||||
url = list.find { |e| e =~ /\/#{record_id}$/ }
|
||||
return unless url
|
||||
(_, _, t, _, fqdn, id) = url.split('/')
|
||||
type = t.gsub(/Record$/, '')
|
||||
|
|
|
@ -30,9 +30,9 @@ module Fog
|
|||
data = [zone[:zone]]
|
||||
|
||||
if fqdn = options[:fqdn]
|
||||
data = data | zone[:records].collect { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
|
||||
data = data | zone[:records].map { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
|
||||
else
|
||||
data = data | zone[:records].collect { |type, records| records.collect { |record| record[:fqdn] } }.flatten
|
||||
data = data | zone[:records].map { |type, records| records.map { |record| record[:fqdn] } }.flatten
|
||||
end
|
||||
|
||||
response.body = {
|
||||
|
|
|
@ -30,9 +30,9 @@ module Fog
|
|||
data = [zone[:zone]]
|
||||
|
||||
if fqdn = options[:fqdn]
|
||||
data = data | zone[:records].collect { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
|
||||
data = data | zone[:records].map { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
|
||||
else
|
||||
data = data | zone[:records].collect { |type, records| records.collect { |record| record[:fqdn] } }.flatten
|
||||
data = data | zone[:records].map { |type, records| records.map { |record| record[:fqdn] } }.flatten
|
||||
end
|
||||
|
||||
response.body = {
|
||||
|
|
|
@ -64,7 +64,7 @@ module Fog
|
|||
end
|
||||
response.body = {
|
||||
"status" => "success",
|
||||
"data" => records.collect { |record| "/REST/#{record[:type]}Record/#{record[:zone][:zone]}/#{record[:fqdn]}/#{record[:record_id]}" },
|
||||
"data" => records.map { |record| "/REST/#{record[:type]}Record/#{record[:zone][:zone]}/#{record[:fqdn]}/#{record[:record_id]}" },
|
||||
"job_id" => Fog::Dynect::Mock.job_id,
|
||||
"msgs" => [{
|
||||
"INFO" => "detail: Found #{records.size} record",
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
}
|
||||
info = "get: Your zone, #{zone[:zone]}"
|
||||
else
|
||||
data = self.data[:zones].collect { |zone, data| "/REST/Zone/#{zone}/" }
|
||||
data = self.data[:zones].map { |zone, data| "/REST/Zone/#{zone}/" }
|
||||
info = "get: Your #{data.size} zones"
|
||||
end
|
||||
|
||||
|
|
|
@ -392,7 +392,7 @@ module Fog
|
|||
|
||||
# section 5.6.3.2 in the ~1000 page pdf spec
|
||||
def canonicalize_headers(headers)
|
||||
tmp = headers.inject({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret }
|
||||
tmp = headers.reduce({}) {|ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ; ret }
|
||||
tmp.reject! {|k,v| k == "x-tmrk-authorization" }
|
||||
tmp = tmp.sort.map{|e| "#{e.first}:#{e.last}" }.join("\n")
|
||||
tmp
|
||||
|
|
|
@ -195,11 +195,11 @@ module Fog
|
|||
private
|
||||
|
||||
def find_href_in(href, objects)
|
||||
objects.detect {|o| o.href == href }
|
||||
objects.find {|o| o.href == href }
|
||||
end
|
||||
|
||||
def find_href_prefixed_in(href, objects)
|
||||
objects.detect {|o| href =~ %r{^#{o.href}($|/)} }
|
||||
objects.find {|o| href =~ %r{^#{o.href}($|/)} }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -393,7 +393,7 @@ module Fog
|
|||
|
||||
class MockNetworkIps < Base
|
||||
def items
|
||||
@items ||= _parent.usable_subnet_ips.inject({}) do |out, subnet_ip|
|
||||
@items ||= _parent.usable_subnet_ips.reduce({}) do |out, subnet_ip|
|
||||
out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self))
|
||||
end
|
||||
end
|
||||
|
@ -417,7 +417,7 @@ module Fog
|
|||
end
|
||||
|
||||
def used_by
|
||||
self[:used_by] || _parent._parent._parent.virtual_machines.detect {|v| v.ip == ip }
|
||||
self[:used_by] || _parent._parent._parent.virtual_machines.find {|v| v.ip == ip }
|
||||
end
|
||||
|
||||
def status
|
||||
|
@ -505,11 +505,11 @@ module Fog
|
|||
end
|
||||
|
||||
def size
|
||||
disks.inject(0) {|s, d| s + d.vcloud_size }
|
||||
disks.reduce(0) {|s, d| s + d.vcloud_size }
|
||||
end
|
||||
|
||||
def network_ip
|
||||
if network = _parent.networks.detect {|n| n.ip_collection.items[ip] }
|
||||
if network = _parent.networks.find {|n| n.ip_collection.items[ip] }
|
||||
network.ip_collection.items[ip]
|
||||
end
|
||||
end
|
||||
|
@ -562,7 +562,7 @@ module Fog
|
|||
end
|
||||
|
||||
def at_address(address)
|
||||
detect {|d| d.address == address }
|
||||
find {|d| d.address == address }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -597,7 +597,7 @@ module Fog
|
|||
end
|
||||
|
||||
def public_ip_internet_services
|
||||
_parent.public_ip_collection.items.inject([]) do |services, public_ip|
|
||||
_parent.public_ip_collection.items.reduce([]) do |services, public_ip|
|
||||
services + public_ip.internet_service_collection.items
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
|
||||
def network
|
||||
reload if other_links.nil?
|
||||
network_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
|
||||
network_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
|
||||
network = self.service.networks.get(network_href)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
|
||||
def environment
|
||||
reload if other_links.nil?
|
||||
environment_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href]
|
||||
environment_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href]
|
||||
self.service.environments.get(environment_href)
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
end
|
||||
|
||||
def environment_id
|
||||
other_links[:Link].detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
other_links[:Link].find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
|
|
|
@ -103,7 +103,7 @@ module Fog
|
|||
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
||||
options[:network_uri].each do |uri|
|
||||
index = options[:network_uri].index(uri)
|
||||
ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).detect { |i| i.host == nil }.name
|
||||
ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).find { |i| i.host == nil }.name
|
||||
options[:ips] ||= []
|
||||
options[:ips][index] = ip
|
||||
end
|
||||
|
@ -168,7 +168,7 @@ module Fog
|
|||
|
||||
def detach_disk(index)
|
||||
options = {}
|
||||
options[:disk] = disks.detect { |disk_hash| disk_hash[:Index] == index.to_s }
|
||||
options[:disk] = disks.find { |disk_hash| disk_hash[:Index] == index.to_s }
|
||||
options[:name] = self.name
|
||||
options[:description] = self.description
|
||||
data = service.virtual_machine_detach_disk(href + "/hardwareconfiguration/disks/actions/detach", options).body
|
||||
|
@ -262,7 +262,7 @@ module Fog
|
|||
|
||||
def storage_size
|
||||
vm_disks = disks
|
||||
disks.map! { |d| d[:Size][:Value].to_i }.inject(0){|sum,item| sum + item} * 1024 * 1024
|
||||
disks.map! { |d| d[:Size][:Value].to_i }.reduce(0){|sum,item| sum + item} * 1024 * 1024
|
||||
end
|
||||
|
||||
def ready?
|
||||
|
@ -283,16 +283,16 @@ module Fog
|
|||
end
|
||||
|
||||
def compute_pool_id
|
||||
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
||||
other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def compute_pool
|
||||
reload if other_links.nil?
|
||||
@compute_pool = self.service.compute_pools.new(:href => other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href])
|
||||
@compute_pool = self.service.compute_pools.new(:href => other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href])
|
||||
end
|
||||
|
||||
def environment_id
|
||||
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
||||
end
|
||||
|
||||
def id
|
||||
|
|
|
@ -46,7 +46,7 @@ module Fog
|
|||
else
|
||||
[*options[:network_uri]].each do |uri|
|
||||
index = options[:network_uri].index(uri)
|
||||
ip = self.service.ip_addresses(:href => uri).detect { |i| i.host == nil && i.detected_on.nil? }.name
|
||||
ip = self.service.ip_addresses(:href => uri).find { |i| i.host == nil && i.detected_on.nil? }.name
|
||||
options[:ips] ||= []
|
||||
options[:ips][index] = ip
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
class Mock
|
||||
def get_ip_address(uri)
|
||||
network_id, ip_address_id = uri.match(/\/networks\/(\d+)\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/).captures
|
||||
ip_address = self.data[:networks][network_id.to_i][:IpAddresses][:IpAddress].detect{|ip| ip[:name] == ip_address_id }.dup
|
||||
ip_address = self.data[:networks][network_id.to_i][:IpAddresses][:IpAddress].find{|ip| ip[:name] == ip_address_id }.dup
|
||||
if ip_address
|
||||
response(:body => ip_address)
|
||||
else response(:status => 404) # ?
|
||||
|
|
|
@ -51,7 +51,7 @@ module Fog
|
|||
network = self.data[:networks][network_id.to_i]
|
||||
ip_addresses = network[:IpAddresses][:IpAddress]
|
||||
ip_addresses = ip_addresses.is_a?(Array) ? ip_addresses : [ip_addresses]
|
||||
ip_address = ip_addresses.detect { |ip| ip[:name] == ip_address_name }
|
||||
ip_address = ip_addresses.find { |ip| ip[:name] == ip_address_name }
|
||||
|
||||
service_id = Fog::Mock.random_numbers(6).to_i
|
||||
service = {
|
||||
|
|
|
@ -136,7 +136,7 @@ module Fog
|
|||
networks.each do |network|
|
||||
links << Fog::Ecloud.keep(network, :name, :href, :type)
|
||||
network_id = id_from_uri(network[:href])
|
||||
ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].detect { |ip| ip[:id] = network[:ip] }
|
||||
ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].find { |ip| ip[:id] = network[:ip] }
|
||||
ip[:DetectedOn] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
|
||||
ip[:Host] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"}
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ module Fog
|
|||
network = self.data[:networks][network_id]
|
||||
options.each.each do |net|
|
||||
net[:ips].each do |ip|
|
||||
ip = network[:IpAddresses][:IpAddress].detect { |iph| iph[:name] == ip }
|
||||
ip = network[:IpAddresses][:IpAddress].find { |iph| iph[:name] == ip }
|
||||
ip[:Host] = {
|
||||
:href => "/clouapi/ecloud/networkhosts/#{server_id}",
|
||||
:name => server[:name],
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
|
||||
def downcase_hash_keys(hash, k = [])
|
||||
return {k.join('_').gsub(/([a-z])([A-Z])/,'\1_\2').downcase => hash} unless hash.is_a?(Hash)
|
||||
hash.inject({}){ |h, v| h.merge! downcase_hash_keys(v[-1], k + [v[0]]) }
|
||||
hash.reduce({}){ |h, v| h.merge! downcase_hash_keys(v[-1], k + [v[0]]) }
|
||||
end
|
||||
|
||||
def camelize_hash_keys(hash)
|
||||
|
|
|
@ -120,7 +120,7 @@ module Fog
|
|||
end
|
||||
|
||||
def urlencode(hash)
|
||||
hash.to_a.collect! { |k, v| "#{k}=#{v.to_s}" }.join("&")
|
||||
hash.to_a.map! { |k, v| "#{k}=#{v.to_s}" }.join("&")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
images = service.template_list.body['response']['templates']
|
||||
images.select do |platform, images|
|
||||
platforms.include?(platform.downcase.to_sym)
|
||||
end.collect{|platform, images| images}.flatten
|
||||
end.map{|platform, images| images}.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ def test
|
|||
# puts img.inspect
|
||||
|
||||
# First, get the name of an image that is in the users 'project' (not global)
|
||||
custom_img_name = images.detect { |img| img.project == img.service.project }
|
||||
custom_img_name = images.find { |img| img.project == img.service.project }
|
||||
# Run the next test only if there is a custom image available
|
||||
if custom_img_name
|
||||
# puts 'Fetching a single image from the custom project'
|
||||
|
|
|
@ -45,7 +45,7 @@ module Fog
|
|||
|
||||
def public_url
|
||||
requires :key
|
||||
if service.get_bucket_acl(key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
|
||||
if service.get_bucket_acl(key).body['AccessControlList'].find {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
|
||||
if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
||||
"https://#{key}.storage.googleapis.com"
|
||||
else
|
||||
|
|
|
@ -92,7 +92,7 @@ module Fog
|
|||
requires :directory, :key
|
||||
|
||||
acl = service.get_object_acl(directory.key, key).body['AccessControlList']
|
||||
access_granted = acl.detect do |entry|
|
||||
access_granted = acl.find do |entry|
|
||||
entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
body = {
|
||||
'healthChecks' => health_checks.collect { |i| { 'healthCheck' => i } }
|
||||
'healthChecks' => health_checks.map { |i| { 'healthCheck' => i } }
|
||||
}
|
||||
|
||||
result = self.build_result(api_method, parameters, body_object=body)
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
body = {
|
||||
'instances' => instances.collect { |i| { 'instance' => i } }
|
||||
'instances' => instances.map { |i| { 'instance' => i } }
|
||||
}
|
||||
|
||||
result = self.build_result(api_method, parameters, body_object=body)
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
|
||||
health_results = target_pool.instances.collect do |instance|
|
||||
health_results = target_pool.instances.map do |instance|
|
||||
body = { 'instance' => instance }
|
||||
resp = build_response(build_result(api_method, parameters, body_object=body))
|
||||
[instance, resp.data[:body]['healthStatus']]
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
body = {
|
||||
'healthChecks' => health_checks.collect { |i| { 'healthCheck' => i } }
|
||||
'healthChecks' => health_checks.map { |i| { 'healthCheck' => i } }
|
||||
}
|
||||
|
||||
result = self.build_result(api_method, parameters, body_object=body)
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
body = {
|
||||
'instances' => instances.collect { |i| { 'instance' => i } }
|
||||
'instances' => instances.map { |i| { 'instance' => i } }
|
||||
}
|
||||
|
||||
result = self.build_result(api_method, parameters, body_object=body)
|
||||
|
|
|
@ -16,7 +16,7 @@ module Fog
|
|||
'region' => target_pool.region.split('/')[-1]
|
||||
}
|
||||
body = {
|
||||
'instances' => instances.collect { |i| { 'instance' => i } }
|
||||
'instances' => instances.map { |i| { 'instance' => i } }
|
||||
}
|
||||
|
||||
result = self.build_result(api_method, parameters, body_object=body)
|
||||
|
|
|
@ -43,37 +43,37 @@ module Fog
|
|||
|
||||
# The following are built-in metadata for each image, exposed as helpers
|
||||
def bootable_volume?
|
||||
m = @metadata.detect {|md| md.key == 'com.hp__1__bootable_volume'}
|
||||
m = @metadata.find {|md| md.key == 'com.hp__1__bootable_volume'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def provider
|
||||
m = @metadata.detect {|md| md.key == 'com.hp__1__provider'}
|
||||
m = @metadata.find {|md| md.key == 'com.hp__1__provider'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def os_distro
|
||||
m = @metadata.detect {|md| md.key == 'com.hp__1__os_distro'}
|
||||
m = @metadata.find {|md| md.key == 'com.hp__1__os_distro'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def os_version
|
||||
m = @metadata.detect {|md| md.key == 'com.hp__1__os_version'}
|
||||
m = @metadata.find {|md| md.key == 'com.hp__1__os_version'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def license
|
||||
m = @metadata.detect {|md| md.key == 'hp_image_license'}
|
||||
m = @metadata.find {|md| md.key == 'hp_image_license'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def type
|
||||
m = @metadata.detect {|md| md.key == 'com.hp__1__image_type'}
|
||||
m = @metadata.find {|md| md.key == 'com.hp__1__image_type'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
|
||||
def architecture
|
||||
m = @metadata.detect {|md| md.key == 'architecture'}
|
||||
m = @metadata.find {|md| md.key == 'architecture'}
|
||||
m.value unless m.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
|
||||
def get(name)
|
||||
data = service.list_algorithms.body['algorithms']
|
||||
algorithm = data.detect {|algo| algo['name'] == name}
|
||||
algorithm = data.find {|algo| algo['name'] == name}
|
||||
new(algorithm)
|
||||
rescue Fog::HP::LB::NotFound
|
||||
nil
|
||||
|
|
|
@ -71,7 +71,7 @@ module Fog
|
|||
|
||||
def nodes_to_hash
|
||||
if nodes
|
||||
nodes.collect do |node|
|
||||
nodes.map do |node|
|
||||
{ 'address' => node.address, 'port' => node.port, 'condition' => node.condition }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
|
||||
def get(name)
|
||||
data = service.list_protocols.body['protocols']
|
||||
protocol = data.detect {|p| p['name'] == name}
|
||||
protocol = data.find {|p| p['name'] == name}
|
||||
new(protocol)
|
||||
rescue Fog::HP::LB::NotFound
|
||||
nil
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче