Skip to content

Commit

Permalink
Add Cloud and Infra specific Resource Pool views
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcarman authored and Guddetisandeep committed Nov 7, 2023
1 parent 6fb237d commit aebf2cf
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 6 deletions.
28 changes: 28 additions & 0 deletions app/controllers/resource_pool_cloud_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class ResourcePoolCloudController < ResourcePoolController
def self.model
ResourcePool
end

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

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

private

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

menu_section :clo
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
4 changes: 0 additions & 4 deletions app/controllers/resource_pool_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ def breadcrumbs_options
{
:breadcrumbs => [
{:title => _("Compute")},
{:title => _("Infrastructure")},
{:title => _("Resource Pools"), :url => controller_url},
],
}
end

menu_section :inf
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
28 changes: 28 additions & 0 deletions app/controllers/resource_pool_infra_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class ResourcePoolInfraController < ResourcePoolController
def self.model
ResourcePool
end

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

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

private

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

menu_section :inf
feature_for_actions "#{controller_name}_show_list", *ADV_SEARCH_ACTIONS
end
7 changes: 7 additions & 0 deletions app/helpers/resource_pool_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,25 @@ def textual_vapp

def textual_aggregate_cpu_speed
# TODO: Why aren't we using mhz_to_human_size here?
return nil if @record.aggregate_cpu_speed == 0
{:label => _("Total Host CPU Resources"),
:value => "#{number_with_delimiter(@record.aggregate_cpu_speed)} MHz"}
end

def textual_aggregate_cpu_memory
return nil if @record.aggregate_memory == 0
{:label => _("Total Host Memory"),
:value => number_to_human_size(@record.aggregate_memory.megabytes, :precision => 0)}
end

def textual_aggregate_physical_cpus
return nil if @record.aggregate_physical_cpus == 0
{:label => _("Total Host CPUs"),
:value => number_with_delimiter(@record.aggregate_physical_cpus)}
end

def textual_aggregate_cpu_total_cores
return nil if @record.aggregate_cpu_total_cores == 0
{:label => _("Total Host CPU Cores"),
:value => number_with_delimiter(@record.aggregate_cpu_total_cores)}
end
Expand All @@ -72,11 +76,13 @@ def textual_aggregate_vm_cpus
end

def textual_parent_datacenter
return nil if @record.v_parent_datacenter.nil?
{:label => _("Parent Datacenter"), :icon => "fa fa-building-o", :value => @record.v_parent_datacenter || _("None")}
end

def textual_parent_cluster
cluster = @record.parent_cluster
return nil if cluster.nil?
h = {:label => _("Parent Cluster"),
:icon => "pficon pficon-cluster",
:value => (cluster.nil? ? _("None") : cluster.name)}
Expand All @@ -89,6 +95,7 @@ def textual_parent_cluster

def textual_parent_host
host = @record.parent_host
return nil if host.nil?
h = {:label => _("Parent Host"),
:icon => "pficon pficon-container-node",
:value => (host.nil? ? _("None") : host.name)}
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/menu/default_menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def clouds_menu_section
Menu::Item.new('orchestration_stack', N_('Stacks'), 'orchestration_stack', {:feature => 'orchestration_stack_show_list'}, '/orchestration_stack/show_list'),
Menu::Item.new('auth_key_pair_cloud', N_('Key Pairs'), 'auth_key_pair_cloud', {:feature => 'auth_key_pair_cloud_show_list'}, '/auth_key_pair_cloud/show_list'),
Menu::Item.new('placement_group', N_('Placement Groups'), 'placement_group', {:feature => 'placement_group_show_list'}, '/placement_group/show_list'),
Menu::Item.new('resource_pool', N_('Resource Pools'), 'resource_pool', {:feature => 'resource_pool_show_list'}, '/resource_pool/show_list'),
Menu::Item.new('resource_pool', N_('Resource Pools'), 'resource_pool', {:feature => 'resource_pool_show_list'}, '/resource_pool_cloud/show_list'),
Menu::Item.new('cloud_databases', N_('Databases'), 'cloud_database', {:feature => 'cloud_database'}, '/cloud_database/show_list'),
])
end
Expand All @@ -95,7 +95,7 @@ def infrastructure_menu_section
Menu::Item.new('ems_cluster', N_("Clusters"), 'ems_cluster', {:feature => 'ems_cluster_show_list'}, '/ems_cluster/show_list'),
Menu::Item.new('host', N_("Hosts"), 'host', {:feature => 'host_show_list'}, '/host/show_list'),
Menu::Item.new('vm_infra', N_('Virtual Machines'), 'vm_infra_explorer', {:feature => 'vm_infra_explorer', :any => true}, '/vm_infra/explorer'),
Menu::Item.new('resource_pool', N_('Resource Pools'), 'resource_pool', {:feature => 'resource_pool_show_list'}, '/resource_pool/show_list'),
Menu::Item.new('resource_pool', N_('Resource Pools'), 'resource_pool', {:feature => 'resource_pool_show_list'}, '/resource_pool_infra/show_list'),
Menu::Item.new('storage', N_('Datastores'), 'storage', {:feature => 'storage_show_list'}, '/storage/explorer'),
Menu::Item.new('pxe', N_('PXE'), 'pxe', {:feature => 'pxe', :any => true}, '/pxe/explorer'),
Menu::Item.new('switch', N_('Networking'), 'infra_networking', {:feature => 'infra_networking', :any => true}, '/infra_networking/explorer'),
Expand Down
20 changes: 20 additions & 0 deletions app/views/resource_pool_cloud/_config.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#maincontent
= render :partial => "layouts/flash_msg"

- if @display == "config_info"
rp_config = calculate_rp_config(@record)
%fieldset
%h3= _('Info')
%table.table.table-bordered.table-striped
- if rp_config.blank?
%tr
%td{:width => "495"}
%strong= _('Not Available')
- else
- rp_config.each_slice(2) do |items|
%tr
- items.each do |item|
%td{:width => "495"}
%strong
= h(item[:field])
= h(item[:description])
11 changes: 11 additions & 0 deletions app/views/resource_pool_cloud/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#main_div
- if %w(vms all_vms hosts clusters resource_pools).include?(@display) && @showtype != "compare"
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
- when "details"
= render :partial => "layouts/gtl", :locals => {:action_url => @lastaction}
- when 'main'
= render :partial => "layouts/textual_groups_generic"
- when 'config'
= render :partial => "config"
2 changes: 2 additions & 0 deletions app/views/resource_pool_cloud/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#main_div
= render :partial => 'layouts/gtl'
20 changes: 20 additions & 0 deletions app/views/resource_pool_infra/_config.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#maincontent
= render :partial => "layouts/flash_msg"

- if @display == "config_info"
rp_config = calculate_rp_config(@record)
%fieldset
%h3= _('Info')
%table.table.table-bordered.table-striped
- if rp_config.blank?
%tr
%td{:width => "495"}
%strong= _('Not Available')
- else
- rp_config.each_slice(2) do |items|
%tr
- items.each do |item|
%td{:width => "495"}
%strong
= h(item[:field])
= h(item[:description])
11 changes: 11 additions & 0 deletions app/views/resource_pool_infra/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#main_div
- if %w(vms all_vms hosts clusters resource_pools).include?(@display) && @showtype != "compare"
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
- when "details"
= render :partial => "layouts/gtl", :locals => {:action_url => @lastaction}
- when 'main'
= render :partial => "layouts/textual_groups_generic"
- when 'config'
= render :partial => "config"
2 changes: 2 additions & 0 deletions app/views/resource_pool_infra/show_list.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#main_div
= render :partial => 'layouts/gtl'
56 changes: 56 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,62 @@
save_post
},

:resource_pool_cloud => {
:get => %w[
download_data
download_summary_pdf
index
protect
show
show_list
tagging_edit
] +
compare_get,
:post => %w[
button
listnav_search_selected
protect
sections_field_changed
show
show_list
tagging_edit
tree_autoload
quick_search
] +
adv_search_post +
compare_post +
exp_post +
save_post
},

:resource_pool_infra => {
:get => %w[
download_data
download_summary_pdf
index
protect
show
show_list
tagging_edit
] +
compare_get,
:post => %w[
button
listnav_search_selected
protect
sections_field_changed
show
show_list
tagging_edit
tree_autoload
quick_search
] +
adv_search_post +
compare_post +
exp_post +
save_post
},

:restful_redirect => {
:get => %w[
index
Expand Down

0 comments on commit aebf2cf

Please sign in to comment.