mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
use the new more persistent data store for mocks
This commit is contained in:
parent
37c8ce7bd7
commit
2c25fae5f1
13 changed files with 28 additions and 28 deletions
|
@ -35,7 +35,7 @@ else
|
|||
'instanceId' => '',
|
||||
'publicIp' => public_ip
|
||||
}
|
||||
@data[:addresses][public_ip] = data
|
||||
Fog::AWS::EC2.data[:addresses][public_ip] = data
|
||||
response.body = {
|
||||
'publicIp' => public_ip,
|
||||
'requestId' => Fog::AWS::Mock.request_id
|
||||
|
|
|
@ -35,14 +35,14 @@ else
|
|||
|
||||
def create_key_pair(key_name)
|
||||
response = Fog::Response.new
|
||||
unless @data[:key_pairs][key_name]
|
||||
unless Fog::AWS::EC2.data[:key_pairs][key_name]
|
||||
response.status = 200
|
||||
data = {
|
||||
'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
|
||||
'keyMaterial' => Fog::AWS::Mock.key_material,
|
||||
'keyName' => key_name
|
||||
}
|
||||
@data[:key_pairs][key_name] = data
|
||||
Fog::AWS::EC2.data[:key_pairs][key_name] = data
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id
|
||||
}.merge!(data)
|
||||
|
|
|
@ -35,14 +35,14 @@ else
|
|||
|
||||
def create_security_group(name, description)
|
||||
response = Fog::Response.new
|
||||
unless @data[:security_groups][name]
|
||||
unless Fog::AWS::EC2.data[:security_groups][name]
|
||||
data = {
|
||||
'GroupDescription' => description,
|
||||
'GroupName' => name,
|
||||
'ipPermissions' => [],
|
||||
'OwnerId' => Fog::AWS::Mock.owner_id
|
||||
}
|
||||
@data[:security_groups][name] = data
|
||||
Fog::AWS::EC2.data[:security_groups][name] = data
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
|
|
|
@ -52,7 +52,7 @@ else
|
|||
'status' => 'creating',
|
||||
'volumeId' => volume_id
|
||||
}
|
||||
@data[:volumes][volume_id] = data
|
||||
Fog::AWS::EC2.data[:volumes][volume_id] = data
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id
|
||||
}.merge!(data.reject {|key,value| !['availabilityZone','createTime','size','snapshotId','status','volumeId'].include?(key) })
|
||||
|
|
|
@ -33,7 +33,7 @@ else
|
|||
|
||||
def delete_key_pair(key_name)
|
||||
response = Fog::Response.new
|
||||
@data[:key_pairs].delete(key_name)
|
||||
Fog::AWS::EC2.data[:key_pairs].delete(key_name)
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
|
|
|
@ -32,8 +32,8 @@ else
|
|||
class EC2
|
||||
def delete_security_group(name)
|
||||
response = Fog::Response.new
|
||||
if @data[:security_groups][name]
|
||||
@data[:security_groups].delete(name)
|
||||
if Fog::AWS::EC2.data[:security_groups][name]
|
||||
Fog::AWS::EC2.data[:security_groups].delete(name)
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
|
|
|
@ -33,13 +33,13 @@ else
|
|||
|
||||
def delete_volume(volume_id)
|
||||
response = Fog::Response.new
|
||||
if volume = @data[:volumes][volume_id]
|
||||
@data[:deleted_at][volume['volumeId']] = Time.now
|
||||
if volume = Fog::AWS::EC2.data[:volumes][volume_id]
|
||||
Fog::AWS::EC2.data[:deleted_at][volume['volumeId']] = Time.now
|
||||
volume['status'] = 'deleting'
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'return' => true
|
||||
'return' => true
|
||||
}
|
||||
else
|
||||
response.status = 400
|
||||
|
|
|
@ -34,12 +34,12 @@ else
|
|||
class EC2
|
||||
|
||||
def describe_addresses(public_ip = [])
|
||||
public_ip = [*public_ip]
|
||||
response = Fog::Response.new
|
||||
public_ip = [*public_ip]
|
||||
if public_ip != []
|
||||
addresses_set = @data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
|
||||
addresses_set = Fog::AWS::EC2.data[:addresses].reject {|key, value| !public_ip.include?(key)}.values
|
||||
else
|
||||
addresses_set = @data[:addresses].values
|
||||
addresses_set = Fog::AWS::EC2.data[:addresses].values
|
||||
end
|
||||
if public_ip.length == 0 || public_ip.length == addresses_set.length
|
||||
response.status = 200
|
||||
|
|
|
@ -34,12 +34,12 @@ else
|
|||
class EC2
|
||||
|
||||
def describe_key_pairs(key_name = [])
|
||||
key_name = [*key_name]
|
||||
response = Fog::Response.new
|
||||
key_name = [*key_name]
|
||||
if key_name != []
|
||||
key_set = @data[:key_pairs].reject {|key, value| !key_name.include?(key)}.values
|
||||
key_set = Fog::AWS::EC2.data[:key_pairs].reject {|key, value| !key_name.include?(key)}.values
|
||||
else
|
||||
key_set = @data[:key_pairs].values
|
||||
key_set = Fog::AWS::EC2.data[:key_pairs].values
|
||||
end
|
||||
if key_name.length == 0 || key_name.length == key_set.length
|
||||
response.status = 200
|
||||
|
|
|
@ -44,12 +44,12 @@ else
|
|||
class EC2
|
||||
|
||||
def describe_security_groups(group_name = [])
|
||||
group_name = [*group_name]
|
||||
response = Fog::Response.new
|
||||
group_name = [*group_name]
|
||||
if group_name != []
|
||||
security_group_info = @data[:security_groups].reject {|key, value| !group_name.include?(key)}.values
|
||||
security_group_info = Fog::AWS::EC2.data[:security_groups].reject {|key, value| !group_name.include?(key)}.values
|
||||
else
|
||||
security_group_info = @data[:security_groups].values
|
||||
security_group_info = Fog::AWS::EC2.data[:security_groups].values
|
||||
end
|
||||
if group_name.length == 0 || group_name.length == security_group_info.length
|
||||
response.status = 200
|
||||
|
|
|
@ -43,12 +43,12 @@ else
|
|||
class EC2
|
||||
|
||||
def describe_volumes(volume_id = [])
|
||||
volume_id = [*volume_id]
|
||||
response = Fog::Response.new
|
||||
volume_id = [*volume_id]
|
||||
if volume_id != []
|
||||
volume_set = @data[:volumes].reject {|key,value| !volume_id.include?(key)}.values
|
||||
volume_set = Fog::AWS::EC2.data[:volumes].reject {|key,value| !volume_id.include?(key)}.values
|
||||
else
|
||||
volume_set = @data[:volumes].values
|
||||
volume_set = Fog::AWS::EC2.data[:volumes].values
|
||||
end
|
||||
|
||||
volume_set.each do |volume|
|
||||
|
@ -58,9 +58,9 @@ else
|
|||
volume['status'] = 'available'
|
||||
end
|
||||
when 'deleting'
|
||||
if Time.now - @data[:deleted_at][volume['volumeId']] > 2
|
||||
@data[:deleted_at].delete(volume['volumeId'])
|
||||
@data[:volumes].delete(volume['volumeId'])
|
||||
if Time.now - Fog::AWS::EC2.data[:deleted_at][volume['volumeId']] > 2
|
||||
Fog::AWS::EC2.data[:deleted_at].delete(volume['volumeId'])
|
||||
Fog::AWS::EC2.data[:volumes].delete(volume['volumeId'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ else
|
|||
|
||||
def release_address(public_ip)
|
||||
response = Fog::Response.new
|
||||
if (address = @data[:addresses].delete(public_ip))
|
||||
if (address = Fog::AWS::EC2.data[:addresses].delete(public_ip))
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
|
|
Loading…
Reference in a new issue