Skip to content

Commit

Permalink
Seperate cloud and infra resource pools
Browse files Browse the repository at this point in the history
  • Loading branch information
Guddetisandeep committed Mar 27, 2024
1 parent 26ad824 commit 8534f7a
Show file tree
Hide file tree
Showing 24 changed files with 667 additions and 165 deletions.
78 changes: 73 additions & 5 deletions app/controllers/resource_pool_cloud_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
class ResourcePoolCloudController < ResourcePoolController
class ResourcePoolCloudController < ApplicationController
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data

include Mixins::GenericButtonMixin
include Mixins::GenericListMixin
include Mixins::GenericSessionMixin
include Mixins::GenericShowMixin
include Mixins::BreadcrumbsMixin

def self.display_methods
%w[vms all_vms resource_pools]
end

# handle buttons pressed on the button bar
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if %w[all_vms vms resource_pools].include?(@display) # Were we displaying sub-items
@refresh_div = 'main_div' unless @display # Default div for button.rjs to refresh

case params[:pressed]
when 'resource_pool_delete'
delete_resource_pools
replace_gtl_main_div if @refresh_div == 'main_div' && @lastaction == 'show_list'
when 'resource_pool_protect'
assign_policies(ResourcePool)
else
super
end

render_flash unless performed?
end

def self.model
ResourcePool
ManageIQ::Providers::CloudManager::ResourcePool
end

def download_data
assert_privileges('resource_pool_cloud_show_list')
super
end

def download_summary_pdf
assert_privileges('resource_pool_cloud_show')
super
end

def breadcrumb_name(_model)
_("Cloud Resource Pools")
end

def self.table_name
Expand All @@ -11,18 +59,38 @@ def index
redirect_to(:action => 'show_list')
end

def show_list
assert_privileges('resource_pool_cloud_show_list')
super
end

def show
assert_privileges('resource_pool_cloud_show')
super
end

private

def record_class
%w[all_vms vms].include?(params[:display]) ? VmOrTemplate : ResourcePool
end

def textual_group_list
[%i[properties relationships], %i[configuration smart_management]]
end

helper_method :textual_group_list

def breadcrumbs_options
{
:breadcrumbs => [
{:title => _("Compute")},
{:title => _("Clouds")},
{:title => _("Resource Pools"), :url => controller_url},
],
{:title => _("Resource Pools"), :url => controller_url}
]
}
end

menu_section :clo
menu_section :resource_pool_cloud
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
67 changes: 0 additions & 67 deletions app/controllers/resource_pool_controller.rb

This file was deleted.

80 changes: 75 additions & 5 deletions app/controllers/resource_pool_infra_controller.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,98 @@
class ResourcePoolInfraController < ResourcePoolController
class ResourcePoolInfraController < ApplicationController
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data

include Mixins::GenericButtonMixin
include Mixins::GenericListMixin
include Mixins::GenericSessionMixin
include Mixins::GenericShowMixin
include Mixins::BreadcrumbsMixin

def self.display_methods
%w[vms all_vms resource_pools]
end

# handle buttons pressed on the button bar
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if %w[all_vms vms resource_pools].include?(@display) # Were we displaying sub-items
@refresh_div = 'main_div' unless @display # Default div for button.rjs to refresh
case params[:pressed]
when 'resource_pool_delete'
deleteresourcepools
if @refresh_div == 'main_div' && @lastaction == 'show_list'
replace_gtl_main_div
else
render_flash unless performed?
end
when 'resource_pool_protect'
assign_policies(ResourcePool)
else
super
end
render_flash unless performed?
end

def self.model
ResourcePool
ManageIQ::Providers::InfraManager::ResourcePool
end

def self.table_name
@table_name ||= "resource_pool"
end

def breadcrumb_name(_model)
_("Infrastructure Resource Pools")
end

def download_data
assert_privileges('resource_pool_infra_view')
super
end

def download_summary_pdf
assert_privileges('resource_pool_infra_view')
super
end

def index
redirect_to(:action => 'show_list')
end

def show_list
assert_privileges('resource_pool_infra_show_list')
super
end

def show
assert_privileges('resource_pool_infra_show')
super
end

private

def record_class
%w[all_vms vms].include?(params[:display]) ? VmOrTemplate : ResourcePool
end

def textual_group_list
[%i[properties relationships], %i[configuration smart_management]]
end

helper_method :textual_group_list

def breadcrumbs_options
{
:breadcrumbs => [
{:title => _("Compute")},
{:title => _("Infrastructure")},
{:title => _("Resource Pools"), :url => controller_url},
],
{:title => _("Resource Pools"), :url => controller_url}
]
}
end

menu_section :inf
menu_section :resource_pool_infra
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
10 changes: 6 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,10 @@ def db_to_controller(db, action = "show")
when "PlacementGroup"
controller = "placement_group"
action = "show"
when "ResourcePool"
controller = "resource_pool"
action = "show"
when "ManageIQ::Providers::CloudManager::ResourcePool"
controller = "resource_pool_cloud"
when "ManageIQ::Providers::InfraManager::ResourcePool"
controller = "resource_pool_infra"
when "SecurityGroup"
controller = "security_group"
action = "show"
Expand Down Expand Up @@ -791,7 +792,8 @@ def display_adv_search?
physical_server
placement_group
provider_foreman
resource_pool
resource_pool_cloud
resource_pool_infra
retired
security_group
security_policy
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/application_helper/listnav.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def render_listnav_filename
physical_server
physical_storage
physical_switch
resource_pool
resource_pool_cloud
resource_pool_infra
security_group
security_policy
security_policy_rule
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/application_helper/page_layouts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def show_adv_search?
physical_server
physical_storage
placement_group
resource_pool
resource_pool_cloud
resource_pool_infra
retired
security_group
security_policy
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/resource_pool_cloud_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ResourcePoolCloudHelper
include_concern 'TextualSummary'
include ResourcePoolConfigHelper
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ResourcePoolHelper::TextualSummary
module ResourcePoolCloudHelper::TextualSummary
#
# Groups
#
Expand Down Expand Up @@ -111,7 +111,7 @@ def textual_direct_vms
h = {:label => _("Direct VMs"), :icon => "pficon pficon-virtual-machine", :value => num}
if num.positive? && role_allows?(:feature => "vm_show_list")
h[:title] = _("Show VMs in this Resource Pool, but not in Resource Pools below")
h[:link] = url_for_only_path(:controller => 'resource_pool', :action => 'show', :id => @record, :display => 'vms')
h[:link] = url_for_only_path(:controller => 'resource_pool_cloud', :action => 'show', :id => @record, :display => 'vms')
end
h
end
Expand All @@ -121,20 +121,21 @@ def textual_allvms_size
h = {:label => _("All VMs"), :icon => "pficon pficon-virtual-machine", :value => num}
if num.positive? && role_allows?(:feature => "vm_show_list")
h[:title] = _("Show all VMs in this Resource Pool")
h[:link] = url_for_only_path(:controller => 'resource_pool', :action => 'show', :id => @record, :display => 'all_vms')
h[:link] = url_for_only_path(:controller => 'resource_pool_cloud', :action => 'show', :id => @record, :display => 'all_vms')
end
h
end

def textual_resource_pools
num = @record.number_of(:resource_pools)
h = {:label => _("Resource Pools"), :icon => "pficon pficon-resource-pool", :value => num}
if num.positive? && role_allows?(:feature => "resource_pool_show_list")
h[:title] = _("Show all Resource Pools")
h[:link] = url_for_only_path(:controller => "resource_pool", :action => 'show', :id => @record, :display => 'resource_pools')
if num.positive? && role_allows?(:feature => "resource_pool_cloud_show_list")
h[:title] = _("Show all Resource Pools in this Cloud")
h[:link] = url_for_only_path(:controller => "resource_pool_cloud", :action => 'show', :id => @record, :display => 'resource_pools')
end
h
end


def textual_memory_reserve
value = @record.memory_reserve
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module ResourcePoolHelper
include_concern 'TextualSummary'
module ResourcePoolConfigHelper

def calculate_rp_config(db_record)
rp_config = []
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/resource_pool_infra_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ResourcePoolInfraHelper
include_concern 'TextualSummary'
include ResourcePoolConfigHelper
end
Loading

0 comments on commit 8534f7a

Please sign in to comment.