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

Implement asset details collector #1

Merged
merged 1 commit into from
May 30, 2018

Conversation

tadeboro
Copy link
Contributor

New functionality from this commit stores information that is not
strictly related to the physical server to asset_details table that
serves as a source of data for summary view in ManageIQ UI.

Please take note that asset details mapping is fairly raw right now,
since mapping tree-like Redfish structures into flat array of XClarity
properties is not trivial and will probably need some tweaking based
on real data that we will get from test bed before we get it right.

This pull request needs ManageIQ/manageiq#17486 merged into core.

/cc @gberginc @matejart
@miq-bot assign @gtanzillo
@miq-bot add_label wip

@gberginc gberginc changed the title Implement asset details collector [WIP] Implement asset details collector May 29, 2018
@agrare agrare closed this May 29, 2018
@agrare agrare reopened this May 29, 2018
@agrare
Copy link
Member

agrare commented May 29, 2018

Dependent PR merged, kicking tests

private

def get_server_location(server)
chassis = [server.Links.Chassis[0]]
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for server.Links.Chassis to be nil or an empty array? If so you might want something like chassis = Array(server.Links.Chassis&.first)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

server.Links.Chassis cannot be nil and it should have only one element in properly configured services. That being said, assuming properly configured services might be a bit naive.

I will rework this part of the code to take into account those edge cases.

collector.physical_server_details.each do |d|
server = persister.physical_servers.find_or_build(d[:server_id])
details = persister.physical_server_details.find_or_build(server)
details.assign_attributes(
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for the server details to be built anywhere else? If these can't be created from multiple code paths it'd be better to skip the find_or_build and just use build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Server details are only built here. I used find_or_build here because I though that calling build might introduce duplicated entries on inventory refresh. Of course, I may be completely wrong here.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay I see what you mean, no the find_or_build part is only relative to the current data in the inventory collection, not what is in the database...that is evaluated during save time.

What you can also do is instead of server = find_or_build(..) you can do a server = persister.physical_servers.lazy_find(d[:server_id]) which will allow the server link to be evaluated at save time even if the server isn't in your current inventory_collections aka you were doing a targeted refresh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the code with your recommendations (and made a mental note to read the inventory-related source code once again).

@tadeboro tadeboro force-pushed the redfish-system-assets-collection branch from bf3b61a to 7a7f8a6 Compare May 30, 2018 10:44
@tadeboro
Copy link
Contributor Author

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] Implement asset details collector Implement asset details collector May 30, 2018
@miq-bot miq-bot removed the wip label May 30, 2018
@tadeboro tadeboro force-pushed the redfish-system-assets-collection branch from 7a7f8a6 to 77814f4 Compare May 30, 2018 13:53
collector.physical_server_details.each do |d|
server = persister.physical_servers.lazy_find(d[:server_id])
details = persister.physical_server_details.build(server)
details.assign_attributes(
Copy link
Member

Choose a reason for hiding this comment

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

Actually you don't need to assign_attribtues when using build, just pass this hash into build and pass in the manager ref.
So I think for this it'd be:

persister.physical_server_details.build(
  :resource    => server,
  :contact     => "",
  :description => "",
  ...
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the noise, I pushed the partial edit. Things should look better now.

@tadeboro tadeboro force-pushed the redfish-system-assets-collection branch from 77814f4 to fb1142b Compare May 30, 2018 14:03
New functionality from this commit stores information that is not
strictly related to the physical server to asset_details table that
serves as a source of data for summary view in ManageIQ UI.

Please take note that asset details mapping is fairly raw right now,
since mapping tree-like Redfish structures into flat array of XClarity
properties is not trivial and will probably need some tweaking based
on real data that we will get from test bed before we get it right.
@tadeboro tadeboro force-pushed the redfish-system-assets-collection branch from fb1142b to 146e89e Compare May 30, 2018 14:04
@agrare agrare added the enhancement New feature or request label May 30, 2018
@miq-bot
Copy link
Member

miq-bot commented May 30, 2018

Checked commit xlab-si@146e89e with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
7 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

@agrare agrare merged commit 146e89e into ManageIQ:master May 30, 2018
agrare added a commit that referenced this pull request May 30, 2018
@agrare agrare assigned agrare and unassigned gtanzillo May 30, 2018
@agrare agrare added this to the Sprint 87 Ending Jun 4, 2018 milestone May 30, 2018
@tadeboro tadeboro deleted the redfish-system-assets-collection branch May 31, 2018 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants