-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add endpoint and rabl nodes for IoP #934
Add endpoint and rabl nodes for IoP #934
Conversation
3f71c20
to
1d61d10
Compare
02a9d1b
to
d477dd1
Compare
d477dd1
to
3b30531
Compare
I like the rabl + api work. But looks like we can do with a simpler host details controller for the advisors engine. So recommending changes. - before_action :find_organization
-
+ api :GET, "insights_advisor/host_details", N_('fetch host details given insights uuid')
+ param :host_uuids, Array, required: true
def host_details
- @hosts = ::Host::Managed.search_for(params[:search] || "", :order => params[:order]).where(:organization_id => @organization.id).includes(:insights)
+ uuids = params.require(:host_uuids)
+ @hosts = ::Host.joins(:insights).where(:insights => {:uuid => uuids })
respond_to do |format|
format.json { render 'api/v2/insights_advisor/host_details' }
end
end No need to search as I initially thought we would. I just pass in a list of uuids that only insights and katello knows about. |
@parthaa Thanks, updated! |
I removed the search param from the controller. But didn't remove it from scoped_search since I don't see any harm in keeping it. |
app/controllers/api/v2/insights_advisor/insights_advisor_controller.rb
Outdated
Show resolved
Hide resolved
app/controllers/api/v2/advisor_engine/advisor_engine_controller.rb
Outdated
Show resolved
Hide resolved
Co-authored-by: Partha Aji <parthaa@gmail.com>
Works well $ curl -uadmin:changeme "https://buku.paji.example.com/api/v2/advisor_engine/host_details?host_uuids[]=85606035-29da-46ea-8bfd-020ce68a7b38"|jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 637 100 637 0 0 2181 0 --:--:-- --:--:-- --:--:-- 2174
[
{
"name": "another-rhel9.paji.example.com",
"insights_uuid": "85606035-29da-46ea-8bfd-020ce68a7b38",
"insights_hit_details": "{.....}"
} |
[1] pry(main)> Host.last.insights
=> #<InsightsFacet:0x00007f8501644e38 id: 11, host_id: 6, uuid: "85606035-29da-46ea-8bfd-020ce68a7b38", hits_count: -39>
[2] pry(main)> Host.search_for("insights_uuid=85606035-29da-46ea-8bfd-020ce68a7b38")
=> [#<Host::Managed:0x00007f85015f1210
id: 6,
name: "another-rhel9.paji.example.com",
last_compile: Thu, 09 Jan 2025 20:32:54.000000000 UTC +00:00,
last_report: nil,
updated_at: Thu, 09 Jan 2025 20:32:54.149480000 UTC +00:00,
created_at: Sat, 21 Dec 2024 05:47:58.270068000 UTC +00:00,
root_pass: nil,
architecture_id: 1,
operatingsystem_id: 2,
ptable_id: nil,
medium_id: nil,
build: false,
comment: "",
disk: nil,
installed_at: Sat, 21 Dec 2024 05:48:30.956451000 UTC +00:00,
model_id: 1,
hostgroup_id: nil,
owner_id: 4,
owner_type: "User",
enabled: true,
puppet_ca_proxy_id: nil,
managed: false,
use_image: nil,
image_file: nil,
uuid: nil,
compute_resource_id: nil,
puppet_proxy_id: nil,
certname: nil,
image_id: nil,
organization_id: 1,
location_id: 2,
type: "Host::Managed",
otp: nil,
realm_id: nil,
compute_profile_id: nil,
provision_method: nil,
grub_pass: nil,
global_status: 2,
lookup_value_matcher: "[FILTERED]",
pxe_loader: nil,
initiated_at: Sat, 21 Dec 2024 05:48:06.327761000 UTC +00:00,
build_errors: nil,
creator_id: 1>]
[3] pry(main)> |
insights_uuid
, so you can search hosts by their Insights UUID.insights_facet
so I stop going crazy 😄/api/v2/insights_advisor/host_details
, which returns only Insights-related details about hosts.