-
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
Change the way that network device details are displayed #3398
Conversation
@miq-bot add_label wip |
@AparnaKarve In this PR, I have created a controller, etc. for guest_devices so that network device details can be displayed. Physical server network device details are currently stored in the guest_devices database table with a device type of ethernet. When you click on the Guest Devices row in the UI, it will take you to a page displaying all guest devices. A couple of questions: 1. Is there a way to only display guest devices with a type of "ethernet" when clicking on this link? Maybe somehow specify a filter in the link? 2. Is there a way to dynamically change the "Guest Devices" heading for the table to "Network Devices" when navigating to this page from the link? Please see screenshots above. Thanks |
@skovic You might have to use something called This is a broader picture of how The model should have a class method that would look something like this - def self.with_ethernet_type
where(:device_type => "ethernet")
end And in the controller, you would have to override -include Mixins::GenericListMixin
+def show_list
+ options = {:model => "GuestDevice", :named_scope => [:with_ethernet_type]}
+ process_show_list(options)
+end Also look up some existing
Add this line to GuestDevice: Network Device |
@AparnaKarve I was able to get the page to have a "Network Devices" heading and display only the ethernet devices using your suggestions. Thanks |
@AparnaKarve Is there a way to only display the guest devices on the Guest Devices page that are associated with a given server? For example, if you click on the Network Devices row from the physical server summary page of a particular server, the Guest Devices page should show the guest devices that are associated with that server instead of all guest devices. Thanks |
end | ||
device | ||
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.
You will need a nested display here, as shown below -
(please make adjustments to the below method as necessary)
def textual_network_devices
hardware_nics = @record.hardware.nics.count
h = {:label => _("Network Devices"), :icon => "ff ff-network-card", :value => hardware_nics}
if hardware_nics > 0
h[:link] = "/physical_server/#{@record.id}?display=guest_devices"
end
h
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.
Note that "/physical_server/#{@record.id}?display=guest_devices"
will work if there is an association between a physical server and a guest device.
Is it possible to add that association in the model if it does not already exist?
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.
@AparnaKarve I created an association between physical server and guest device, but "/physical_server/#{@record.id}?display=guest_devices"
doesn't seem to be working. When I click on the link, I get a page with an error that says "The page you were looking for doesn't exist" and in development.log, I get these errors:
[----] I, [2018-02-14T06:43:08.764242 #6493:2abc084e2ea8] INFO -- : Started GET "/physical_server/2?display=guest_devices" for 127.0.0.1 at 2018-02-14 06:43:08 -0500
[----] F, [2018-02-14T06:43:08.790984 #6493:2abc084e2ea8] FATAL -- :
[----] F, [2018-02-14T06:43:08.791066 #6493:2abc084e2ea8] FATAL -- : ActionController::RoutingError (No route matches [GET] "/physical_server/2"):
[----] F, [2018-02-14T06:43:08.791093 #6493:2abc084e2ea8] FATAL -- :
[----] F, [2018-02-14T06:43:08.791116 #6493:2abc084e2ea8] FATAL -- : actionpack (5.0.6) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.6) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.6) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
railties (5.0.6) lib/rails/engine.rb:522:in `call'
puma (3.7.1) lib/puma/configuration.rb:232:in `call'
puma (3.7.1) lib/puma/server.rb:578:in `handle_request'
puma (3.7.1) lib/puma/server.rb:415:in `process_client'
puma (3.7.1) lib/puma/server.rb:275:in `block in run'
puma (3.7.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
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.
@AparnaKarve Is there another change that I need to make somewhere to get this to work? Thanks
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.
@skovic Looks like I missed a show
action in the above url
It should have been -
"/physical_server/show/#{@record.id}?display=guest_devices"
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.
I think you are just missing this method in the physical server controller -
def self.display_methods
%w(guest_devices)
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.
@AparnaKarve Thanks. The page loads now, but it doesn't load a table with guest device details -- it only has the heading. I think I have the guest device / physical server relation set up correctly; I am able to access @record.guest_devices from the physical server textual_summary.rb file -- it returns a list of guest devices associated with the server. What are some other things I could check? Please see the screenshot below:
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.
I am able to access @record.guest_devices from the physical server textual_summary.rb file -- it returns a list of guest devices associated with the server.
Ok, that is good.
So now you need the actual display
method in your Physical Server controller -
def display_guest_devices
nested_list(GuestDevice, {:named_scope => :with_ethernet_type})
end
Note that the nested list implementation does not use guest_device_controller
- so if it's not being used for any other use case, you can remove it
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.
@AparnaKarve I added the display_guest_devices method, but the page still doesn't display the table of devices. It still looks like the screenshot above. There doesn't seem to be any associated errors in the logs. How can I further debug this? Thanks
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.
@skovic Can you push your latest code - that way I can troubleshoot it better.
Thanks.
@@ -2,7 +2,7 @@ module PhysicalServerHelper::TextualSummary | |||
def textual_group_properties | |||
TextualGroup.new( | |||
_("Properties"), | |||
%i(name model product_name manufacturer machine_type serial_number ems_ref capacity memory cores health_state loc_led_state) | |||
%i(name model product_name manufacturer machine_type serial_number ems_ref capacity memory cores network_devices health_state loc_led_state) |
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.
Specify network_devices
in a new Textual Group - Relationships
def textual_group_relationships
TextualGroup.new(_("Relationships"), %i(network_devices))
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.
Actually, on second thoughts, displaying it as 'Properties' (the way you have it currently), should be fine.
@skovic It looks like you need a nested display list here. |
10f63d8
to
024ab54
Compare
@AparnaKarve The latest code has been pushed. Thanks |
@skovic I could not test your exact requirement since I did not have the corresponding model changes. Although it looks like, to display the nested list, you will need this in your show.haml - #main_div
- - if %w(physical_servers).include?(@display)
+ - if %w(guest_devices physical_servers).include?(@display)
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
- case @showtype
|
@AparnaKarve The change to show.haml fixed the problem. The page now displays the table of devices correctly. Thank you for looking into this. |
@miq-bot add_label compute/physical infrastructure |
@miq-bot remove_label wip |
@agrare Also this PR. Thanks |
@skovic Thanks for the update! |
@@ -163,6 +155,15 @@ def textual_health_state | |||
{:label => _("Health State"), :value => @record.health_state} | |||
end | |||
|
|||
def textual_network_devices | |||
hardware_nics_count = @record.hardware.nics.count |
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.
@record.guest_devices
would be the same as @record.hardware.nics
, right?
Do you want to use @record.guest_devices.count
here in order to be consistent with the nested display list?
i.e. both the link and the actual list rely on the PhysicalServer/GuestDevice association
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.
@AparnaKarve @record.hardware.nics
is different because it returns guest devices that have a device_type of 'ethernet' which is what we want here. @record.guest_devices
would return all guest devices including storage adapters, ports, etc. which we don't want included in the count.
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.
Ok, thanks for that clarification.
@record.hardware.nics
makes sense to get the count for the 'ethernet' guest devices
Core PR has been merged |
@AparnaKarve @agrare Any other changes needed in this PR? Thanks |
def show_list | ||
options = {:model => "GuestDevice", :named_scope => [:with_ethernet_type]} | ||
process_show_list(options) | ||
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.
@skovic I think you can remove the show_list
override from here since we are not using it anymore.
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.
@AparnaKarve I removed the override for show_list, and named_scope still seems to work. How is it still working without this override? Just curious. Thanks
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.
The nested display list is using named_scope
, and that's all we need to make named_scope
work.
Note that the nested display list is an action that is called on physical_server_controller
(the parent controller )and not on guest_device_controller
.
In other words, GuestDeviceController#show_list
is not being used at all -- hence you can remove that method from the controller and even routes.rb
.
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.
@AparnaKarve OK, got it. Thank you for the explanation. I'll remove the override.
@skovic Would you be able to add a specs for the following -
|
@AparnaKarve I added tests for the controllers as requested. I was able to run the tests successfully locally, so I'm not sure why the Travis run failed. |
Checked commits skovic/manageiq-ui-classic@10e0773~...f6043e3 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@skovic LGTM @dclarizio Good to go when green |
@dclarizio Tests are passing now |
This PR changes the way that network device details are displayed on the physical server summary page. The existing Network Devices table was removed, and a new row named Network Devices was added to the Properties table. In this new row, the number of network devices a server has is displayed, and this row can be clicked on to go to a page displaying all network devices. Clicking on an entry on the network devices page takes the user to the network device summary page for that device.
This PR depends on changes made in ManageIQ/manageiq#16996