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

add a number of tests for cloudstack requests

This commit is contained in:
Athir Nuaimi 2014-12-22 08:43:00 -05:00
parent ea08946d02
commit 8d8ef13cc5
22 changed files with 454 additions and 70 deletions

View file

@ -741,6 +741,27 @@ module Fog
"restartrequired" => false,
"specifyipranges" => true}
},
:public_ip_addresses => { "0e276270-7950-4483-bf21-3dc897dbe08a" => {
"id" => "0e276270-7950-4483-bf21-3dc897dbe08a",
"ipaddress" => "192.168.200.2",
"allocated" => "2014-11-26T22:32:39+0000",
"zoneid" => "0e276270-7950-4483-bf21-3dc897dbe08a",
"zonename" => "Toronto",
"issourcenat" => false,
"projectid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"project" => "TestProject",
"domainid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"domain" => "TestDomain",
"forvirtualnetwork" => true,
"isstaticnat" => false,
"issystem" => false,
"associatednetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"associatednetworkname" => "TestNetwork",
"networkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"state" => "Allocated",
"physicalnetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"tags" => []
}},
:zones => { zone_id => {
"id" => zone_id,
"name" => "zone-00",
@ -788,7 +809,8 @@ module Fog
"offerha" => false,
"limitcpuuse" => false,
"issystem" => false,
"defaultuse" => false}},
"defaultuse" => false
}},
:accounts => { account_id => {
"id" => account_id,
"name" => "accountname",
@ -881,6 +903,37 @@ module Fog
"storagetype" => "shared"
}
},
:network_offerings => {
"cc4de87d-672d-4353-abb5-6a8a4c0abf59" => {
"id" => "cc4de87d-672d-4353-abb5-6a8a4c0abf59",
"name" => "Shared Network With Security Groups",
"displaytext" => "Shared Network With Security Groups",
"traffictype" => "Guest",
"isdefault" => true,
"specifyvlan" => true,
"conservemode" => true,
"specifyipranges" => true,
"availability" => "Optional",
"networkrate" => 200,
"state" => "Enabled",
"guestiptype" => "Shared",
"serviceofferingid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1"
}
},
:firewall_rules => {
"f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1" => {
"id"=> "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"protocol"=> "tcp",
"startport" => "443",
"endport" => "443",
"ipaddressid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"networkid"=> network_id,
"ipaddress" => "192.168.200.1",
"state" => "Active",
"cidrlist" => "255.255.255.0/24",
"tags" => []
}
},
:egress_firewall_rules => {
"f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1" => {
"id"=>"f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
@ -891,6 +944,24 @@ module Fog
"tags"=>[]
}
},
:port_forwarding_rules => {
"8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3" => {
'id' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3",
'privateport' => "25",
'privateendport' => "25",
'protocol' => "tcp",
'publicport' => "25",
'publicendport' => "25",
'virtualmachineid' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3",
'virtualmachinename' => "LoadBalancer",
'virtualmachinedisplayname' => "LoadBalancer",
'ipaddressid' => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
'ipaddress' => "192.168.200.200",
'state' => "Active",
'cidrlist' => "",
'tags' => []
}
},
:os_types => {
"51ef854d-279e-4e68-9059-74980fd7b29b" => {
"id" => "51ef854d-279e-4e68-9059-74980fd7b29b",

View file

@ -34,15 +34,15 @@ module Fog
'tags' => tags
}
response = service.create_disk_offering(options)
merge_attributes(response['creatediskofferingresponse'])
response = service.associate_ip_address(options)
merge_attributes(response['associateipaddressresponse'])
end
def destroy
requires :id
response = service.disassociate_ip_address('id' => id )
success_status = response['deletediskofferingresponse']['success']
success_status = response['disassociateipaddressresponse']['success']
success_status == 'true'
end

View file

@ -20,6 +20,35 @@ module Fog
end
end
class Mock
def associate_ip_address(*args)
public_ip_address = {
"id" => "f2f2f2f2-f2f2-f2f2-f2f2-f2f2f2f2f2",
"ipaddress" => "192.168.200.3",
"allocated" => "2014-12-22T22:32:39+0000",
"zoneid" => "0e276270-7950-4483-bf21-3dc897dbe08a",
"zonename" => "Toronto",
"issourcenat" => false,
"projectid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"project" => "TestProject",
"domainid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"domain" => "TestDomain",
"forvirtualnetwork" => true,
"isstaticnat" => false,
"issystem" => false,
"associatednetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"associatednetworkname" => "TestNetwork",
"networkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"state" => "Allocated",
"physicalnetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
"tags" => []
}
self.data[:public_ip_addresses][public_ip_address_id]= public_ip_address
{'associateipaddressresponse' => public_ip_address}
end
end
end
end
end

View file

@ -20,6 +20,28 @@ module Fog
end
end
class Mock
def create_firewall_rule(options={})
firewall_rule_id = Fog::Cloudstack.uuid
firewall_rule = {
"id" => network_offering_id,
"protocol" => "tcp",
"startport" => 80,
"endport" => 80,
"ipaddressid" => "f1f1f1f1-f1f1-f1f1-f1f1f1f1f1f1",
"networkid" => "f1f1f1f1-f1f1-f1f1-f1f1f1f1f1f1",
"ipaddress" => "10.1.1.253",
"state" => "Active",
"cidrlist" => "255.255.255.0/24"
}
self.data[:firewall_rules][firewall_rule_id] = firewall_ruleetwork_offering
{'createfirewallruleresponse' => firewall_rule}
end
end
end
end
end

View file

@ -23,6 +23,32 @@ module Fog
end
end
class Mock
def create_network_offering(options={})
network_offering_id = Fog::Cloudstack.uuid
network_offering = {
"id" => network_offering_id,
"name" => "Isolated Network for VPC",
"displaytext" => "Isolated Network for VPC",
"traffictype" => "Guest",
"isdefault" => true,
"specifyvlan" => true,
"conservemode" => true,
"specifyipranges" => false,
"availability" => "Optional",
"networkrate" => 200,
"state" => "Enabled",
"guestiptype" => "Isolated",
"serviceofferingid" => "eaec129c-f1f1-f1f1-f1f1-a379f6b2897d"
}
self.data[:network_offerings][network_offering_id] = network_offering
{'createnetworkofferingresponse' => network_offering}
end
end
end
end
end

View file

@ -23,6 +23,32 @@ module Fog
end
end
class Mock
def create_port_forwarding_rule(*args)
port_forwarding_rule_id = "43192143-5828-6831-58286837474"
port_forwarding_rule = {
'id' => port_forwarding_rule_id,
'privateport' => "110",
'privateendport' => "110",
'protocol' => "tcp",
'publicport' => "111",
'publicendport' => "111",
'virtualmachineid' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3",
'virtualmachinename' => "Pop3LoadBalancer",
'virtualmachinedisplayname' => "Pop3LoadBalancer",
'ipaddressid' => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1",
'ipaddress' => "192.168.200.201",
'state' => "Active",
'cidrlist' => "",
'tags' => []
}
self.data[:port_forwarding_rules][port_forwarding_rule_id]= port_forwarding_rule
{'createportforwardingruleresponse' => port_forwarding_rule}
end
end
end
end
end

View file

@ -20,6 +20,35 @@ module Fog
end
end
class Mock
def create_service_offering(options={})
flavour_id = Fog::Cloudstack.uuid
flavour = {
"id" => flavour_id,
"name" => "4CPU, 4 GB RAM, High Availability",
"displaytext" => "4CPU, 4 GB RAM, High Availability",
"cpunumber" => 4,
"cpuspeed" => 2000,
"memory" => 4096,
"created" => Time.now.iso8601,
"storagetype" => "shared",
"offerha" => true,
"limitcpuuse" => false,
"isvolatile" => false,
"issytem" => false,
"defaultuse" => false,
"iscustomized" => false,
"tags" => []
}
self.data[:flavours][flavour_id] = flavour
{'createserviceofferingresponse' => flavour}
end
end
end
end
end

View file

@ -19,6 +19,15 @@ module Fog
end
end
class Mock
def delete_firewall_rule(options={})
firewall_rule_id = options['id']
data[:firewall_rules].delete(firewall_rule_id) if data[:firewall_rules][firewall_rule_id]
{ 'deletefirewallruleresponse' => { 'success' => 'true' } }
end
end
end
end
end

View file

@ -19,6 +19,15 @@ module Fog
end
end
class Mock
def delete_network_offering(options={})
network_offering_id = options['id']
data[:network_offerings].delete(network_offering_id) if data[:network_offerings][network_offering_id]
{ 'deletenetworkofferingresponse' => { 'success' => 'true' } }
end
end
end
end
end

View file

@ -19,6 +19,15 @@ module Fog
end
end
class Mock
def delete_service_offering(options={})
service_offering_id = options['id']
data[:favours].delete(service_offering_id) if data[:flavours][service_offering_id]
{ 'deleteserviceofferingresponse' => { 'success' => 'true' } }
end
end
end
end
end

View file

@ -19,6 +19,16 @@ module Fog
end
end
class Mock
def disassociate_ip_address(*args)
public_ip_address_id = options['id']
if self.data[:public_ip_addresses][public_ip_address_id]
self.data[:public_ip_addresses].delete(public_ip_address_id)
{ "disassociateipaddressresponse" => { "success" => "true" }}
end
end
end
end
end
end

View file

@ -22,6 +22,13 @@ module Fog
end
end
class Mock
def list_firewall_rules(*arg)
firewall_rules = self.data[:firewall_rules]
{ "listfirewallrulesresponse" => { "count"=> firewall_rules.count, "firewallrule"=> firewall_rules.values } }
end
end
end
end
end

View file

@ -18,6 +18,13 @@ module Fog
end
end
class Mock
def list_network_offerings(*arg)
network_offerings = self.data[:network_offerings]
{ "listnetworkofferingsresponse" => { "count"=> network_offerings.count, "networkoffering"=> network_offerings.values } }
end
end
end
end
end

View file

@ -22,6 +22,18 @@ module Fog
end
end
class Mock
def list_port_forwarding_rules(*args)
port_forwarding_rules = self.data[:port_forwarding_rules]
{
'listportforwardingrulesresponse' => {
'count' => port_forwarding_rules.size,
'portforwardingrule' => port_forwarding_rules.values
}
}
end
end
end
end
end

View file

@ -22,6 +22,13 @@ module Fog
end
end
class Mock
def list_public_ip_addresses(*arg)
public_ip_addresses = self.data[:public_ip_addresses]
{ "listpublicipaddressesresponse" => { "count"=> public_ip_addresses.count, "publicipaddress"=> public_ip_addresses.values } }
end
end
end
end
end

View file

@ -21,22 +21,9 @@ module Fog
class Mock
def list_service_offerings(options={})
flavors = []
if service_offering_id = options['id']
flavor = self.data[:flavors][service_offering_id]
raise Fog::Compute::Cloudstack::BadRequest unless flavor
flavors = [flavor]
else
flavors = self.data[:flavors].values
end
flavors = self.data[:flavors]
{
"listserviceofferingsresponse" =>
{
"count" => flavors.size,
"serviceoffering"=> flavors
}
}
{ "listserviceofferingsresponse" => { "count" => flavors.size, "serviceoffering"=> flavors.values}}
end
end
end

View file

@ -0,0 +1,29 @@
Shindo.tests('Fog::Compute[:cloudstack] | firewall rule requests', ['cloudstack']) do
@firewall_rules_format = {
'listfirewallrulesresponse' => {
'count' => Integer,
'firewallrule' => [
'id' => String,
'protocol' => String,
'startport' => String,
'endport' => String,
'ipaddressid' => String,
'networkid' => String,
'ipaddress' => String,
'state' => String,
'cidrlist' => String,
'tags' => Fog::Nullable::Array
]
}
}
tests('success') do
tests('#list_firewall_rules').formats(@firewall_rules_format) do
Fog::Compute[:cloudstack].list_firewall_rules
end
end
end

View file

@ -0,0 +1,32 @@
Shindo.tests('Fog::Compute[:cloudstack] | network offering requests', ['cloudstack']) do
@network_offerings_format = {
'listnetworkofferingsresponse' => {
'count' => Integer,
'networkoffering' => [
'id' => String,
'name' => String,
'displaytext' => String,
'traffictype' => String,
'isdefault' => Fog::Boolean,
'specifyvlan' => Fog::Boolean,
'conservemode' => Fog::Boolean,
'specifyipranges' => Fog::Boolean,
'availability' => String,
'networkrate' => Integer,
'state' => String,
'guestiptype' => String,
'serviceofferingid' => String,
]
}
}
tests('success') do
tests('#list_network_offerings').formats(@network_offerings_format) do
Fog::Compute[:cloudstack].list_network_offerings
end
end
end

View file

@ -0,0 +1,33 @@
Shindo.tests('Fog::Compute[:cloudstack] | port forwarding rule requests', ['cloudstack']) do
@port_forwarding_rule_format = {
'listportforwardingrulesresponse' => {
'count' => Integer,
'portforwardingrule' => [
'id' => String,
'privateport' => String,
'privateendport' => String,
'protocol' => String,
'publicport' => String,
'publicendport' => String,
'virtualmachineid' => String,
'virtualmachinename' => String,
'virtualmachinedisplayname' => String,
'ipaddressid' => String,
'ipaddress' => String,
'state' => String,
'cidrlist' => String,
'tags' => Fog::Nullable::Array
]
}
}
tests('success') do
tests('#list_port_forwarding_rules').formats(@port_forwarding_rule_format) do
Fog::Compute[:cloudstack].list_port_forwarding_rules('zoneid' => 1)
end
end
end

View file

@ -0,0 +1,38 @@
Shindo.tests('Fog::Compute[:cloudstack] | public ip address requests', ['cloudstack']) do
@public_ip_addresses_format = {
'listpublicipaddressesresponse' => {
'count' => Integer,
'publicipaddress' => [
'id' => String,
'ipaddress' => String,
'allocated' => String,
'zoneid' => String,
'zonename' => String,
'issourcenat' => Fog::Boolean,
'projectid' => String,
'project' => String,
'domainid' => String,
'domain' => String,
'forvirtualnetwork' => Fog::Boolean,
'isstaticnat' => Fog::Boolean,
'issystem' => Fog::Boolean,
'associatednetworkid' => String,
'associatednetworkname' => String,
'networkid' => String,
'state' => String,
'physicalnetworkid' => String,
'tags' => Fog::Nullable::Array
]
}
}
tests('success') do
tests('#list_public_ip_addresses').formats(@public_ip_addresses_format) do
Fog::Compute[:cloudstack].list_public_ip_addresses
end
end
end

View file

@ -4,24 +4,18 @@ Shindo.tests('Fog::Compute[:cloudstack] | service offering requests', ['cloudsta
'listserviceofferingsresponse' => {
'count' => Integer,
'serviceoffering' => [
'id' => Integer,
'id' => String,
'name' => String,
'displaytext' => String,
'cpuspeed' => Integer,
'cpunumber' => Integer,
'created' => String,
'defaultuse' => Fog::Boolean,
'displaytext' => String,
'domain' => Fog::Nullable::String,
'domainid' => Fog::Nullable::Integer,
'hosttags' => Fog::Nullable::String,
'issystem' => Fog::Boolean,
'limitcpuuse' => Fog::Boolean,
'memory' => Integer,
'name' => String,
'networkrate' => Integer,
'offerha' => Fog::Boolean,
'created' => String,
'storagetype' => String,
'systemvmtype' => Fog::Nullable::String,
'tags' => Fog::Nullable::String
'offerha' => Fog::Boolean,
'limitcpuuse' => Fog::Boolean,
'issystem' => Fog::Boolean,
'defaultuse' => Fog::Boolean
]
}
}
@ -29,7 +23,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | service offering requests', ['cloudsta
tests('success') do
tests('#list_service_offerings').formats(@service_offerings_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_service_offerings
end

View file

@ -4,27 +4,27 @@ Shindo.tests('Fog::Compute[:cloudstack] | volume requests', ['cloudstack']) do
'listvolumesresponse' => {
'count' => Integer,
'volume' => [
'id' => Integer,
'id' => String,
'name' => String,
'zoneid' => Integer,
'zoneid' => String,
'zonename' => String,
'type' => String,
'size' => Integer,
'created' => String,
'account' => String,
'domainid' => Integer,
'domainid' => String,
'domain' => String,
'state' => String,
'storagetype' => String,
'hypervisor' => String,
'diskofferingid' => Fog::Nullable::Integer,
'diskofferingid' => Fog::Nullable::String,
'diskofferingname' => Fog::Nullable::String,
'diskofferingdisplaytext' => Fog::Nullable::String,
'storage' => String,
'destroyed' => Fog::Boolean,
'isextractable' => Fog::Boolean,
'deviceid' => Fog::Nullable::Integer,
'virtualmachineid' => Fog::Nullable::Integer,
'virtualmachineid' => Fog::Nullable::String,
'vmname' => Fog::Nullable::String,
'vmdisplayname' => Fog::Nullable::String,
'vmstate' => Fog::Nullable::String,
@ -39,7 +39,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | volume requests', ['cloudstack']) do
tests('success') do
tests('#list_volumes').formats(@volumes_format) do
pending if Fog.mocking?
Fog::Compute[:cloudstack].list_volumes('zoneid' => 1)
end