1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Replace deprecated Hash methods

Done with `rubocop --auto-correct --only DeprecatedHashMethods`
This commit is contained in:
Paul Thornthwaite 2014-05-21 10:28:51 -04:00
parent 698bca3f10
commit 6716f37c5f
208 changed files with 301 additions and 301 deletions

View file

@ -334,13 +334,13 @@ module Fog
tag_set_fetcher = lambda {|resource| self.data[:tag_sets][resource[resource_id_key]] }
# tag-key: match resources tagged with this key (any value)
if filters.has_key?('tag-key')
if filters.key?('tag-key')
value = filters.delete('tag-key')
resources = resources.select{|r| tag_set_fetcher[r].has_key?(value)}
resources = resources.select{|r| tag_set_fetcher[r].key?(value)}
end
# tag-value: match resources tagged with this value (any key)
if filters.has_key?('tag-value')
if filters.key?('tag-value')
value = filters.delete('tag-value')
resources = resources.select{|r| tag_set_fetcher[r].values.include?(value)}
end

View file

@ -13,7 +13,7 @@ module Fog
# a describe configuration templates call in the AWS API.
def all(options={})
application_filter = []
if options.has_key?('ApplicationName')
if options.key?('ApplicationName')
application_filter << options['ApplicationName']
end

View file

@ -45,7 +45,7 @@ module Fog
end
def writable?
!!(private_key && ENV.has_key?('HOME'))
!!(private_key && ENV.key?('HOME'))
end
end
end

View file

@ -28,7 +28,7 @@ module Fog
data = service.list_resource_record_sets(zone.id, options).body
# NextRecordIdentifier is completely absent instead of nil, so set to nil, or iteration breaks.
data['NextRecordIdentifier'] = nil unless data.has_key?('NextRecordIdentifier')
data['NextRecordIdentifier'] = nil unless data.key?('NextRecordIdentifier')
merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextRecordName', 'NextRecordType', 'NextRecordIdentifier'].include?(key)})
load(data['ResourceRecordSets'])
@ -55,7 +55,7 @@ module Fog
batch = service.list_resource_record_sets(zone.id, options).body
# NextRecordIdentifier is completely absent instead of nil, so set to nil, or iteration breaks.
batch['NextRecordIdentifier'] = nil unless batch.has_key?('NextRecordIdentifier')
batch['NextRecordIdentifier'] = nil unless batch.key?('NextRecordIdentifier')
merge_attributes(batch.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextRecordName', 'NextRecordType', 'NextRecordIdentifier'].include?(key)})

View file

@ -26,7 +26,7 @@ module Fog
end
def new(attributes = {})
if not attributes.has_key?(:assume_role_policy_document)
if not attributes.key?(:assume_role_policy_document)
attributes[:assume_role_policy_document] = Fog::AWS::IAM::EC2_ASSUME_ROLE_POLICY.to_s
end
super

View file

@ -34,7 +34,7 @@ module Fog
if @parse_stack.last[:type] == :object
@parse_stack.last[:value] << {} # Push any empty object
end
elsif @list_tags.has_key?(name)
elsif @list_tags.key?(name)
set_value(name, [], :array) # Set an empty array
@parse_stack.push({ :type => @tags[name], :value => get_parent[name] })
elsif @tags[name] == :object
@ -52,9 +52,9 @@ module Fog
when 'RequestId'
@response['ResponseMetadata'][name] = value
else
if @list_tags.has_key?(name) || @tags[name] == :object
if @list_tags.key?(name) || @tags[name] == :object
@parse_stack.pop()
elsif @tags.has_key?(name)
elsif @tags.key?(name)
set_value(name, value, @tags[name])
end
end

View file

@ -53,7 +53,7 @@ module Fog
@response['ResponseMetadata'][name] = value
when 'member'
if !@in_dimensions
if @metric_alarms.has_key?('AlarmName')
if @metric_alarms.key?('AlarmName')
@response['DescribeAlarmsResult']['MetricAlarms'] << @metric_alarms
reset_metric_alarms
elsif @response['DescribeAlarmsResult']['MetricAlarms'].last != nil

View file

@ -51,7 +51,7 @@ module Fog
@response['ResponseMetadata'][name] = value
when 'member'
if !@in_dimensions
if @metric_alarms.has_key?('AlarmName')
if @metric_alarms.key?('AlarmName')
@response['DescribeAlarmsForMetricResult']['MetricAlarms'] << @metric_alarms
reset_metric_alarms
elsif @response['DescribeAlarmsForMetricResult']['MetricAlarms'].last != nil

View file

@ -99,10 +99,10 @@ module Fog
raise Fog::AWS::AutoScaling::ValidationError.new("Options #{unexpected_options.join(',')} should not be included in request")
end
if self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
if self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::IdentifierTaken.new("AutoScalingGroup by this name already exists - A group with the name #{auto_scaling_group_name} already exists")
end
unless self.data[:launch_configurations].has_key?(launch_configuration_name)
unless self.data[:launch_configurations].key?(launch_configuration_name)
raise Fog::AWS::AutoScaling::ValidationError.new('Launch configuration name not found - null')
end
self.data[:auto_scaling_groups][auto_scaling_group_name] = {

View file

@ -75,7 +75,7 @@ module Fog
class Mock
def create_launch_configuration(image_id, instance_type, launch_configuration_name, options = {})
if self.data[:launch_configurations].has_key?(launch_configuration_name)
if self.data[:launch_configurations].key?(launch_configuration_name)
raise Fog::AWS::AutoScaling::IdentifierTaken.new("Launch Configuration by this name already exists - A launch configuration already exists with the name #{launch_configuration_name}")
end
self.data[:launch_configurations][launch_configuration_name] = {

View file

@ -33,10 +33,10 @@ module Fog
class Mock
def delete_notification_configuration(auto_scaling_group_name, topic_arn)
unless self.data[:notification_configurations].has_key?(auto_scaling_group_name)
unless self.data[:notification_configurations].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - %s' % auto_scaling_group_name)
end
unless self.data[:notification_configurations][auto_scaling_group_name].has_key?(topic_arn)
unless self.data[:notification_configurations][auto_scaling_group_name].key?(topic_arn)
raise Fog::AWS::AutoScaling::ValidationError.new("Notification Topic '#{topic_arn}' doesn't exist for '#{self.data[:owner_id]}'")
end

View file

@ -38,7 +38,7 @@ module Fog
class Mock
def disable_metrics_collection(auto_scaling_group_name, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
Fog::AWS::AutoScaling::ValidationError.new("Group #{auto_scaling_group_name} not found")
end

View file

@ -45,7 +45,7 @@ module Fog
class Mock
def enable_metrics_collection(auto_scaling_group_name, granularity, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
Fog::AWS::AutoScaling::ValidationError.new("Group #{auto_scaling_group_name} not found")
end
unless self.data[:metric_collection_types][:granularities].include?(granularity)

View file

@ -37,7 +37,7 @@ module Fog
class Mock
def put_notification_configuration(auto_scaling_group_name, notification_types, topic_arn)
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - #{auto_scaling_group_name}")
end
if notification_types.to_a.empty?

View file

@ -52,7 +52,7 @@ module Fog
class Mock
def put_scaling_policy(adjustment_type, auto_scaling_group_name, policy_name, scaling_adjustment, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new('Auto Scaling Group name not found - null')
end
self.data[:scaling_policies][policy_name] = {

View file

@ -36,7 +36,7 @@ module Fog
class Mock
def resume_processes(auto_scaling_group_name, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - no such group: #{auto_scaling_group_name}")
end

View file

@ -63,7 +63,7 @@ module Fog
class Mock
def set_desired_capacity(auto_scaling_group_name, desired_capacity, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null')
end
self.data[:auto_scaling_groups][auto_scaling_group_name]['DesiredCapacity'] = desired_capacity

View file

@ -39,7 +39,7 @@ module Fog
class Mock
def suspend_processes(auto_scaling_group_name, options = {})
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new("AutoScalingGroup name not found - no such group: #{auto_scaling_group_name}")
end

View file

@ -75,7 +75,7 @@ module Fog
raise Fog::AWS::AutoScaling::ValidationError.new("Options #{unexpected_options.join(',')} should not be included in request")
end
unless self.data[:auto_scaling_groups].has_key?(auto_scaling_group_name)
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null')
end
self.data[:auto_scaling_groups][auto_scaling_group_name].merge!(options)

View file

@ -28,7 +28,7 @@ module Fog
class Mock
def delete_alarms(alarm_names)
[*alarm_names].each do |alarm_name|
unless data[:metric_alarms].has_key?(alarm_name)
unless data[:metric_alarms].key?(alarm_name)
raise Fog::AWS::AutoScaling::NotFound, "The alarm '#{alarm_name}' does not exist."
end
end

View file

@ -25,7 +25,7 @@ module Fog
#
def get_metric_statistics(options={})
%w{Statistics StartTime EndTime Period MetricName Namespace}.each do |required_parameter|
raise ArgumentError, "Must provide #{required_parameter}" unless options.has_key?(required_parameter)
raise ArgumentError, "Must provide #{required_parameter}" unless options.key?(required_parameter)
end
statistics = options.delete 'Statistics'
options.merge!(AWS.indexed_param('Statistics.member.%d', [*statistics]))

View file

@ -66,7 +66,7 @@ module Fog
requirements = [ "AlarmName", "ComparisonOperator", "EvaluationPeriods", "Namespace", "Period", "Statistic", "Threshold" ]
requirements.each do |req|
unless options.has_key?(req)
unless options.key?(req)
raise Fog::Compute::AWS::Error.new("The request must contain a the parameter '%s'" % req)
end
end

View file

@ -138,7 +138,7 @@ module Fog
if !is_vpc && (options['IpProtocol'] && (!options['FromPort'] || !options['ToPort']))
raise Fog::Compute::AWS::Error.new("InvalidPermission.Malformed => TCP/UDP port (-1) out of range")
end
if options.has_key?('IpPermissions')
if options.key?('IpPermissions')
if !options['IpPermissions'].is_a?(Array) || options['IpPermissions'].empty?
raise Fog::Compute::AWS::Error.new("InvalidRequest => The request received was invalid.")
end

View file

@ -65,7 +65,7 @@ module Fog
tagged.each do |resource|
tags.each do |key, value|
tagset = self.data[:tag_sets][resource['resourceId']]
tagset.delete(key) if tagset.has_key?(key) && (value.nil? || tagset[key] == value)
tagset.delete(key) if tagset.key?(key) && (value.nil? || tagset[key] == value)
end
end

View file

@ -35,7 +35,7 @@ module Fog
end
for key in ['ExecutableBy', 'ImageId', 'Owner', 'RestorableBy']
if filters.has_key?(key)
if filters.key?(key)
options[key] = filters.delete(key)
end
end

View file

@ -60,7 +60,7 @@ module Fog
response = Excon::Response.new
response.status = 200
raise Fog::AWS::ELB::IdentifierTaken if self.data[:load_balancers].has_key? lb_name
raise Fog::AWS::ELB::IdentifierTaken if self.data[:load_balancers].key? lb_name
certificate_ids = Fog::AWS::IAM::Mock.data[@aws_access_key_id][:server_certificates].map {|n, c| c['Arn'] }

View file

@ -30,8 +30,8 @@ module Fog
class Mock
def add_user_to_group(group_name, user_name)
if data[:groups].has_key? group_name
if data[:users].has_key? user_name
if data[:groups].key? group_name
if data[:users].key? user_name
unless data[:groups][group_name][:members].include?(user_name)
data[:groups][group_name][:members] << user_name

View file

@ -35,7 +35,7 @@ module Fog
#FIXME: Not 100% correct as AWS will use the signing credentials when there is no 'UserName' in the options hash
# Also doesn't raise an error when there are too many keys
if user = options['UserName']
if data[:users].has_key? user
if data[:users].key? user
access_keys_data = data[:users][user][:access_keys]
else
raise Fog::AWS::IAM::NotFound.new('The user with name #{user_name} cannot be found.')

View file

@ -35,7 +35,7 @@ module Fog
class Mock
def create_group(group_name, path = '/')
if data[:groups].has_key? group_name
if data[:groups].key? group_name
raise Fog::AWS::IAM::EntityAlreadyExists.new("Group with name #{group_name} already exists.")
else
data[:groups][group_name][:path] = path

View file

@ -35,7 +35,7 @@ module Fog
class Mock
def create_user(user_name, path='/')
if data[:users].has_key? user_name
if data[:users].key? user_name
raise Fog::AWS::IAM::EntityAlreadyExists.new "User with name #{user_name} already exists."
else
data[:users][user_name][:path] = path

View file

@ -31,7 +31,7 @@ module Fog
class Mock
def delete_access_key(access_key_id, options = {})
user_name = options['UserName']
if user_name && data[:users].has_key?(user_name) && data[:users][user_name][:access_keys].any? { |akey| akey['AccessKeyId'] == access_key_id }
if user_name && data[:users].key?(user_name) && data[:users][user_name][:access_keys].any? { |akey| akey['AccessKeyId'] == access_key_id }
data[:users][user_name][:access_keys].delete_if { |akey| akey['AccessKeyId'] == access_key_id }
Excon::Response.new.tap do |response|
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }

View file

@ -28,7 +28,7 @@ module Fog
class Mock
def delete_group(group_name)
if data[:groups].has_key? group_name
if data[:groups].key? group_name
if data[:groups][group_name][:members].empty?
data[:groups].delete group_name
Excon::Response.new.tap do |response|

View file

@ -28,7 +28,7 @@ module Fog
class Mock
def delete_user(user_name)
if data[:users].has_key? user_name
if data[:users].key? user_name
data[:users].delete user_name
Excon::Response.new.tap do |response|
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }

View file

@ -30,7 +30,7 @@ module Fog
class Mock
def delete_user_policy(user_name, policy_name)
if data[:users].has_key?(user_name) && data[:users][user_name][:policies].has_key?(policy_name)
if data[:users].key?(user_name) && data[:users][user_name][:policies].key?(policy_name)
data[:users][user_name][:policies].delete policy_name
Excon::Response.new.tap do |response|
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }

View file

@ -38,7 +38,7 @@ module Fog
def list_access_keys(options = {})
#FIXME: Doesn't do anything with options, aside from UserName
if user = options['UserName']
if data[:users].has_key? user
if data[:users].key? user
access_keys_data = data[:users][user][:access_keys]
else
raise Fog::AWS::IAM::NotFound.new("The user with name #{user} cannot be found.")

View file

@ -40,7 +40,7 @@ module Fog
class Mock
def list_groups_for_user(user_name, options = {})
#FIXME: Does not consider options
if data[:users].has_key? user_name
if data[:users].key? user_name
Excon::Response.new.tap do |response|
response.status = 200
response.body = { 'GroupsForUser' => data[:groups].select do |name, group|

View file

@ -36,7 +36,7 @@ module Fog
class Mock
def list_user_policies(user_name, options = {})
#FIXME: doesn't use options atm
if data[:users].has_key? user_name
if data[:users].key? user_name
Excon::Response.new.tap do |response|
response.body = { 'PolicyNames' => data[:users][user_name][:policies].keys,
'IsTruncated' => false,

View file

@ -33,7 +33,7 @@ module Fog
#FIXME: You can't actually use the credentials for anything elsewhere in Fog
#FIXME: Doesn't do any validation on the policy
def put_group_policy(group_name, policy_name, policy_document)
if data[:groups].has_key? group_name
if data[:groups].key? group_name
data[:groups][group_name][:policies][policy_name] = policy_document
Excon::Response.new.tap do |response|

View file

@ -34,7 +34,7 @@ module Fog
#FIXME: You can't actually use the credentials for anything elsewhere in Fog
#FIXME: Doesn't do any validation on the policy
def put_user_policy(user_name, policy_name, policy_document)
if data[:users].has_key? user_name
if data[:users].key? user_name
data[:users][user_name][:policies][policy_name] = policy_document
Excon::Response.new.tap do |response|

View file

@ -30,8 +30,8 @@ module Fog
class Mock
def remove_user_from_group(group_name, user_name)
if data[:groups].has_key? group_name
if data[:users].has_key? user_name
if data[:groups].key? group_name
if data[:users].key? user_name
data[:groups][group_name][:members].delete_if { |item| item == user_name }
Excon::Response.new.tap do |response|
response.status = 200

View file

@ -33,7 +33,7 @@ module Fog
class Mock
def update_access_key(access_key_id, status, options = {})
if user = options['UserName']
if data[:users].has_key? user
if data[:users].key? user
access_keys_data = data[:users][user][:access_keys]
else
raise Fog::AWS::IAM::NotFound.new('The user with name #{user_name} cannot be found.')

View file

@ -66,7 +66,7 @@ module Fog
# These are the required parameters according to the API
required_params = %w{AllocatedStorage DBInstanceClass Engine MasterUserPassword MasterUsername }
required_params.each do |key|
unless options.has_key?(key) and options[key] and !options[key].to_s.empty?
unless options.key?(key) and options[key] and !options[key].to_s.empty?
#response.status = 400
#response.body = {
# 'Code' => 'MissingParameter',

View file

@ -52,11 +52,11 @@ module Fog
end
end
if options.has_key?('ReplyToAddresses')
if options.key?('ReplyToAddresses')
params.merge!(Fog::AWS.indexed_param("ReplyToAddresses.member", [*options['ReplyToAddresses']]))
end
if options.has_key?('ReturnPath')
if options.key?('ReturnPath')
params['ReturnPath'] = options['ReturnPath']
end

View file

@ -20,10 +20,10 @@ module Fog
# * 'RequestId'<~String> - Id of request
def send_raw_email(raw_message, options = {})
params = {}
if options.has_key?('Destinations')
if options.key?('Destinations')
params.merge!(Fog::AWS.indexed_param('Destinations.member', [*options['Destinations']]))
end
if options.has_key?('Source')
if options.key?('Source')
params['Source'] = options['Source']
end

View file

@ -55,7 +55,7 @@ module Fog
object = {}
if !options['AttributeName'].empty?
for attribute in options['AttributeName']
if self.data[:domains][domain_name].has_key?(item_name) && self.data[:domains][domain_name][item_name].has_key?(attribute)
if self.data[:domains][domain_name].key?(item_name) && self.data[:domains][domain_name][item_name].key?(attribute)
object[attribute] = self.data[:domains][domain_name][item_name][attribute]
end
end

View file

@ -31,7 +31,7 @@ module Fog
Excon::Response.new.tap do |response|
if (queue = data[:queues][queue_url])
message_id, _ = queue[:receipt_handles].find { |message_id, receipts|
receipts.has_key?(receipt_handle)
receipts.key?(receipt_handle)
}
if message_id

View file

@ -29,7 +29,7 @@ module Fog
Excon::Response.new.tap do |response|
if (queue = data[:queues][queue_url])
message_id, _ = queue[:receipt_handles].find { |msg_id, receipts|
receipts.has_key?(receipt_handle)
receipts.key?(receipt_handle)
}
if message_id

View file

@ -21,11 +21,11 @@ module Fog
data << " <Grant>\n"
grantee = grant['Grantee']
type = case
when grantee.has_key?('ID')
when grantee.key?('ID')
'CanonicalUser'
when grantee.has_key?('EmailAddress')
when grantee.key?('EmailAddress')
'AmazonCustomerByEmail'
when grantee.has_key?('URI')
when grantee.key?('URI')
'Group'
end

View file

@ -68,7 +68,7 @@ module Fog
(marker && object['Key'] <= marker) ||
(delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
&& common_prefixes << object['Key'].sub(/^(#{prefix}[^#{delimiter}]+.).*/, '\1')) ||
object.has_key?(:delete_marker)
object.key?(:delete_marker)
end.map do |object|
data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)}
data.merge!({

View file

@ -98,7 +98,7 @@ module Fog
(delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
&& common_prefixes << object['Key'].sub(/^(#{prefix}[^#{delimiter}]+.).*/, '\1'))
end.map do |object|
if object.has_key?(:delete_marker)
if object.key?(:delete_marker)
tag_name = 'DeleteMarker'
extracted_attrs = ['Key', 'VersionId']
else

View file

@ -77,7 +77,7 @@ module Fog
response = Excon::Response.new
if (bucket = self.data[:buckets][bucket_name])
object = nil
if bucket[:objects].has_key?(object_name)
if bucket[:objects].key?(object_name)
object = version_id ? bucket[:objects][object_name].find { |object| object['VersionId'] == version_id} : bucket[:objects][object_name].first
end

View file

@ -18,7 +18,7 @@ module Fog
# * response<~Excon::Response>:
# * body<~Hash>:
def create_block(product_id, template_id, location_id, options = {})
unless options.has_key?('password') || options.has_key?('ssh_public_key')
unless options.key?('password') || options.key?('ssh_public_key')
raise ArgumentError, 'Either password or public_key must be supplied'
end

View file

@ -25,7 +25,7 @@ module Fog
def get_record(domain, record_id)
response = Excon::Response.new
if self.data[:records].has_key?(domain)
if self.data[:records].key?(domain)
response.status = 200
response.body = self.data[:records][domain].find { |record| record["record"]["id"] == record_id }

View file

@ -251,7 +251,7 @@ module Fog
attr_reader :versions_uri
def validate_data(required_opts = [], options = {})
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
end
@ -810,7 +810,7 @@ module Fog
status = params[:status] || 200
response = Excon::Response.new(:body => body, :headers => headers, :status => status)
if params.has_key?(:expects) && ![*params[:expects]].include?(response.status)
if params.key?(:expects) && ![*params[:expects]].include?(response.status)
raise(Excon::Errors.status_error(params, response))
else response
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_edit_compute_pool_options(options)
required_opts = [:name]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_internet_service_data(service_data)
required_opts = [:name, :protocol, :port, :description, :enabled, :persistence]
unless required_opts.all? { |opt| service_data.has_key?(opt) }
unless required_opts.all? { |opt| service_data.key?(opt) }
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
end
if service_data[:trusted_network_group]

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_edit_internet_service_options(options)
required_opts = [:name, :enabled, :persistence]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
raise ArgumentError.new("Required data missing: #{:persistence[:type]}") unless options[:persistence][:type]

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_node_service_data(service_data)
required_opts = [:name, :port, :enabled, :ip_address]
unless required_opts.all? { |opt| service_data.has_key?(opt) }
unless required_opts.all? { |opt| service_data.key?(opt) }
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
end
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_edit_node_service_options(options)
required_opts = [:name, :enabled]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
end

View file

@ -9,7 +9,7 @@ module Fog
else
required_opts.push(:ssh_key_uri)
end
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_create_server_options_identical(template_uri, options)
required_opts = [:name, :row, :group, :source]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end

View file

@ -9,7 +9,7 @@ module Fog
else
required_opts.push(:ssh_key_uri)
end
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_edit_server_options(options)
required_opts = [:name]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_import_server_options(template_uri, options)
required_opts = [:name, :cpus, :memory, :row, :group, :network_uri, :catalog_network_name]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end

View file

@ -4,7 +4,7 @@ module Fog
module Shared
def validate_upload_file_options(options)
required_opts = [:file, :path, :credentials]
unless required_opts.all? { |opt| options.has_key?(opt) }
unless required_opts.all? { |opt| options.key?(opt) }
raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
end
end

View file

@ -3,8 +3,8 @@ module Fog
class Fogdocker
class Real
def container_action(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "action is a required parameter" unless options.has_key? :action
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
raise ArgumentError, "action is a required parameter" unless options.key? :action
container = Docker::Container.get(options[:id])
downcase_hash_keys container.send(options[:action]).json
end
@ -12,8 +12,8 @@ module Fog
class Mock
def container_action(options = {})
raise ArgumentError, "id is a required parameter" unless options.has_key? :id
raise ArgumentError, "action is a required parameter" unless options.has_key? :action
raise ArgumentError, "id is a required parameter" unless options.key? :id
raise ArgumentError, "action is a required parameter" unless options.key? :action
{'id' => 'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef3','state_running' => false}
end
end

View file

@ -3,7 +3,7 @@ module Fog
class Fogdocker
class Real
def container_commit(options)
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
container = Docker::Container.get(options[:id])
downcase_hash_keys container.commit(camelize_hash_keys(options)).json
end

View file

@ -3,7 +3,7 @@ module Fog
class Fogdocker
class Real
def container_delete(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
container = Docker::Container.get(options[:id])
container.delete()
true
@ -12,7 +12,7 @@ module Fog
class Mock
def container_delete(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
true
end
end

View file

@ -3,7 +3,7 @@ module Fog
class Fogdocker
class Real
def image_delete(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
image = Docker::Image.get(options[:id])
image.remove()
end
@ -11,7 +11,7 @@ module Fog
class Mock
def image_delete(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
"[{'Deleted':'b15c1423ba157d0f7ac83cba178390c421bb8d536e7e7857580fc10f2d53e1b9'}]"
end
end

View file

@ -43,7 +43,7 @@ module Fog
options = default_options.merge!(options)
%w{platform datacenter version}.each do |attr|
raise Fog::Errors::Error.new("You need to specify ':#{attr}'") if !options.has_key?(attr.to_sym)
raise Fog::Errors::Error.new("You need to specify ':#{attr}'") if !options.key?(attr.to_sym)
end
options[:ipversion] = options[:version]

View file

@ -29,7 +29,7 @@ module Fog
def get_by_ip_address(ip_address)
addresses = service.list_aggregated_addresses(:filter => "address eq .*#{ip_address}").body['items']
address = addresses.each_value.select { |region| region.has_key?('addresses') }
address = addresses.each_value.select { |region| region.key?('addresses') }
return nil if address.empty?
new(address.first['addresses'].first)

View file

@ -25,7 +25,7 @@ module Fog
response = service.get_disk(identity, zone).body
else
disks = service.list_aggregated_disks(:filter => "name eq .*#{identity}").body['items']
disk = disks.each_value.select { |zone| zone.has_key?('disks') }
disk = disks.each_value.select { |zone| zone.key?('disks') }
# It can only be 1 disk with the same name across all regions
response = disk.first['disks'].first unless disk.empty?

View file

@ -25,7 +25,7 @@ module Fog
response = service.get_server(identity, zone).body
else
servers = service.list_aggregated_servers(:filter => "name eq .*#{identity}").body['items']
server = servers.each_value.select { |zone| zone.has_key?('instances') }
server = servers.each_value.select { |zone| zone.key?('instances') }
# It can only be 1 server with the same name across all regions
response = server.first['instances'].first unless server.empty?

View file

@ -81,12 +81,12 @@ module Fog
# sizeGb or sourceSnapshot need to be present, one will create blank
# disk of desired size, other will create disk from snapshot
if image_name.nil?
if opts.has_key?('sourceSnapshot')
if opts.key?('sourceSnapshot')
# New disk from snapshot
snap = snapshots.get(opts.delete('sourceSnapshot'))
raise ArgumentError.new('Invalid source snapshot') unless snap
body_object['sourceSnapshot'] = @api_url + snap.resource_url
elsif opts.has_key?('sizeGb')
elsif opts.key?('sizeGb')
# New blank disk
body_object['sizeGb'] = opts.delete('sizeGb')
else

View file

@ -128,7 +128,7 @@ module Fog
body_object['machineType'] = @api_url + @project + "/zones/#{zone_name}/machineTypes/#{options.delete 'machineType'}"
network = nil
if options.has_key? 'network'
if options.key? 'network'
network = options.delete 'network'
elsif @default_network
network = @default_network
@ -137,7 +137,7 @@ module Fog
# ExternalIP is default value for server creation
access_config = {'type' => 'ONE_TO_ONE_NAT', 'name' => 'External NAT'}
# leave natIP undefined to use an IP from a shared ephemeral IP address pool
if options.has_key? 'externalIp'
if options.key? 'externalIp'
access_config['natIP'] = options.delete 'externalIp'
# If set to 'false', that would mean user does no want to allocate an external IP
access_config = nil if access_config['natIP'] == false
@ -154,11 +154,11 @@ module Fog
'automaticRestart' => false,
'onHostMaintenance' => "MIGRATE"
}
if options.has_key? 'auto_restart'
if options.key? 'auto_restart'
scheduling['automaticRestart'] = options.delete 'auto_restart'
scheduling['automaticRestart'] = scheduling['automaticRestart'].class == TrueClass
end
if options.has_key? 'on_host_maintenance'
if options.key? 'on_host_maintenance'
ohm = options.delete 'on_host_maintenance'
scheduling['onHostMaintenance'] = (ohm.respond_to?("upcase") &&
ohm.upcase == "MIGRATE" && "MIGRATE") || "TERMINATE"
@ -166,7 +166,7 @@ module Fog
body_object['scheduling'] = scheduling
# @see https://developers.google.com/compute/docs/networking#canipforward
if options.has_key? 'can_ip_forward'
if options.key? 'can_ip_forward'
body_object['canIpForward'] = options.delete 'can_ip_forward'
end

View file

@ -43,7 +43,7 @@ module Fog
end
def writable?
!!(private_key && ENV.has_key?('HOME'))
!!(private_key && ENV.key?('HOME'))
end
end
end

View file

@ -43,7 +43,7 @@ module Fog
end
def writable?
!!(private_key && ENV.has_key?('HOME'))
!!(private_key && ENV.key?('HOME'))
end
end
end

View file

@ -21,7 +21,7 @@ module Fog
:path => "#{Fog::HP.escape(container)}/#{Fog::HP.escape(object)}"
)
end
if headers.has_key?('Transfer-Encoding')
if headers.key?('Transfer-Encoding')
headers.delete('Content-Length')
end
response = request(

View file

@ -27,7 +27,7 @@ module Fog
:path => "#{path}/#{Fog::HP.escape(object_name)}"
)
end
if headers.has_key?('Transfer-Encoding')
if headers.key?('Transfer-Encoding')
headers.delete('Content-Length')
end
response = shared_request(

View file

@ -5,18 +5,18 @@ module Excon
def instrument(name, params = {}, &block)
params = params.dup
if params.has_key?(:headers) && params[:headers].has_key?('Authorization')
if params.key?(:headers) && params[:headers].key?('Authorization')
params[:headers] = params[:headers].dup
params[:headers]['Authorization'] = REDACTED
end
if params.has_key?(:password)
if params.key?(:password)
params[:password] = REDACTED
end
$stderr.puts("--- #{name} ---")
if name.include?('.request')
query = ''
tmp_query = ''
if params.has_key?(:query) && !params[:query].nil?
if params.key?(:query) && !params[:query].nil?
params[:query].each do |key, value|
tmp_query += "#{key}=#{value}&"
end

View file

@ -21,11 +21,11 @@ module Fog
data << " <Grant>\n"
grantee = grant['Grantee']
type = case
when grantee.has_key?('ID')
when grantee.key?('ID')
'CanonicalUser'
when grantee.has_key?('EmailAddress')
when grantee.key?('EmailAddress')
'AmazonCustomerByEmail'
when grantee.has_key?('URI')
when grantee.key?('URI')
'Group'
end

View file

@ -68,7 +68,7 @@ module Fog
(marker && object['Key'] <= marker) ||
(delimiter && object['Key'][(prefix ? prefix.length : 0)..-1].include?(delimiter) \
&& common_prefixes << object['Key'].sub(/^(#{prefix}[^#{delimiter}]+.).*/, '\1')) ||
object.has_key?(:delete_marker)
object.key?(:delete_marker)
end.map do |object|
data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)}
data.merge!({

View file

@ -67,7 +67,7 @@ module Fog
response = Excon::Response.new
if (bucket = self.data[:buckets][bucket_name])
object = nil
if bucket[:objects].has_key?(object_name)
if bucket[:objects].key?(object_name)
object = bucket[:objects][object_name].first
end

View file

@ -124,7 +124,7 @@ module Fog
if querystring.nil?
append="?socket=/var/run/libvirt/libvirt-sock"
else
if !::CGI.parse(querystring).has_key?("socket")
if !::CGI.parse(querystring).key?("socket")
append="&socket=/var/run/libvirt/libvirt-sock"
end
end

View file

@ -123,7 +123,7 @@ module Fog
def value(name)
unless @parsed_uri.query.nil?
params=CGI.parse(@parsed_uri.query)
if params.has_key?(name)
if params.key?(name)
return params[name].first
else
return nil

View file

@ -5,9 +5,9 @@ module Fog
def list_domains(filter = { })
data=[]
if filter.has_key?(:uuid)
if filter.key?(:uuid)
data << client.lookup_domain_by_uuid(filter[:uuid])
elsif filter.has_key?(:name)
elsif filter.key?(:name)
data << client.lookup_domain_by_name(filter[:name])
else
client.list_defined_domains.each { |name| data << client.lookup_domain_by_name(name) } unless filter[:defined] == false

View file

@ -4,9 +4,9 @@ module Fog
class Real
def list_pools(filter = { })
data=[]
if filter.has_key?(:name)
if filter.key?(:name)
data << find_pool_by_name(filter[:name])
elsif filter.has_key?(:uuid)
elsif filter.key?(:uuid)
data << find_pool_by_uuid(filter[:uuid])
else
(client.list_storage_pools + client.list_defined_storage_pools).each do |name|

View file

@ -3,7 +3,7 @@ module Fog
class Libvirt
class Real
def update_display(options = { })
raise ArgumentError, "uuid is a required parameter" unless options.has_key? :uuid
raise ArgumentError, "uuid is a required parameter" unless options.key? :uuid
display = { }
display[:type] = options[:type] || 'vnc'
display[:port] = (options[:port] || -1).to_s
@ -22,7 +22,7 @@ module Fog
class Mock
def update_display(options = { })
raise ArgumentError, "uuid is a required parameter" unless options.has_key? :uuid
raise ArgumentError, "uuid is a required parameter" unless options.key? :uuid
true
end
end

View file

@ -110,7 +110,7 @@ module Fog
# the values out with a prefix, and if there is an empty data entry return an
# empty version of the expected type (if provided)
response = Fog::JSON.decode(response.body)
if options.has_key? :response_prefix
if options.key? :response_prefix
keys = options[:response_prefix].split('/')
keys.each do |k|
if response[k]

View file

@ -48,7 +48,7 @@ module Fog
end
def writable?
!!(private_key && ENV.has_key?('HOME'))
!!(private_key && ENV.key?('HOME'))
end
end
end

View file

@ -6,7 +6,7 @@ module Fog
data = { 'health_monitor' => {} }
vanilla_options = [:delay, :timeout, :max_retries, :http_method, :url_path, :expected_codes, :admin_state_up]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['health_monitor'][key] = options[key]
end

View file

@ -6,7 +6,7 @@ module Fog
data = { 'member' => {} }
vanilla_options = [:pool_id, :weight, :admin_state_up]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['member'][key] = options[key]
end

View file

@ -6,7 +6,7 @@ module Fog
data = { 'pool' => {} }
vanilla_options = [:name, :description, :lb_method, :admin_state_up]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['pool'][key] = options[key]
end

View file

@ -6,7 +6,7 @@ module Fog
data = { 'vip' => {} }
vanilla_options = [:pool_id, :name, :description, :session_persistence, :connection_limit, :admin_state_up]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['vip'][key] = options[key]
end

View file

@ -6,7 +6,7 @@ module Fog
data = { 'network' => {} }
vanilla_options = [:name, :shared, :admin_state_up]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['network'][key] = options[key]
end

View file

@ -7,7 +7,7 @@ module Fog
vanilla_options = [:name, :fixed_ips, :admin_state_up, :device_owner,
:device_id]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['port'][key] = options[key]
end

View file

@ -7,7 +7,7 @@ module Fog
vanilla_options = [:name, :gateway_ip, :dns_nameservers,
:host_routes, :enable_dhcp]
vanilla_options.select{ |o| options.has_key?(o) }.each do |key|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
data['subnet'][key] = options[key]
end

View file

@ -4,7 +4,7 @@ module Fog
class Real
def destroy_interface(id, options)
raise ArgumentError, "instance id is a required parameter" unless id
raise ArgumentError, "interface id is a required parameter for destroy-interface" unless options.has_key? :id
raise ArgumentError, "interface id is a required parameter for destroy-interface" unless options.key? :id
client.destroy_interface(id, options[:id])
end
@ -13,7 +13,7 @@ module Fog
class Mock
def destroy_interface(id, options)
raise ArgumentError, "instance id is a required parameter" unless id
raise ArgumentError, "interface id is a required parameter for destroy-interface" unless options.has_key? :id
raise ArgumentError, "interface id is a required parameter for destroy-interface" unless options.key? :id
true
end
end

View file

@ -3,14 +3,14 @@ module Fog
class Ovirt
class Real
def destroy_vm(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
client.destroy_vm(options[:id])
end
end
class Mock
def destroy_vm(options = {})
raise ArgumentError, "instance id is a required parameter" unless options.has_key? :id
raise ArgumentError, "instance id is a required parameter" unless options.key? :id
true
end
end

View file

@ -4,7 +4,7 @@ module Fog
class Real
def destroy_volume(id, options)
raise ArgumentError, "instance id is a required parameter" unless id
raise ArgumentError, "volume id is a required parameter for destroy-volume" unless options.has_key? :id
raise ArgumentError, "volume id is a required parameter for destroy-volume" unless options.key? :id
client.destroy_volume(id, options[:id])
end
@ -13,7 +13,7 @@ module Fog
class Mock
def destroy_volume(id, options)
raise ArgumentError, "instance id is a required parameter" unless id
raise ArgumentError, "volume id is a required parameter for destroy-volume" unless options.has_key? :id
raise ArgumentError, "volume id is a required parameter for destroy-volume" unless options.key? :id
true
end
end

Some files were not shown because too many files have changed in this diff Show more