Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cloud and infra apis for resource pool #1273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Api
class ResourcePoolsController < BaseController
class ResourcePoolCloudsController < BaseController
include Subcollections::Policies
include Subcollections::PolicyProfiles
include Subcollections::Tags
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/resource_pool_infras_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Api
class ResourcePoolInfrasController < BaseController
include Subcollections::Policies
include Subcollections::PolicyProfiles
include Subcollections::Tags
end
end
73 changes: 59 additions & 14 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3325,49 +3325,94 @@
- :subcollection
:verbs: *g
:klass: ResourceAction
:resource_pools:
:description: Resource Pools
:identifier: resource_pool

:resource_pool_clouds:
:description: Cloud Resource Pools
:identifier: resource_pool_cloud
:options:
- :collection
:verbs: *gp
:klass: ManageIQ::Providers::CloudManager::ResourcePool
:subcollections:
- :tags
- :policies
- :policy_profiles
:collection_actions:
:get:
- :name: read
:identifier: resource_pool_cloud_show_list
:post:
- :name: query
:identifier: resource_pool_cloud_show_list
:resource_actions:
:get:
- :name: read
:identifier: resource_pool_cloud_show
:post:
- :name: delete
:identifier: resource_pool_cloud_delete
:tags_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_cloud_tag
- :name: unassign
:identifier: resource_pool_cloud_tag
:policies_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_cloud_protect
- :name: unassign
:identifier: resource_pool_cloud_protect
:policy_profiles_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_cloud_protect
- :name: unassign
:identifier: resource_pool_cloud_protect

:resource_pool_infras:
:description: Infrastructure Resource Pools
:identifier: resource_pool_infra
:options:
- :collection
:verbs: *gp
:klass: ResourcePool
:klass: ManageIQ::Providers::InfraManager::ResourcePool
:subcollections:
- :tags
- :policies
- :policy_profiles
:collection_actions:
:get:
- :name: read
:identifier: resource_pool_show_list
:identifier: resource_pool_infra_show_list
:post:
- :name: query
:identifier: resource_pool_show_list
:identifier: resource_pool_infra_show_list
:resource_actions:
:get:
- :name: read
:identifier: resource_pool_show
:identifier: resource_pool_infra_show
:post:
- :name: delete
:identifier: resource_pool_delete
:identifier: resource_pool_infra_delete
:tags_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_tag
:identifier: resource_pool_infra_tag
- :name: unassign
:identifier: resource_pool_tag
:identifier: resource_pool_infra_tag
:policies_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_protect
:identifier: resource_pool_infra_protect
- :name: unassign
:identifier: resource_pool_protect
:identifier: resource_pool_infra_protect
:policy_profiles_subcollection_actions:
:post:
- :name: assign
:identifier: resource_pool_protect
:identifier: resource_pool_infra_protect
- :name: unassign
:identifier: resource_pool_protect
:identifier: resource_pool_infra_protect
:results:
:description: Report Results
:identifier: miq_report_reports
Expand Down
20 changes: 15 additions & 5 deletions spec/requests/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
test_collection_query(:requests, api_requests_url, MiqRequest)
end

it "query Resource Pools" do
it "query Cloud Resource Pool" do
FactoryBot.create(:resource_pool)
test_collection_query(:resource_pools, api_resource_pools_url, ResourcePool)
test_collection_query(:resource_pool_clouds, api_resource_pool_clouds_url, ManageIQ::Providers::CloudManager::ResourcePool)
end

it "query Infra Resource Pool" do
FactoryBot.create(:resource_pool)
test_collection_query(:resource_pool_infras, api_resource_pool_infras_url, ManageIQ::Providers::InfraManager::ResourcePool)
end

it "query Roles" do
Expand Down Expand Up @@ -586,9 +591,14 @@ def test_collection_bulk_query(collection, collection_url, klass, id = nil)
test_collection_bulk_query(:requests, api_requests_url, MiqRequest)
end

it "bulk query Resource Pools" do
FactoryBot.create(:resource_pool)
test_collection_bulk_query(:resource_pools, api_resource_pools_url, ResourcePool)
it "bulk query Cloud Resource Pools" do
FactoryBot.create(:resource_pool, :type => 'ManageIQ::Providers::CloudManager::ResourcePool')
test_collection_bulk_query(:resource_pool_clouds, api_resource_pool_clouds_url, ManageIQ::Providers::CloudManager::ResourcePool)
end

it "bulk query Infra Resource Pools" do
FactoryBot.create(:resource_pool, :type => 'ManageIQ::Providers::InfraManager::ResourcePool')
test_collection_bulk_query(:resource_pool_infras, api_resource_pool_infras_url, ManageIQ::Providers::InfraManager::ResourcePool)
end

it "bulk query Roles" do
Expand Down
178 changes: 132 additions & 46 deletions spec/requests/policies_assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# /api/vms/:id
# /api/providers/:id
# /api/hosts/:id
# /api/resource_pools/:id
# /api/resource_pool_clouds/:id
# /api/resource_pool_infras/:id
# /api/clusters/:id
# /api/templates/:id
#
Expand All @@ -22,7 +23,8 @@
let(:cluster) do
FactoryBot.create(:ems_cluster, :ext_management_system => provider, :hosts => [host], :vms => [])
end
let(:rp) { FactoryBot.create(:resource_pool, :name => "Resource Pool 1") }
let(:rpc) { FactoryBot.create(:resource_pool, :name => "Resource Pool 1", :type => ManageIQ::Providers::CloudManager::ResourcePool) }
let(:rpi) { FactoryBot.create(:resource_pool, :name => "Resource Pool 1", :type => ManageIQ::Providers::InfraManager::ResourcePool) }
let(:vm) { FactoryBot.create(:vm) }
let(:template) do
FactoryBot.create(:miq_template, :name => "Tmpl 1", :vendor => "vmware", :location => "tmpl_1.vmtx")
Expand Down Expand Up @@ -322,87 +324,171 @@ def test_unassign_multiple_policy_profiles(api_object_policies_url, collection,
end
end

context "Resource Pool policies subcollection assignments" do
it "assign Resource Pool policy without appropriate role" do
test_policy_assign_no_role(api_resource_pool_policies_url(nil, rp))
context "Resource Pool Cloud policies subcollection assignments" do
it "assign Resource Pool Cloud policy without appropriate role" do
test_policy_assign_no_role(api_resource_pool_cloud_policies_url(nil, rpc))
end

it "assign Resource Pool policy with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_policies_url(nil, rp), :resource_pools, :policies)
it "assign Resource Pool Cloud policy with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_cloud_policies_url(nil, rpc), :resource_pool_clouds, :policies)
end

it "assign Resource Pool policy with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_url(nil, rp), api_resource_pool_policies_url(nil, rp), :resource_pools, :policies)
it "assign Resource Pool Cloud policy with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_cloud_url(nil, rpc), api_resource_pool_cloud_policies_url(nil, rpc), :resource_pool_clouds, :policies)
end

it "assign Resource Pool multiple policies" do
test_assign_multiple_policies(api_resource_pool_url(nil, rp),
api_resource_pool_policies_url(nil, rp),
:resource_pools,
it "assign Resource Pool Cloud multiple policies" do
test_assign_multiple_policies(api_resource_pool_cloud_url(nil, rpc),
api_resource_pool_cloud_policies_url(nil, rpc),
:resource_pool_clouds,
:policies,
:object => rp,
:object => rpc,
:policies => [p1, p2])
end

it "unassign Resource Pool policy without approriate role" do
test_policy_unassign_no_role(api_resource_pool_policies_url(nil, rp))
it "unassign Resource Pool Cloud policy without approriate role" do
test_policy_unassign_no_role(api_resource_pool_cloud_policies_url(nil, rpc))
end

it "unassign Resource Pool policy with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_policies_url(nil, rp), :resource_pools, :policies)
it "unassign Resource Pool Cloud policy with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_cloud_policies_url(nil, rpc), :resource_pool_clouds, :policies)
end

it "unassign Resource Pool policy with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_url(nil, rp), api_resource_pool_policies_url(nil, rp), :resource_pools, :policies)
it "unassign Resource Pool Cloud policy with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_cloud_url(nil, rpc), api_resource_pool_cloud_policies_url(nil, rpc), :resource_pool_clouds, :policies)
end

it "unassign Resource Pool multiple policies" do
test_unassign_multiple_policies(api_resource_pool_policies_url(nil, rp), :resource_pools, :policies, :object => rp)
it "unassign Resource Pool Cloud multiple policies" do
test_unassign_multiple_policies(api_resource_pool_cloud_policies_url(nil, rpc), :resource_pool_clouds, :policies, :object => rpc)
end
end

context "Resource Pool policy profiles subcollection assignments" do
it "assign Resource Pool policy profile without approriate role" do
test_policy_assign_no_role(api_resource_pool_policy_profiles_url(nil, rp))
context "Resource Pool Cloud policy profiles subcollection assignments" do
it "assign Resource Pool Cloud policy profile without approriate role" do
test_policy_assign_no_role(api_resource_pool_cloud_policy_profiles_url(nil, rpc))
end

it "assign Resource Pool policy profile with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_policy_profiles_url(nil, rp), :resource_pools, :policy_profiles)
it "assign Resource Pool Cloud policy profile with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_cloud_policy_profiles_url(nil, rpc), :resource_pool_clouds, :policy_profiles)
end

it "assign Resource Pool policy profile with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_url(nil, rp), api_resource_pool_policy_profiles_url(nil, rp), :resource_pools, :policy_profiles)
it "assign Resource Pool Cloud policy profile with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_cloud_url(nil, rpc), api_resource_pool_cloud_policy_profiles_url(nil, rpc), :resource_pool_clouds, :policy_profiles)
end

it "assign Resource Pool multiple policy profiles" do
test_assign_multiple_policies(api_resource_pool_url(nil, rp),
api_resource_pool_policy_profiles_url(nil, rp),
:resource_pools,
it "assign Resource Pool Cloud multiple policy profiles" do
test_assign_multiple_policies(api_resource_pool_cloud_url(nil, rpc),
api_resource_pool_cloud_policy_profiles_url(nil, rpc),
:resource_pool_clouds,
:policy_profiles,
:object => rp,
:object => rpc,
:policies => [ps1, ps2])
end

it "unassign Resource Pool policy profile without approriate role" do
test_policy_unassign_no_role(api_resource_pool_policy_profiles_url(nil, rp))
it "unassign Resource Pool Cloud policy profile without approriate role" do
test_policy_unassign_no_role(api_resource_pool_cloud_policy_profiles_url(nil, rpc))
end

it "unassign Resource Pool policy profile with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_policy_profiles_url(nil, rp), :resource_pools, :policy_profiles)
it "unassign Resource Pool Cloud policy profile with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_cloud_policy_profiles_url(nil, rpc), :resource_pool_clouds, :policy_profiles)
end

it "unassign Resource Pool policy profile with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_url(nil, rp),
api_resource_pool_policy_profiles_url(nil, rp),
:resource_pools,
it "unassign Resource Pool Cloud policy profile with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_cloud_url(nil, rpc),
api_resource_pool_cloud_policy_profiles_url(nil, rpc),
:resource_pool_clouds,
:policy_profiles)
end

it "unassign Resource Pool multiple policy profiles" do
test_unassign_multiple_policy_profiles(api_resource_pool_policy_profiles_url(nil, rp),
:resource_pools,
it "unassign Resource Pool Cloud multiple policy profiles" do
test_unassign_multiple_policy_profiles(api_resource_pool_cloud_policy_profiles_url(nil, rpc),
:resource_pool_clouds,
:policy_profiles,
:object => rp)
:object => rpc)
end
end

context "Resource Pool Infra policies subcollection assignments" do
it "assign Resource Pool Infra policy without appropriate role" do
test_policy_assign_no_role(api_resource_pool_infra_policies_url(nil, rpi))
end

it "assign Resource Pool Infra policy with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_infra_policies_url(nil, rpi), :resource_pool_infras, :policies)
end

it "assign Resource Pool Infra policy with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_infra_url(nil, rpi), api_resource_pool_infra_policies_url(nil, rpi), :resource_pool_infras, :policies)
end

it "assign Resource Pool Infra multiple policies" do
test_assign_multiple_policies(api_resource_pool_infra_url(nil, rpi),
api_resource_pool_infra_policies_url(nil, rpi),
:resource_pool_infras,
:policies,
:object => rpi,
:policies => [p1, p2])
end

it "unassign Resource Pool Infra policy without approriate role" do
test_policy_unassign_no_role(api_resource_pool_infra_policies_url(nil, rpi))
end

it "unassign Resource Pool Infra policy with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_infra_policies_url(nil, rpi), :resource_pool_infras, :policies)
end

it "unassign Resource Pool Infra policy with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_infra_url(nil, rpi), api_resource_pool_infra_policies_url(nil, rpi), :resource_pool_infras, :policies)
end

it "unassign Resource Pool Infra multiple policies" do
test_unassign_multiple_policies(api_resource_pool_infra_policies_url(nil, rpi), :resource_pool_infras, :policies, :object => rpi)
end
end

context "Resource Pool Infra policy profiles subcollection assignments" do
it "assign Resource Pool Infra policy profile without approriate role" do
test_policy_assign_no_role(api_resource_pool_infra_policy_profiles_url(nil, rpi))
end

it "assign Resource Pool Infra policy profile with invalid href" do
test_policy_assign_invalid_policy(api_resource_pool_infra_policy_profiles_url(nil, rpi), :resource_pool_infras, :policy_profiles)
end

it "assign Resource Pool Infra policy profile with invalid guid" do
test_policy_assign_invalid_policy_guid(api_resource_pool_infra_url(nil, rpi), api_resource_pool_infra_policy_profiles_url(nil, rpi), :resource_pool_infras, :policy_profiles)
end

it "assign Resource Pool Infra multiple policy profiles" do
test_assign_multiple_policies(api_resource_pool_infra_url(nil, rpi),
api_resource_pool_infra_policy_profiles_url(nil, rpi),
:resource_pool_infras,
:policy_profiles,
:object => rpi,
:policies => [ps1, ps2])
end

it "unassign Resource Pool Infra policy profile without approriate role" do
test_policy_unassign_no_role(api_resource_pool_infra_policy_profiles_url(nil, rpi))
end

it "unassign Resource Pool Infra policy profile with invalid href" do
test_policy_unassign_invalid_policy(api_resource_pool_infra_policy_profiles_url(nil, rpi), :resource_pool_infras, :policy_profiles)
end

it "unassign Resource Pool Infra policy profile with invalid guid" do
test_policy_unassign_invalid_policy_guid(api_resource_pool_infra_url(nil, rpi),
api_resource_pool_infra_policy_profiles_url(nil, rpi),
:resource_pool_infras,
:policy_profiles)
end

it "unassign Resource Pool Infra multiple policy profiles" do
test_unassign_multiple_policy_profiles(api_resource_pool_infra_policy_profiles_url(nil, rpi),
:resource_pool_infras,
:policy_profiles,
:object => rpi)
end
end

Expand Down
Loading
Loading