mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Adds create_plan and delete_plan requests
Adds following to Planning service of OpenStack: * create_plan and delete_plan requests * tests for create_plan and delete_plan requests
This commit is contained in:
parent
1a0dff6424
commit
de93719cd9
4 changed files with 70 additions and 0 deletions
|
@ -30,6 +30,8 @@ module Fog
|
|||
request :list_plans
|
||||
request :get_plan_templates
|
||||
request :get_plan
|
||||
request :create_plan
|
||||
request :delete_plan
|
||||
|
||||
class Mock
|
||||
def self.data
|
||||
|
|
33
lib/fog/openstack/requests/planning/create_plan.rb
Normal file
33
lib/fog/openstack/requests/planning/create_plan.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
module Fog
|
||||
module Openstack
|
||||
class Planning
|
||||
class Real
|
||||
def create_plan(parameters)
|
||||
request(
|
||||
:expects => [201],
|
||||
:method => 'POST',
|
||||
:path => "plans",
|
||||
:body => Fog::JSON.encode(parameters)
|
||||
)
|
||||
end
|
||||
end # class Real
|
||||
|
||||
class Mock
|
||||
def create_plan(parameters)
|
||||
response = Excon::Response.new
|
||||
response.status = [201][rand(1)]
|
||||
response.body = {
|
||||
"created_at" => "2014-09-26T20:23:14.222815",
|
||||
"description" => "Development testing cloud",
|
||||
"name" => "dev-cloud",
|
||||
"parameters" => [],
|
||||
"roles" => [],
|
||||
"updated_at" => nil,
|
||||
"uuid" => "53268a27-afc8-4b21-839f-90227dd7a001"
|
||||
}
|
||||
response
|
||||
end # def create_plans
|
||||
end # class Mock
|
||||
end # class Planning
|
||||
end # module Openstack
|
||||
end # module Fog
|
23
lib/fog/openstack/requests/planning/delete_plan.rb
Normal file
23
lib/fog/openstack/requests/planning/delete_plan.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module Openstack
|
||||
class Planning
|
||||
class Real
|
||||
def delete_plan(plan_uuid)
|
||||
request(
|
||||
:expects => [204],
|
||||
:method => 'DELETE',
|
||||
:path => "plans/#{plan_uuid}"
|
||||
)
|
||||
end
|
||||
end # class Real
|
||||
|
||||
class Mock
|
||||
def delete_plan(plan_uuid)
|
||||
response = Excon::Response.new
|
||||
response.status = [204][rand(1)]
|
||||
response
|
||||
end # def delete_plans
|
||||
end # class Mock
|
||||
end # class Planning
|
||||
end # module Openstack
|
||||
end # module Fog
|
|
@ -25,6 +25,18 @@ Shindo.tests('Fog::Openstack[:planning] | Planning plan requests', ['openstack']
|
|||
Fog::Openstack[:planning].get_plan(@instance['uuid']).body
|
||||
end
|
||||
|
||||
tests('#delete_plan').succeeds do
|
||||
Fog::Openstack[:planning].delete_plan(@instance['uuid'])
|
||||
end
|
||||
|
||||
tests('#create_plan').data_matches_schema(@plan_format) do
|
||||
plan_attributes = {
|
||||
:name => 'test-plan-name',
|
||||
:description => 'test-plan-desc',
|
||||
}
|
||||
@instance = Fog::Openstack[:planning].create_plan(plan_attributes).body
|
||||
end
|
||||
|
||||
tests('#get_plan_templates').data_matches_schema(@plan_templates_format) do
|
||||
Fog::Openstack[:planning].get_plan_templates(@instance['uuid']).body
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue