mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack|compute] Add requests, models and tests for address
management - Fixed other tests, but tests for address has a problem. - Needs to be revisited.
This commit is contained in:
parent
b122f0c85e
commit
fc88380f4a
4 changed files with 52 additions and 19 deletions
|
@ -11,9 +11,16 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
|
||||
|
||||
|
||||
def associate_address(server_id, ip_address)
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.headers = {
|
||||
"Content-Type" => "text/html, charset=UTF-8",
|
||||
"Content-Length" => "0",
|
||||
"Date"=> Date.new
|
||||
}
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
Shindo.tests('Fog::Compute[:openstack] | address requests', ['openstack']) do
|
||||
# clean the servers
|
||||
=begin
|
||||
@servers = Fog::Compute[:openstack].servers.each do |server|
|
||||
Fog::Compute[:openstack].list_all_addresses(server.id).body['floating_ips'].each do |ip_add|
|
||||
Fog::Compute[:openstack].release_address(ip_add['id'])
|
||||
end
|
||||
|
||||
Fog::Compute[:openstack].delete_server(server.id)
|
||||
end
|
||||
=end
|
||||
|
||||
@server = Fog::Compute[:openstack].create_server("shindo_test_server", Fog::Compute[:openstack].list_images.body['images'].last['links'].first['href'], Fog::Compute[:openstack].list_flavors.body['flavors'].first['links'].first['href'])
|
||||
|
||||
@address_format = {
|
||||
"instance_id" => NilClass,
|
||||
"ip" => String,
|
||||
|
@ -13,15 +26,22 @@ Shindo.tests('Fog::Compute[:openstack] | address requests', ['openstack']) do
|
|||
end
|
||||
|
||||
tests('#list_all_addresses(server_id)').formats({"floating_ips" => [@address_format]}) do
|
||||
Fog::Compute[:openstack].list_all_addresses("sd34234dvsdasdmlk123cdslfck1").body
|
||||
Fog::Compute[:openstack].list_all_addresses(@server.body['server']['id']).body
|
||||
end
|
||||
|
||||
tests('#get_address(address_id)').formats({"floating_ip" => @address_format}) do
|
||||
Fog::Compute[:openstack].get_address(1).body
|
||||
address_id = Fog::Compute[:openstack].addresses.all(Fog::Compute[:openstack].servers.last.id).first.id
|
||||
Fog::Compute[:openstack].get_address(address_id).body
|
||||
end
|
||||
|
||||
tests('#associate_address(server_id, ip_address)').succeeds do
|
||||
address_ip = Fog::Compute[:openstack].addresses.all(Fog::Compute[:openstack].servers.last.id).first.ip
|
||||
Fog::Compute[:openstack].associate_address(@server.body['server']['id'], address_ip).body
|
||||
end
|
||||
|
||||
tests('#disassociate_address(server_id, ip_address)').succeeds do
|
||||
Fog::Compute[:openstack].disassociate_address("sd34234dvsdasdmlk123cdslfck1", "192.168.27.129").body
|
||||
address_ip = Fog::Compute[:openstack].addresses.all(Fog::Compute[:openstack].servers.last.id).first.ip
|
||||
Fog::Compute[:openstack].disassociate_address(@server.body['server']['id'], address_ip).body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,11 +20,11 @@ Shindo.tests('Fog::Compute[:openstack] | keypair requests', ['openstack']) do
|
|||
end
|
||||
|
||||
tests('#list_key_pairs').formats({"keypairs" => [{"keypair" => @keypair_list_format}]}) do
|
||||
Fog::Compute[:openstack].list_key_pairs
|
||||
Fog::Compute[:openstack].list_key_pairs.body
|
||||
end
|
||||
|
||||
tests('#delete_key_pair(key_name)').succeeds do
|
||||
Fog::Compute[:openstack].delete_key_pair(1)
|
||||
Fog::Compute[:openstack].delete_key_pair('from_shindo_test')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Shindo.tests('Fog::Compute[:openstack] | security group requests', ['openstack']) do
|
||||
@security_group = Hash.new
|
||||
@security_group_rule = Hash.new
|
||||
@security_group_format = {
|
||||
"rules" => Array,
|
||||
"tenant_id" => String,
|
||||
|
@ -18,28 +20,32 @@ Shindo.tests('Fog::Compute[:openstack] | security group requests', ['openstack']
|
|||
}
|
||||
|
||||
tests('success') do
|
||||
tests('#create_security_group(name, description)').formats({"security_group" => [@security_group_format]}) do
|
||||
Fog::Compute[:openstack].create_security_group('from_shindo_test', 'this is from the shindo test').body
|
||||
end
|
||||
|
||||
tests('#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)').formats({"security_group_rule" => @security_group_rule_format}) do
|
||||
parent_group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
|
||||
Fog::Compute[:openstack].create_security_group_rule(parent_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body
|
||||
end
|
||||
|
||||
tests('#list_security_groups').formats({"security_groups" => [@security_group_format]}) do
|
||||
Fog::Compute[:openstack].list_security_groups.body
|
||||
end
|
||||
|
||||
tests('#get_security_group(security_group_id)').formats({"security_group" => @security_group_format}) do
|
||||
Fog::Compute[:openstack].get_security_group(1).body
|
||||
end
|
||||
|
||||
tests('#create_security_group(name, description)').formats({"security_groups" => [@security_group_format]}) do
|
||||
Fog::Compute[:openstack].create_security_group('test', 'this is from the test').body
|
||||
end
|
||||
|
||||
tests('#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)').formats({"security_group_rule" => @security_group_rule_format}) do
|
||||
Fog::Compute[:openstack].create_security_group_rule(1, "tcp", 2, 3, "10.10.10.10/24").body
|
||||
group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
|
||||
Fog::Compute[:openstack].get_security_group(group_id).body
|
||||
end
|
||||
|
||||
tests('#delete_security_group_rule(security_group_rule_id)').succeeds do
|
||||
Fog::Compute[:openstack].delete_security_group_rule(1)
|
||||
security_group_rule_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['rules'].last['id']
|
||||
Fog::Compute[:openstack].delete_security_group_rule(security_group_rule_id)
|
||||
end
|
||||
|
||||
tests('#delete_security_group(security_group_id)').succeeds do
|
||||
Fog::Compute[:openstack].delete_security_group(1)
|
||||
group_id = Fog::Compute[:openstack].list_security_groups.body['security_groups'].last['id']
|
||||
Fog::Compute[:openstack].delete_security_group(group_id)
|
||||
end
|
||||
end # tests('success')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue