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

Associate ph server to host #37

Merged
merged 12 commits into from
May 4, 2017
Merged

Associate ph server to host #37

merged 12 commits into from
May 4, 2017

Conversation

walteraa
Copy link
Member

Now the relationship is associated in Provider.

The relationship will be assign only if the physical server exists previously in Database and if exists a host . So, the relationship will be done in the second refresh for each Physical server.

This PR depends of #34 and maybe some change should be done after merge.

Use actice record procedures to assign relationship.
Use actice record procedures to assign relationship.
@walteraa walteraa changed the title Associate ph server to host [WIP]Associate ph server to host Mar 24, 2017
@miq-bot miq-bot added the wip label Mar 24, 2017
@walteraa walteraa closed this Mar 28, 2017
@walteraa
Copy link
Member Author

Reopen to rebuild.

@walteraa walteraa reopened this Mar 28, 2017
@walteraa walteraa closed this Mar 28, 2017
@walteraa
Copy link
Member Author

Reopen to rebuild.

@walteraa walteraa reopened this Mar 28, 2017
@walteraa
Copy link
Member Author

@juliancheal @rodneyhbrown7 I am having migrations erros when I try to execute the refresh process. Is there any PR referring to migrations that solve these issues? Is missing only test if the refresh process will assign the physical server ID in host.

@walteraa walteraa changed the title [WIP]Associate ph server to host Associate ph server to host Mar 28, 2017
@miq-bot miq-bot removed the wip label Mar 28, 2017
@rodneyhbrown7
Copy link
Contributor

Walter what errors are you seeing in the refresh process?

@walteraa
Copy link
Member Author

@rodneyhbrown7

EmsRefresh::Refreshers::EmsRefresherMixin::PartialRefreshError: Cannot modify association 'ManageIQ::Providers::Lenovo::PhysicalInfraManager::PhysicalServer#hardware' because the source reflection class 'Hardware' is associated to 'ComputerSystem' via :has_one.

@rodneyhbrown7
Copy link
Contributor

Do you have the PR 14430 installed?

@rodneyhbrown7
Copy link
Contributor

ManageIQ/manageiq#14430 and #34

@walteraa
Copy link
Member Author

@rodneyhbrown7 I'm running MIQ core from julian/physical_provider_refresh bce86f9 "Fixed refresh for Physical Infra" and My provider branch was merged with juliancheal:refactor_refresh in your last commit.

def save_host_relationship(node)
# Assign a physicalserver and host if server already exists and
# some host match with physical Server's serial number
server = PhysicalServer.find_by(:uuid => node.uuid, :ems_id => @ems.id)
Copy link
Contributor

@rodneyhbrown7 rodneyhbrown7 Apr 5, 2017

Choose a reason for hiding this comment

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

:uuid is not part of the PhysicalServer definition. I think this needs to be changed to find_by(:ems_ref => node.uuid

Copy link
Member Author

@walteraa walteraa Apr 5, 2017

Choose a reason for hiding this comment

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

Was the :uuid removed from Physical server?

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 changed it to :ems_ref.

# Filled in later conditionally on what's available
:computer_system => {:hardware => {:networks => [], :firmwares => []}}
}
new_result[:hardware] = get_hardwares(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

The hardware element is not associated to the physical server directly. Hardware is associated to ComputerSystem which is associated to the PhysicalServer (see L80) . Rails will not resolve this assignment.

Copy link
Member Author

Choose a reason for hiding this comment

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

This assignment come from @juliancheal's branch. What do you think about @rodneyhbrown7's concern, Julian?

Copy link
Contributor

@rodneyhbrown7 rodneyhbrown7 Apr 5, 2017

Choose a reason for hiding this comment

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

If you look at #34 This assignment is now new_result[:computer_system][:hardware] = get_hardwares(node). It may be worth rebasing this PR from 34 before it is merged. I was testing this yesterday and the assignment that was there before threw an exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll do a rebase, @rodneyhbrown7, thanks!

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.

}
}
# Filled in later conditionally on what's available
:computer_system => {:hardware => {:networks => [], :firmwares => []}}
Copy link
Contributor

Choose a reason for hiding this comment

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

This change will be functional but removes formatting that was added previously. Rubocop will probably complain about laying this out on a single line like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rodneyhbrown7 I did this change because rubocop was warning about the previous structure made by Julian. Rubocop doesn't warn about this format.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Good. Thanks Walter.

@miq-bot
Copy link
Member

miq-bot commented Apr 11, 2017

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

return node.uuid, new_result
end

def save_host_relationship(node)
Copy link
Member

Choose a reason for hiding this comment

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

I believe we should just be finding hosts here, but not saving them. All saving should be done in ManageIQ in SaveInventory.

Copy link
Member Author

Choose a reason for hiding this comment

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

@juliancheal I don't figured out how to send a save host to MIQ core from here. I mean, the ID of relationship was saved in Physical server, as you guys defined, so, once we found the Host ID and the Physical server ID which matches considering the LXCA association(serial_number and service_tag equals), how to do that in Core?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you do the look up and assignments in the refresher as you have already implemented, but you remove the line that saves the server instance. I think that the existing code in save_ems_physical_infra_inventory (https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_refresh/save_inventory_physical_infra.rb#L8 ) should save the details without any additional changes. This needs to be verified.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @rodneyhbrown7 , I figured out this process(which use the core to save the objects) before, it isn't the problem. The problem is that the relationship is saved in the Host object, so to use the ems_refresh/save_inventory_physical_infra.rb is unfeasible considering the structure proposed by RH guys.

The only way that we can use this, is converting the Host object found in a Hash, adding it as a "sub hash" in the Physical server hash and setting up a child key to host in save_physical_server method in ems_refresh/save_inventory_physical_infra.rb file.

But it looks like a workaround.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is a work around. I think that is the way this is intended to work. I believe all we need to do is remove the save! operation in the refresher and then add the :host as a child key in save_physical_server. This is working for me locally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok @rodneyhbrown7, I'll do that as I described.

Now Host object is passing to Physical server Hash. Before was passing a Hash, but the save method throws an error.
There isn't necessity search a physical server.
Then, just need find a host previously saved in database to create the relationship.
@miq-bot
Copy link
Member

miq-bot commented May 3, 2017

Checked commits https://github.com/lenovo/manageiq-providers-lenovo/compare/da38bd3de9757209bedd2479f2dd4232071c066f~...2a8728de5465820b3212695b30f604424ad7fbb8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@AndreyMenezes
Copy link
Member

@juliancheal can you merge this PR? @rodneyhbrown7

@blomquisg blomquisg assigned juliancheal and unassigned blomquisg May 4, 2017
@juliancheal
Copy link
Member

LGTM 👍

@juliancheal juliancheal merged commit 288ae9d into ManageIQ:master May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants