-
Notifications
You must be signed in to change notification settings - Fork 358
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
Physical server page #970
Changes from 35 commits
ca99b62
95edeb1
0ef30c0
d60cc0a
3c0e12f
8affee9
aa60337
92c7549
4feb863
7142a11
bef6016
471a4e2
fb91056
ea20828
0a3a4a3
4b2916a
7bb757a
7ad7e4b
019c7f4
fefe826
4d82e5d
5c0ef75
dc082d9
6d646bc
26de5af
4b08d75
87c39e4
f3c5a59
f069e05
19d23a1
f3f6bdc
9b82528
7e836c4
762d426
3f36681
8adb93b
301bb36
1c139d0
017ae3f
088fb68
0fc2547
4bfd07a
462f14f
13ee483
420a230
ee96de7
6e61f01
fd8c51e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this method and instead use the |
||
@showtype = "topology" | ||
@lastaction = "show_topology" | ||
drop_breadcrumb(:name => @ems.name + _(" (Topology)"), :url => show_link(@ems)) | ||
end | ||
|
||
def view_setup_params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect this |
||
end | ||
|
||
pfx = pfx_for_vm_button_pressed(params[:pressed]) | ||
|
@@ -683,6 +749,13 @@ def form_instance_vars | |
@hawkular_security_protocols = retrieve_hawkular_security_protocols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this change related to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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']] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the removed code was added back. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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| | ||
|
@@ -733,13 +806,6 @@ def retrieve_container_security_protocols | |
[_('SSL without validation'), 'ssl-without-validation']] | ||
end | ||
|
||
def retrieve_hawkular_security_protocols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this unrelated method being removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||
[[_('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 | ||
|
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 |
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 |
There was a problem hiding this comment.
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 inphysical_server_controller