From 1a753624b829fd353f69020237154fa948f9d842 Mon Sep 17 00:00:00 2001 From: Dmitry Dedov Date: Thu, 11 Apr 2013 11:21:58 +0300 Subject: [PATCH 1/3] [cloudstack] add disk_offerings, os_types mock data --- lib/fog/cloudstack/compute.rb | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/fog/cloudstack/compute.rb b/lib/fog/cloudstack/compute.rb index 09a24380e..948593918 100644 --- a/lib/fog/cloudstack/compute.rb +++ b/lib/fog/cloudstack/compute.rb @@ -422,7 +422,43 @@ module Fog :jobs => {}, :volumes => {}, :security_groups => {}, - :snapshots => {} + :snapshots => {}, + :disk_offerings => { + "cc4de87d-672d-4353-abb5-6a8a4c0abf59" => { + "id" => "cc4de87d-672d-4353-abb5-6a8a4c0abf59", + "domainid" => domain_id, + "domain" => domain_name, + "name" => "Small Disk", + "displaytext" => "Small Disk [16GB Disk]", + "disksize" => 16, + "created" => "2013-02-21T03:12:520300", + "iscustomized" => false, + "storagetype" => "shared" + }, + "d5deeb0c-de03-4ebf-820a-dc74221bcaeb" => { + "id" => "d5deeb0c-de03-4ebf-820a-dc74221bcaeb", + "domainid" => domain_id, + "domain" => domain_name, + "name" => "Medium Disk", + "displaytext" => "Medium Disk [32GB Disk]", + "disksize" => 32, + "created" => "2013-02-21T03:12:520300", + "iscustomized" => false, + "storagetype" => "shared" + } + }, + :os_types => { + "51ef854d-279e-4e68-9059-74980fd7b29b" => { + "id" => "51ef854d-279e-4e68-9059-74980fd7b29b", + "oscategoryid" => "56f67279-e082-45c3-a01c-d290d6cd4ce2", + "description" => "Asianux 3(32-bit)" + }, + "daf124c8-95d8-4756-8e1c-1871b073babb" => { + "id" => "daf124c8-95d8-4756-8e1c-1871b073babb", + "oscategoryid" => "56f67279-e082-45c3-a01c-d290d6cd4ce2", + "description" => "Asianux 3(64-bit)" + } + } } end end From ba6242f64d76a4557bc9f086016eaf37f9380278 Mon Sep 17 00:00:00 2001 From: Dmitry Dedov Date: Thu, 11 Apr 2013 11:31:18 +0300 Subject: [PATCH 2/3] [cloudstack] add list_os_types, list_disk_offerings request mocks --- .../cloudstack/requests/compute/list_disk_offerings.rb | 9 +++++++++ lib/fog/cloudstack/requests/compute/list_os_types.rb | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/fog/cloudstack/requests/compute/list_disk_offerings.rb b/lib/fog/cloudstack/requests/compute/list_disk_offerings.rb index 79a8e3eb4..08bc816b5 100644 --- a/lib/fog/cloudstack/requests/compute/list_disk_offerings.rb +++ b/lib/fog/cloudstack/requests/compute/list_disk_offerings.rb @@ -15,6 +15,15 @@ module Fog end end + + class Mock + # TODO: add id, name filters and paging params + def list_disk_offerings(options={}) + disk_offerings = self.data[:disk_offerings] + { "listdiskofferingsresponse" => { "count"=> disk_offerings.count, "diskoffering"=> disk_offerings.values } } + end + + end end end end diff --git a/lib/fog/cloudstack/requests/compute/list_os_types.rb b/lib/fog/cloudstack/requests/compute/list_os_types.rb index 819e690ae..e7ad65037 100644 --- a/lib/fog/cloudstack/requests/compute/list_os_types.rb +++ b/lib/fog/cloudstack/requests/compute/list_os_types.rb @@ -15,6 +15,15 @@ module Fog end end + + class Mock + # TODO: add id, category_id filters and paging params + def list_os_types(options={}) + os_types = self.data[:os_types] + { "listostypesresponse" => { "count"=> os_types.count, "ostype"=> os_types.values } } + end + + end end end end From cb51eebd0ce7ba5adc7d5c678452eca75d76aeb6 Mon Sep 17 00:00:00 2001 From: Dmitry Dedov Date: Thu, 11 Apr 2013 12:22:48 +0300 Subject: [PATCH 3/3] [cloudstack] list_os_types, list_disk_offerings request tests, rm pending --- tests/cloudstack/requests/disk_offering_tests.rb | 6 +++--- tests/cloudstack/requests/os_type_tests.rb | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/cloudstack/requests/disk_offering_tests.rb b/tests/cloudstack/requests/disk_offering_tests.rb index d9ad34bfe..d4802e805 100644 --- a/tests/cloudstack/requests/disk_offering_tests.rb +++ b/tests/cloudstack/requests/disk_offering_tests.rb @@ -4,14 +4,15 @@ Shindo.tests('Fog::Compute[:cloudstack] | disk offering requests', ['cloudstack' 'listdiskofferingsresponse' => { 'count' => Integer, 'diskoffering' => [ - 'id' => Integer, + 'id' => String, 'created' => String, 'disksize' => Integer, 'displaytext' => String, 'domain' => Fog::Nullable::String, - 'domainid' => Fog::Nullable::Integer, + 'domainid' => Fog::Nullable::String, 'iscustomized' => Fog::Boolean, 'name' => String, + 'storagetype' => String, 'tags' => Fog::Nullable::String ] } @@ -20,7 +21,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | disk offering requests', ['cloudstack' tests('success') do tests('#list_disk_offerings').formats(@disk_offerings_format) do - pending if Fog.mocking? Fog::Compute[:cloudstack].list_disk_offerings end diff --git a/tests/cloudstack/requests/os_type_tests.rb b/tests/cloudstack/requests/os_type_tests.rb index 9be49738b..514b695e4 100644 --- a/tests/cloudstack/requests/os_type_tests.rb +++ b/tests/cloudstack/requests/os_type_tests.rb @@ -4,9 +4,9 @@ Shindo.tests('Fog::Compute[:cloudstack] | os type requests', ['cloudstack']) do 'listostypesresponse' => { 'count' => Integer, 'ostype' => [ - 'id' => Integer, + 'id' => String, 'description' => String, - 'oscategoryid' => Integer + 'oscategoryid' => String ] } } @@ -24,7 +24,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | os type requests', ['cloudstack']) do tests('success') do tests('#list_os_types').formats(@os_types_format) do - pending if Fog.mocking? Fog::Compute[:cloudstack].list_os_types end