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

Physical server page #970

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ca99b62
[Routes] Adds routes to physical_server
Mar 20, 2017
95edeb1
[EmsCommon] Adds physical_server flags
Mar 20, 2017
0ef30c0
[ui_constants] Adds physical_server structure
Mar 20, 2017
d60cc0a
[QuadIcon] Adds PhysicalServer structure
Mar 20, 2017
3c0e12f
[TextualSummary] Adds physical server flag
Mar 21, 2017
8affee9
[TextualSummary] Adds physical server flag
Mar 21, 2017
aa60337
[PhysicalServerFlags] Adds physical server flag
Mar 21, 2017
92c7549
[PhysicalServerViews] Adds all physical server views
Mar 21, 2017
4feb863
[PhysicalServerController] Adds physical server's controller
Mar 21, 2017
7142a11
[PhysicalServerToolbar] Adds physical server's toolbar structure.
Mar 21, 2017
bef6016
Add helpers to physical server pages
Mar 21, 2017
471a4e2
Change physical infra helpers
Mar 21, 2017
fb91056
Add images assets to physical server pages
Mar 21, 2017
ea20828
[Fix] Fixes all warning made by rubocop
Mar 21, 2017
0a3a4a3
[Fix] Fixes warning in files made by rubocop
Mar 22, 2017
4b2916a
[Fix] Fixes of warning made by rubocop into views and helpers of phys…
Mar 22, 2017
7bb757a
[Fix] Fixing some issues
Mar 22, 2017
7ad7e4b
[Fix] Changes html_safe to safe_join
Mar 22, 2017
019c7f4
[Typo] Typo some errors warning by rubocop
Mar 22, 2017
fefe826
[Typo] Delete a blank space after backslash
Mar 22, 2017
4d82e5d
[Fix] Turns into hash rockets syntax
Mar 22, 2017
5c0ef75
[Fix] Inserts '.try' method call
Mar 22, 2017
dc082d9
Merge remote-tracking branch 'manageiq/master' into physical_server_page
Mar 23, 2017
6d646bc
[BugFix] Changes the attribute methods call
Mar 23, 2017
26de5af
Create fetures for physical servers toolbar's buttons.
gabrielsvinha Apr 7, 2017
4b08d75
Update ci processing with methods for toolbar buttons
gabrielsvinha Apr 7, 2017
87c39e4
Update toolbar button with modify methods
gabrielsvinha Apr 7, 2017
f3c5a59
Insert cases for ems common show toolbar buttons
gabrielsvinha Apr 7, 2017
f069e05
Update textual summary name methods
gabrielsvinha Apr 7, 2017
19d23a1
Fix methods calls for physical server center button
gabrielsvinha Apr 10, 2017
f3f6bdc
Merge remote-tracking branch 'ManageIQ/master' into physical_server_page
gabrielsvinha Apr 10, 2017
9b82528
Remove & operators from physical server textual summary
gabrielsvinha Apr 11, 2017
7e836c4
Removes vms variable.
gabrielsvinha Apr 11, 2017
762d426
Fix ems_common controller
walteraa Apr 19, 2017
3f36681
Merge remote-tracking branch 'manageiq/master' into physical_server_page
walteraa Apr 19, 2017
8adb93b
Fix rubocop issues
walteraa Apr 19, 2017
301bb36
Fix rubocup styles for physical server textual summary
gabrielsvinha Apr 19, 2017
1c139d0
Merge branch 'physical_server_page' of github.com:lenovo/manageiq-ui-…
gabrielsvinha Apr 19, 2017
017ae3f
fixed robocop issues
MaysaMacedo Apr 19, 2017
088fb68
Fix rubocup styles for physical server textual summary
gabrielsvinha Apr 20, 2017
0fc2547
Merge remote-tracking branch 'ManageIQ/master' into physical_server_page
gabrielsvinha Apr 24, 2017
4bfd07a
merged 'physical_server_page' into fix
MaysaMacedo Apr 25, 2017
462f14f
Merge remote-tracking branch 'upstreamMIQ/master' into physical_serve…
MaysaMacedo Apr 25, 2017
13ee483
Fix CI processing controller
walteraa Apr 25, 2017
420a230
Merge remote-tracking branch 'upstream/physical_server_page' into phy…
MaysaMacedo Apr 25, 2017
ee96de7
fixed code climate issues
MaysaMacedo Apr 25, 2017
6e61f01
fixed rubocop issues
MaysaMacedo Apr 25, 2017
fd8c51e
Merge branch 'physical_server_page_fix' into HEAD
MaysaMacedo Apr 25, 2017
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
Binary file added app/assets/images/100/healthstate-normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/assets/images/svg/healthstate-critical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/assets/images/svg/healthstate-unknown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 18 additions & 27 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def set_ownership
end
end
end

alias_method :image_ownership, :set_ownership
alias_method :instance_ownership, :set_ownership
alias_method :vm_ownership, :set_ownership
Expand All @@ -85,7 +84,6 @@ def ownership(ownership_items = [])
drop_breadcrumb(:name => _("Set Ownership"), :url => "/vm_common/ownership")
ownership_items = params[:rec_ids] if params[:rec_ids]
build_ownership_info(ownership_items)
return if @ownershipitems.empty?
build_targets_hash(@ownershipitems)
if @sb[:explorer]
@refresh_partial = "shared/views/ownership"
Expand Down Expand Up @@ -134,18 +132,11 @@ def build_ownership_hash(ownership_items)
@group = group ? group.id.to_s : nil
Rbac.filtered(MiqGroup).each { |g| @groups[g.description] = g.id.to_s }
@user = @group = DONT_CHANGE_OWNER if ownership_items.length > 1
@ownershipitems = Rbac.filtered(klass.where(:id => ownership_items).order(:name), :class => klass)
raise _('Invalid items passed') unless @ownershipitems.pluck(:id).to_set == ownership_items.map(&:to_i).to_set
@ownershipitems = klass.find(ownership_items).sort_by(&:name)
{:user => @user,
:group => @group}
end

def valid_items_for(klass, param_ids)
scope = klass.respond_to?(:with_ownership) ? klass.with_ownership : klass
checked_ids = Rbac.filtered(scope.where(:id => param_ids)).pluck(:id)
checked_ids.to_set == param_ids.to_set
end

def ownership_update
case params[:button]
when "cancel"
Expand Down Expand Up @@ -176,10 +167,7 @@ def ownership_update
end

klass = get_class_from_controller_param(request.parameters[:controller])
param_ids = params[:objectIds].map(&:to_i)
raise _('Invalid items selected.') unless valid_items_for(klass, param_ids)

result = klass.set_ownership(param_ids, opts)
result = klass.set_ownership(params[:objectIds].map(&:to_i), opts)
unless result == true
result["missing_ids"].each { |msg| add_flash(msg, :error) } if result["missing_ids"]
result["error_updating"].each { |msg| add_flash(msg, :error) } if result["error_updating"]
Expand Down Expand Up @@ -1895,15 +1883,8 @@ def process_cloud_object_storage_buttons(pressed)
end

def cloud_object_store_button_operation(klass, task)
# Map to instance method name
case task
when "delete"
method = "#{task}_#{klass.name.underscore.to_sym}"
display_name = _(task.capitalize)
else
display_name = _(task.capitalize)
method = task = "#{klass.name.underscore.to_sym}_#{task}"
end
method = "#{task}_#{klass.name.underscore.to_sym}"
display_name = _(task.capitalize)

items = []
# Either a list or coming from a different controller
Expand Down Expand Up @@ -1942,11 +1923,9 @@ def get_rec_cls
when "service"
Service
when "cloud_object_store_container"
params[:pressed].starts_with?("cloud_object_store_object") ? CloudObjectStoreObject : CloudObjectStoreContainer
when "cloud_object_store_object"
CloudObjectStoreObject
CloudObjectStoreContainer
when "ems_storage"
params[:pressed].starts_with?("cloud_object_store_object") ? CloudObjectStoreObject : CloudObjectStoreContainer
CloudObjectStoreContainer
else
VmOrTemplate
end
Expand Down Expand Up @@ -2526,6 +2505,18 @@ def refreshhosts
host_button_operation('refresh_ems', _('Refresh'))
end

def refreshphysicalservers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.
It's best to handle all Physical Server actions in physical_server_controller

#TODO refresh physical servers
end

def deletephysicalservers
#TODO delete physical servers
end

def editphysicalservers
#TODO edit physical servers
end

# Scan all selected or single displayed host(s)
def scanhosts
assert_privileges("host_scan")
Expand Down
80 changes: 73 additions & 7 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,68 @@ def show_ad_hoc_metrics
drop_breadcrumb(:name => @ems.name + _(" (Ad hoc Metrics)"), :url => show_link(@ems))
end

def show_topology
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this method and instead use the MoreShowActions mixin which has the show_topology method.

@showtype = "topology"
@lastaction = "show_topology"
drop_breadcrumb(:name => @ems.name + _(" (Topology)"), :url => show_link(@ems))
end

def view_setup_params
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this method being called? What does it do?

{
"instances" => [ManageIQ::Providers::CloudManager::Vm, _("Instances")],
"images" => [ManageIQ::Providers::CloudManager::Template, _("Images")],
"block_storage_managers" => [ManageIQ::Providers::StorageManager,
_("Block Storage Managers"),
:block_storage_managers],
"object_storage_managers" => [ManageIQ::Providers::StorageManager,
_("Object Storage Managers"),
:object_storage_managers],
"storage_managers" => [ManageIQ::Providers::StorageManager,
_("Storage Managers"),
:storage_managers],
"miq_templates" => [MiqTemplate, _("Templates")],
"vms" => [Vm, _("VMs")],
"orchestration_stacks" => [OrchestrationStack, _("Stacks")],
# "configuration_jobs" => [ConfigurationJob, _("Configuration Jobs")],
"cloud_object_store_containers" => [CloudObjectStoreContainer, _('Cloud Object Store Containers')],
'containers' => [Container, _('Containers')],
'container_replicators' => [ContainerReplicator, _('Container Replicators')],
'container_nodes' => [ContainerNode, _('Container Nodes')],
'container_groups' => [ContainerGroup, _('Pods')],
'container_services' => [ContainerService, _('Container Services')],
'container_images' => [ContainerImage, _('Container Images')],
'container_routes' => [ContainerRoute, _('Container Routes')],
'container_builds' => [ContainerBuild, _('Container Builds')],
'container_projects' => [ContainerProject, _('Container Projects')],
'container_image_registries' => [ContainerImageRegistry, _('Container Image Registries')],
'container_templates' => [ContainerTemplate, _('Container Templates')],
'availability_zones' => [AvailabilityZone, _('Availability Zones')],
'host_aggregates' => [HostAggregate, _('Host Aggregates')],
'middleware_servers' => [MiddlewareServer, _('Middleware Servers')],
'middleware_deployments' => [MiddlewareDeployment, _('Middleware Deployments')],
'middleware_datasources' => [MiddlewareDatasource, _('Middleware Datasources')],
'middleware_domains' => [MiddlewareDomain, _('Middleware Domains')],
'middleware_server_groups' => [MiddlewareServerGroup, _('Middleware Server Groups')],
'middleware_messagings' => [MiddlewareMessaging, _('Middleware Messagings')],
'cloud_tenants' => [CloudTenant, _('Cloud Tenants')],
'cloud_volumes' => [CloudVolume, _('Cloud Volumes')],
'cloud_volume_snapshots' => [CloudVolumeSnapshot, _('Cloud Volume Snapshots')],
'flavors' => [Flavor, _('Flavors')],
'security_groups' => [SecurityGroup, _('Security Groups')],
'floating_ips' => [FloatingIp, _('Floating IPs')],
'network_routers' => [NetworkRouter, _('Network Routers')],
'network_ports' => [NetworkPort, _('Network Ports')],
'cloud_subnets' => [CloudSubnet, _('Cloud Subnets')],
'cloud_networks' => [CloudNetwork, _('Cloud Networks')],
'load_balancers' => [LoadBalancer, _('Load Balancers')],
'storages' => [Storage, _('Managed Datastores')],
'ems_clusters' => [EmsCluster, title_for_clusters],
'persistent_volumes' => [PersistentVolume, _('Volumes'), :persistent_volumes],
'hosts' => [Host, _("Managed Hosts")],
'physical_servers' => [PhysicalServer, _("Physical Servers")],
}
end

def display_block_storage_managers
nested_list('block_storage_manager', ManageIQ::Providers::StorageManager, :parent_method => :block_storage_managers)
end
Expand Down Expand Up @@ -337,6 +399,10 @@ def button
when "network_router_tag" then tag(NetworkRouter)
when "orchestration_stack_tag" then tag(OrchestrationStack)
when "security_group_tag" then tag(SecurityGroup)
# Physical server
when "physical_server_refresh" then refreshphysicalservers
when "physical_server_delete" then deletephysicalservers
when "physical_server_edit" then editphysicalservers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this button handling in physical_server_controller, not here in ems_common

end

pfx = pfx_for_vm_button_pressed(params[:pressed])
Expand Down Expand Up @@ -683,6 +749,13 @@ def form_instance_vars
@hawkular_security_protocols = retrieve_hawkular_security_protocols
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this change related to Physical Servers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as below.

end

def retrieve_hawkular_security_protocols
[[_('SSL'), 'ssl-with-validation'],
[_('SSL trusting custom CA'), 'ssl-with-validation-custom-ca'],
[_('SSL without validation'), 'ssl-without-validation'],
[_('Non-SSL'), 'non-ssl']]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the removed code was added back.
Why was it removed though? Was it removed inadvertently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was merged from master.

end

def retrieve_provider_regions
managers = model.supported_subclasses.select(&:supports_regions?)
managers.each_with_object({}) do |manager, provider_regions|
Expand Down Expand Up @@ -733,13 +806,6 @@ def retrieve_container_security_protocols
[_('SSL without validation'), 'ssl-without-validation']]
end

def retrieve_hawkular_security_protocols
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this unrelated method being removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was changes in the master branch and came up with a merge made. But this is fixed in the next commits:

https://github.com/lenovo/manageiq-ui-classic/blob/physical_server_page/app/controllers/ems_common.rb#L776

[[_('SSL'), 'ssl-with-validation'],
[_('SSL trusting custom CA'), 'ssl-with-validation-custom-ca'],
[_('SSL without validation'), 'ssl-without-validation'],
[_('Non-SSL'), 'non-ssl']]
end

# Get variables from edit form
def get_form_vars
@ems = @edit[:ems_id] ? model.find_by_id(@edit[:ems_id]) : model.new
Expand Down
117 changes: 117 additions & 0 deletions app/controllers/physical_server_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
class PhysicalServerController < ApplicationController
include Mixins::GenericListMixin
include Mixins::GenericShowMixin

before_action :check_privileges
before_action :session_data
after_action :cleanup_action
after_action :set_session_data

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

def session_data
@title = _("Physical Servers")
@layout = "physical_server"
@lastaction = session[:physical_server_lastaction]
end

def collect_data(server_id)
PhysicalServerService.new(server_id, self).all_data
end

def set_session_data
session[:layout] = @layout
session[:physical_server_lastaction] = @lastaction
end

def show_list
# Disable the cache to prevent a caching problem that occurs when
# pressing the browser's back arrow button to return to the show_list
# page while on the Physical Server's show page. Disabling the cache
# causes the page and its session variables to actually be reloaded.
disable_client_cache

process_show_list
end

# Handles buttons pressed on the toolbar
def button
# Get the list of servers to apply the action to
servers = retrieve_servers

# Apply the action (depending on the button pressed) to the servers
apply_action_to_servers(servers)
end

private

# Maps button actions to actual method names to be called and the
# corresponding result status messages to be displayed
ACTIONS = {"physical_server_power_on" => [:power_on, "Power On"],
"physical_server_power_off" => [:power_off, "Power Off"],
"physical_server_restart" => [:restart, "Restart"],
"physical_server_blink_loc_led" => [:blink_loc_led, "Blink LED"],
"physical_server_turn_on_loc_led" => [:turn_on_loc_led, "Turn On LED"],
"physical_server_turn_off_loc_led" => [:turn_off_loc_led, "Turn Off LED"]}.freeze

# Displays an error message
def display_error_message(msg)
display_message(msg, :error)
end

# Displays a success message
def display_success_message(msg)
display_message(msg, :success)
end

# Displays a message
def display_message(msg, level)
add_flash(_(msg), level)
render_flash
end

# Returns a list of servers to which the button action will be applied
def retrieve_servers
server_id = params[:id]
servers = []

# A list of servers
if @lastaction == "show_list"
server_ids = find_checked_items
server_ids.each do |id|
servers.push(PhysicalServer.find_by('id' => id))
end
if server_ids.empty?
display_error_message("No server IDs found for the selected servers")
end
# A single server
elsif server_id.nil? || PhysicalServer.find_by('id' => server_id).nil?
display_error_message("No server ID found for the current server")
else
servers.push(PhysicalServer.find_by('id' => server_id))
end

servers
end

# Applies the appropriate action to a list of servers depending
# on the button pressed
def apply_action_to_servers(servers)
button_pressed = params[:pressed]

# Apply the appropriate action to each server
if ACTIONS.key?(button_pressed)
method = ACTIONS[button_pressed][0]
action_str = ACTIONS[button_pressed][1]
servers.each do |server|
server.send(method)
end
msg = "Successfully initiated the #{action_str} action"
display_success_message(msg)
else
display_error_message("Unknown action: #{button_pressed}")
end
end
end
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ def pdf_page_size_style
offline
orchestration_stack
physical_infra_topology
physical_server
persistent_volume
policy
policy_group
Expand Down Expand Up @@ -1312,6 +1313,7 @@ def render_listnav_filename
offline
orchestration_stack
persistent_volume
physical_server
resource_pool
retired
security_group
Expand Down Expand Up @@ -1380,6 +1382,7 @@ def render_listnav_filename
network_router
orchestration_stack
persistent_volume
physical_server
policy
resource_pool
scan_profile
Expand Down Expand Up @@ -1456,6 +1459,8 @@ def db_for_quadicon
case @layout
when "ems_infra"
:ems
when "ems_physical_infra"
:ems
when "ems_cloud"
:ems_cloud
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ApplicationHelper::Button::PhysicalServerFeatureButton < ApplicationHelper::Button::GenericFeatureButton

def visible?
true
end

def disabled?
false
end
end
Loading