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 Apr 17, 2024
1 parent 5d9bb09 commit f212495
Show file tree
Hide file tree
Showing 34 changed files with 1,186 additions and 38 deletions.
1 change: 1 addition & 0 deletions app/controllers/mixins/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def display_methods
physical_switches
physical_storages
placement_groups
resource_pools_cloud
security_groups
security_policies
security_policy_rules
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/mixins/generic_show_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def display_custom_button_events
nested_list(CustomButtonEvent, :breadcrumb_title => _('Custom Button Events'), :clickable => false, :parent_method => 'custom_button_events')
end

def display_resource_pools
nested_list(ResourcePool)
def display_resource_pools_cloud
nested_list(ManageIQ::Providers::CloudManager::ResourcePool, :breadcrumb_title => _('Resource Pools'))
end

def display_instances
Expand Down
96 changes: 96 additions & 0 deletions app/controllers/resource_pool_cloud_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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
ManageIQ::Providers::CloudManager::ResourcePool
end

def download_data
assert_privileges('resource_pool_cloud_view')
super
end

def download_summary_pdf
assert_privileges('resource_pool_cloud_view')
super
end

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

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

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},
],
}
end

menu_section :resource_pool_cloud
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ResourcePoolController < ApplicationController
class ResourcePoolInfraController < ApplicationController
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
Expand All @@ -18,7 +18,6 @@ def self.display_methods
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'
Expand All @@ -33,15 +32,42 @@ def button
else
super
end
render_flash unless performed?
end

def self.model
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_show_list')
assert_privileges('resource_pool_infra_view')
super
end

def download_summary_pdf
assert_privileges('resource_pool_show')
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

Expand All @@ -54,6 +80,7 @@ def record_class
def textual_group_list
[%i[properties relationships], %i[configuration smart_management]]
end

helper_method :textual_group_list

def breadcrumbs_options
Expand All @@ -66,6 +93,6 @@ def breadcrumbs_options
}
end

menu_section :inf
menu_section :resource_pool_infra
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
4 changes: 4 additions & 0 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ def placement_group
show_association('placement_groups', _('Placement Groups'), :placement_groups, PlacementGroup)
end

def resource_pool
show_association('resource_pools', _('Resource Pools'), :resource_pools, ResourcePool)
end

def cloud_subnets
show_association('cloud_subnets', _('Subnets'), :cloud_subnets, CloudSubnet)
end
Expand Down
7 changes: 6 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ def db_to_controller(db, action = "show")
when "PlacementGroup"
controller = "placement_group"
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 @@ -788,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
12 changes: 11 additions & 1 deletion app/helpers/ems_cloud_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def textual_group_relationships
_("Relationships"),
%i[
ems_infra network_manager availability_zones host_aggregates cloud_tenants flavors
security_groups placement_groups instances images cloud_volumes orchestration_stacks storage_managers cloud_databases
security_groups placement_groups resource_pools instances images cloud_volumes orchestration_stacks storage_managers cloud_databases
custom_button_events tenant
]
)
Expand Down Expand Up @@ -131,6 +131,16 @@ def textual_placement_groups
h
end

def textual_resource_pools
num = @record.try(:resource_pools) ? @record.number_of(:resource_pools) : 0
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] = ems_cloud_path(@record.id, :display => 'resource_pools_cloud')
end
h
end

def textual_cloud_databases
num = @record.try(:cloud_databases) ? @record.number_of(:cloud_databases) : 0
h = {:label => _('Cloud Databases'), :icon => "fa fa-database", :value => num}
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
Loading

0 comments on commit f212495

Please sign in to comment.