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 May 16, 2024
1 parent cdfcfc5 commit 995bd1f
Show file tree
Hide file tree
Showing 41 changed files with 1,335 additions and 76 deletions.
9 changes: 7 additions & 2 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,13 @@ def delete_flavors
end

# Delete all selected or single displayed RP(s)
def deleteresourcepools
assert_privileges("resource_pool_delete")
def deletecloudresourcepools
assert_privileges("resource_pool_cloud_delete")
delete_elements(ResourcePool, :process_resourcepools)
end

def deleteinfraresourcepools
assert_privileges("resource_pool_infra_delete")
delete_elements(ResourcePool, :process_resourcepools)
end

Expand Down
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
102 changes: 102 additions & 0 deletions app/controllers/resource_pool_cloud_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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_cloud_delete'
deletecloudresourcepools
if @refresh_div == 'main_div' && @lastaction == 'show_list'
replace_gtl_main_div
else
render_flash unless performed?
end
when 'resource_pool_cloud_protect'
assign_policies(ResourcePool)
when 'resource_pool_cloud_tag'
tag(self.class.model)
else
super
end
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')
@center_toolbar = "resource_pool_clouds"
super
end

def show
assert_privileges('resource_pool_cloud_show')
@center_toolbar = "resource_pool_cloud"
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 @@ -21,27 +21,57 @@ def button

@refresh_div = 'main_div' unless @display # Default div for button.rjs to refresh
case params[:pressed]
when 'resource_pool_delete'
deleteresourcepools
when 'resource_pool_infra_delete'
deleteinfraresourcepools
if @refresh_div == 'main_div' && @lastaction == 'show_list'
replace_gtl_main_div
else
render_flash unless performed?
end
when 'resource_pool_protect'
when 'resource_pool_infra_protect'
assign_policies(ResourcePool)
when 'resource_pool_infra_tag'
tag(self.class.model)
else
super
end
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')
@center_toolbar = "resource_pool_infras"
super
end

def show
assert_privileges('resource_pool_infra_show')
@center_toolbar = "resource_pool_infra"
super
end

Expand All @@ -54,6 +84,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 +97,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class ApplicationHelper::Toolbar::ResourcePoolCloudCenter < ApplicationHelper::Toolbar::Basic
button_group('resource_pool_vmdb', [
select(
:resource_pool_vmdb_choice,
nil,
t = N_('Configuration'),
t,
:items => [
button(
:resource_pool_cloud_delete,
'pficon pficon-delete fa-lg',
N_('Remove this Resource Pool from Inventory'),
N_('Remove Resource Pool from Inventory'),
:url_parms => "&refresh=y",
:confirm => N_("Warning: This Resource Pool and ALL of its components will be permanently removed!")),
]
),
])
button_group('resource_pool_cloud_policy', [
select(
:resource_pool_policy_choice,
nil,
t = N_('Policy'),
t,
:items => [
button(
:resource_pool_cloud_protect,
'pficon pficon-edit fa-lg',
N_('Manage Policies for this Resource Pool'),
N_('Manage Policies')),
button(
:resource_pool_cloud_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Resource Pool'),
N_('Edit Tags')),
]
),
])
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationHelper::Toolbar::ResourcePoolsCenter < ApplicationHelper::Toolbar::Basic
class ApplicationHelper::Toolbar::ResourcePoolCloudsCenter < ApplicationHelper::Toolbar::Basic
button_group('resource_pool_vmdb', [
select(
:resource_pool_vmdb_choice,
Expand All @@ -9,7 +9,7 @@ class ApplicationHelper::Toolbar::ResourcePoolsCenter < ApplicationHelper::Toolb
:onwhen => "1+",
:items => [
button(
:resource_pool_delete,
:resource_pool_cloud_delete,
'pficon pficon-delete fa-lg',
N_('Remove selected Resource Pools from Inventory'),
N_('Remove Resource Pools from Inventory'),
Expand All @@ -31,7 +31,7 @@ class ApplicationHelper::Toolbar::ResourcePoolsCenter < ApplicationHelper::Toolb
:onwhen => "1+",
:items => [
button(
:resource_pool_protect,
:resource_pool_cloud_protect,
'pficon pficon-edit fa-lg',
N_('Manage Policies for the selected Resource Pools'),
N_('Manage Policies'),
Expand All @@ -40,7 +40,7 @@ class ApplicationHelper::Toolbar::ResourcePoolsCenter < ApplicationHelper::Toolb
:enabled => false,
:onwhen => "1+"),
button(
:resource_pool_tag,
:resource_pool_cloud_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for the selected Resource Pools'),
N_('Edit Tags'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationHelper::Toolbar::ResourcePoolCenter < ApplicationHelper::Toolbar::Basic
class ApplicationHelper::Toolbar::ResourcePoolInfraCenter < ApplicationHelper::Toolbar::Basic
button_group('resource_pool_vmdb', [
select(
:resource_pool_vmdb_choice,
Expand All @@ -7,7 +7,7 @@ class ApplicationHelper::Toolbar::ResourcePoolCenter < ApplicationHelper::Toolba
t,
:items => [
button(
:resource_pool_delete,
:resource_pool_infra_delete,
'pficon pficon-delete fa-lg',
N_('Remove this Resource Pool from Inventory'),
N_('Remove Resource Pool from Inventory'),
Expand All @@ -24,12 +24,12 @@ class ApplicationHelper::Toolbar::ResourcePoolCenter < ApplicationHelper::Toolba
t,
:items => [
button(
:resource_pool_protect,
:resource_pool_infra_protect,
'pficon pficon-edit fa-lg',
N_('Manage Policies for this Resource Pool'),
N_('Manage Policies')),
button(
:resource_pool_tag,
:resource_pool_infra_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Resource Pool'),
N_('Edit Tags')),
Expand Down
Loading

0 comments on commit 995bd1f

Please sign in to comment.