Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions app/models/guest_device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ class GuestDevice < ApplicationRecord

has_many :firmwares, :dependent => :destroy
has_many :child_devices, -> { where(:parent_device_id => ids) }, :foreign_key => "parent_device_id", :class_name => "GuestDevice", :dependent => :destroy

alias_attribute :name, :device_name
Copy link
Member

Choose a reason for hiding this comment

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

Why was this needed? I don't disagree that guest_device.device_name is a bit repetitive but could this work with just using device_name?

Copy link
Author

Choose a reason for hiding this comment

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

@agrare Without this alias, I get an error when I try to access the guest device summary page in the UI. Here is the backtrace of the error from development.log:

[----] F, [2018-02-26T11:10:45.064300 #4797:2afb9bcf2a44] FATAL -- : Error caught: [NoMethodError] undefined method `name' for #<GuestDevice:0x007f03c8a1ae28>
/home/skovic/.gem/ruby/gems/activemodel-5.0.6/lib/active_model/attribute_methods.rb:433:in `method_missing'
/home/skovic/dev/network-device/manageiq-ui-classic/app/controllers/mixins/generic_show_mixin.rb:81:in `show_main'
/home/skovic/dev/network-device/manageiq-ui-classic/app/controllers/mixins/generic_show_mixin.rb:13:in `show'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/abstract_controller/base.rb:188:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/rendering.rb:30:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:126:in `call'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:455:in `call'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/abstract_controller/callbacks.rb:19:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/rescue.rb:20:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/notifications.rb:164:in `block in instrument'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/notifications.rb:164:in `instrument'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
/home/skovic/.gem/ruby/gems/activerecord-5.0.6/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/abstract_controller/base.rb:126:in `process'
/home/skovic/.gem/ruby/gems/actionview-5.0.6/lib/action_view/rendering.rb:30:in `process'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal.rb:190:in `dispatch'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_controller/metal.rb:262:in `dispatch'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:32:in `serve'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:39:in `block in serve'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:26:in `each'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:26:in `serve'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:727:in `call'
/home/skovic/.gem/ruby/bundler/gems/manageiq-graphql-334da8c9270b/lib/manageiq/graphql/rest_api_proxy.rb:18:in `call'
/home/skovic/.gem/ruby/gems/secure_headers-3.0.3/lib/secure_headers/middleware.rb:10:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/etag.rb:25:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/conditional_get.rb:25:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/head.rb:12:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:232:in `context'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:226:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/cookies.rb:613:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:90:in `run_callbacks'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/home/skovic/.gem/ruby/gems/railties-5.0.6/lib/rails/rack/logger.rb:36:in `call_app'
/home/skovic/.gem/ruby/gems/railties-5.0.6/lib/rails/rack/logger.rb:26:in `call'
/home/skovic/.gem/ruby/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/request_id.rb:24:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/method_override.rb:22:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/runtime.rb:22:in `call'
/home/skovic/.gem/ruby/gems/activesupport-5.0.6/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
/home/skovic/.gem/ruby/gems/actionpack-5.0.6/lib/action_dispatch/middleware/static.rb:136:in `call'
/home/skovic/.gem/ruby/gems/rack-2.0.4/lib/rack/sendfile.rb:111:in `call'
/home/skovic/.gem/ruby/gems/railties-5.0.6/lib/rails/engine.rb:522:in `call'
/home/skovic/.gem/ruby/gems/puma-3.7.1/lib/puma/configuration.rb:232:in `call'
/home/skovic/.gem/ruby/gems/puma-3.7.1/lib/puma/server.rb:578:in `handle_request'
/home/skovic/.gem/ruby/gems/puma-3.7.1/lib/puma/server.rb:415:in `process_client'
/home/skovic/.gem/ruby/gems/puma-3.7.1/lib/puma/server.rb:275:in `block in run'
/home/skovic/.gem/ruby/gems/puma-3.7.1/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Copy link
Member

Choose a reason for hiding this comment

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

Okay so it is needed by some UI mixin, 👍


def self.with_ethernet_type
where(:device_type => "ethernet")
end
end
1 change: 1 addition & 0 deletions app/models/physical_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PhysicalServer < ApplicationRecord
has_one :hardware, :through => :computer_system
has_one :host, :inverse_of => :physical_server
has_one :asset_detail, :as => :resource, :dependent => :destroy
has_many :guest_devices, :through => :hardware

scope :with_hosts, -> { where("physical_servers.id in (select hosts.physical_server_id from hosts)") }

Expand Down
1 change: 1 addition & 0 deletions locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ en:
GenericObject: Generic Object
GenericObjectDefinition: Generic Object Class
GuestApplication: Guest Application
GuestDevice: Network Device
Host: Host / Node
HostPerformance: Performance - Host
IsoDatastore: ISO Datastore
Expand Down