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

Adding switches support for physical infra #16948

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

saulotoledo
Copy link
Member

@saulotoledo saulotoledo commented Feb 5, 2018

This PR adds switches support for physical infra.

Depends on:

@miq-bot miq-bot added the wip label Feb 5, 2018
@saulotoledo saulotoledo force-pushed the add_physical_switch_support branch 6 times, most recently from 39ada3d to 41099c9 Compare February 7, 2018 15:07
@saulotoledo saulotoledo changed the title [WIP] Adding switches support for physical infra Adding switches support for physical infra Feb 16, 2018
@miq-bot miq-bot removed the wip label Feb 16, 2018
@saulotoledo
Copy link
Member Author

@Fryguy, could you take a look at this PR?

has_one :hardware, :dependent => :destroy

belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :switches,
:class_name => "ManageIQ::Providers::PhysicalInfraManager"
Copy link
Member

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.

Copy link
Member Author

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".

Copy link
Member Author

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?

@bdunne bdunne requested a review from agrare March 20, 2018 15:49
@saulotoledo saulotoledo changed the title Adding switches support for physical infra [WIP] Adding switches support for physical infra Mar 21, 2018
has_one :hardware, :dependent => :destroy

belongs_to :ext_management_system, :foreign_key => :ems_id, :inverse_of => :switches,
:class_name => "ExtManagementSystem"
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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"?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@saulotoledo
Copy link
Member Author

saulotoledo commented Mar 21, 2018

@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.

@miq-bot miq-bot added the wip label Mar 21, 2018
@saulotoledo saulotoledo force-pushed the add_physical_switch_support branch 2 times, most recently from 699bc8e to c2e510c Compare March 27, 2018 23:37
@saulotoledo saulotoledo changed the title [WIP] Adding switches support for physical infra Adding switches support for physical infra Mar 28, 2018
@saulotoledo
Copy link
Member Author

saulotoledo commented Mar 28, 2018

@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?

@miq-bot miq-bot removed the wip label Mar 28, 2018
@agrare
Copy link
Member

agrare commented Mar 29, 2018

@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.

@miq-bot
Copy link
Member

miq-bot commented Apr 4, 2018

This pull request is not mergeable. Please rebase and repush.

@saulotoledo saulotoledo force-pushed the add_physical_switch_support branch 2 times, most recently from 84d1bea to 224ebe5 Compare April 5, 2018 15:47
@saulotoledo saulotoledo force-pushed the add_physical_switch_support branch 2 times, most recently from 61fb508 to 1d8a44f Compare April 5, 2018 18:33
@@ -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
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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.

@saulotoledo saulotoledo force-pushed the add_physical_switch_support branch 5 times, most recently from ddca623 to 576ced0 Compare April 6, 2018 12:54
@miq-bot
Copy link
Member

miq-bot commented Apr 6, 2018

Checked commit saulotoledo@b963a8f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 0 offenses detected
Everything looks fine. ⭐

@agrare agrare merged commit fa45a97 into ManageIQ:master Apr 6, 2018
@agrare agrare added this to the Sprint 83 Ending Apr 9, 2018 milestone Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants