-
Notifications
You must be signed in to change notification settings - Fork 897
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
Adding switches support for physical infra #16948
Adding switches support for physical infra #16948
Conversation
39ada3d
to
41099c9
Compare
41099c9
to
e6f86d7
Compare
@Fryguy, could you take a look at this PR? |
e6f86d7
to
c8eee09
Compare
app/models/switch.rb
Outdated
has_one :hardware, :dependent => :destroy | ||
|
||
belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :switches, | ||
:class_name => "ManageIQ::Providers::PhysicalInfraManager" |
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 this :class_name
is too specific for the base Switch
model.
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.
Hi @bdunne. Sorry for the delay. I am moving that to the provider and changing here to point to "ExtManagementSystem".
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.
@bdunne, I've updated the code. What do you think about?
c8eee09
to
e20cdc3
Compare
e20cdc3
to
8f0b175
Compare
app/models/switch.rb
Outdated
has_one :hardware, :dependent => :destroy | ||
|
||
belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :switches, | ||
:class_name => "ExtManagementSystem" |
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 don't think class_name is needed here
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.
Done.
@@ -2,7 +2,10 @@ module ManageIQ::Providers | |||
class PhysicalInfraManager < BaseManager | |||
include SupportsFeatureMixin | |||
|
|||
has_many :switches, :foreign_key => "ems_id", :dependent => :destroy, :inverse_of => :ext_management_system |
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.
@Fryguy didn't want to have two providers with the same named association InfraManager.switches actually representing two different things, can you name this something like physical_switches
and add a :class_name => "Switch"
?
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.
Yes, I think I can do something like that. I am preparing some changes according to the comment below. I will do that change and will update this 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.
Done.
@bdunne, @agrare, @rodneyhbrown7, a PR changing the way we consider asset_details will be merged soon, the schema is already ready for physical servers was merged. Since switches is a new concept here, I will do the same changes here and in the parser before we merge. Also, I am considering to add a new model called PhysicalSwitches. Thus, it is possible to have a different controller for the physical infra switches. I will remove the WIP prefix as soon I have updates here and I will let you know for review. |
699bc8e
to
c2e510c
Compare
@bdunne, @agrare, @rodneyhbrown7, this is ok for review. I can run without ManageIQ/manageiq-schema#180. Can you help me to confirm if it is a dependency? |
c2e510c
to
1b33d90
Compare
1b33d90
to
8674019
Compare
@saulotoledo I don't think ManageIQ/manageiq-schema#180 is a dependency of this, it looks like you have new vcrs in the -lenovo parsing PR, I'll test this out in the next day or two. |
This pull request is not mergeable. Please rebase and repush. |
84d1bea
to
224ebe5
Compare
61fb508
to
1d8a44f
Compare
app/models/hardware.rb
Outdated
@@ -4,6 +4,7 @@ class Hardware < ApplicationRecord | |||
belongs_to :miq_template, :foreign_key => :vm_or_template_id | |||
belongs_to :host | |||
belongs_to :computer_system | |||
belongs_to :physical_switch |
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.
do you need a :foreign_key => :switch_id
here?
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've added that in the PhysicalSwitch
object. Do not should be there? Also, since I am using :foreign_key
, it will work if I add the :inverse_of
as requested by the RuboCop?
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 get this error without it
>> hardware.physical_switch = physical_switch
ActiveModel::MissingAttributeError: can't write unknown attribute `physical_switch_id`
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/attribute.rb:182:in `with_value_from_database'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/attribute_set.rb:53:in `write_from_user'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/attribute_methods/write.rb:50:in `write_attribute_with_type_cast'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/attribute_methods/write.rb:32:in `write_attribute'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/attribute_methods.rb:361:in `[]='
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/associations/belongs_to_association.rb:76:in `replace_keys'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/associations/belongs_to_association.rb:14:in `replace'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/associations/singular_association.rb:22:in `writer'
from /home/agrare/.gem/ruby/2.4.3/gems/activerecord-5.0.7/lib/active_record/associations/builder/association.rb:119:in `physical_switch='
from (irb):4
It needs to work from both sides of the 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.
You're right. Thanks! It is fixed now.
ddca623
to
576ced0
Compare
576ced0
to
b963a8f
Compare
Checked commit saulotoledo@b963a8f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
This PR adds switches support for physical infra.
Depends on: