theforeman / foreman_rh_cloud

a plugin to Foreman that generates and uploads reports to the Red Hat cloud
GNU General Public License v3.0
6 stars 30 forks source link

Add convert2rhel fact to host report #896

Closed jeremylenz closed 1 week ago

jeremylenz commented 2 weeks ago

To test:

Setup

On a registered host, create a custom fact file that includes conversions.env.CONVERT2RHEL_THROUGH_FOREMAN:

[root@toledo8 ~]# cat /etc/rhsm/facts/convert2rhel.facts {
"conversions.version": "1",
"conversions.activity": "conversion",
"conversions.packages.0.nevra": "convert2rhel-0:2.0.0-1.el8.noarch",
"conversions.packages.0.signature": "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51",
"conversions.executed": "/usr/bin/convert2rhel",
"conversions.success": true,
"conversions.activity_started": "2024-07-11T17:28:54.281664Z",
"conversions.activity_ended": "2024-07-11T17:48:47.026664Z",
"conversions.source_os.id": "Cerulean Leopard",
"conversions.source_os.name": "AlmaLinux",
"conversions.source_os.version": "8.10",
"conversions.target_os.id": "Ootpa",
"conversions.target_os.name": "Red Hat Enterprise Linux",
"conversions.target_os.version": "8.10",
"conversions.env.CONVERT2RHEL_THROUGH_FOREMAN": "1",
"conversions.run_id": "null"
}

Update facts:

subscription-manager facts --update

Verify that the host's subscription_facet_attributes have convert2rhel_through_foreman: 1

Test

Ensure that the host's host_registration_insights parameter is set to true On the Inventory Upload page, click 'Sync inventory status' and wait for the sync to complete

On the host, run

organization_id=1 target=/var/lib/foreman/red_hat_inventory/generated_reports/ bundle exec rake rh_cloud_inventory:report:generate

You should see, at the end of the output, something like

Successfully generated /tmp/d20240827-17482-t377is/report_for_1.tar.xz for organization id 1

CD into that directory, then run

$ tar -vxf report_for_1.tar.xz
./
./metadata.json
./d5f5c08b-7903-4c58-8c08-53d1f37c753c.json

All files except metadata.json will be about individual hosts. Find your host and verify its json contains convert2rhel_through_foreman:

$ cat d5f5c08b-7903-4c58-8c08-53d1f37c753c.json | jq
{
  "report_slice_id": "d5f5c08b-7903-4c58-8c08-53d1f37c753c",
  "hosts": [
    {
      "fqdn": "rhel9b.fedora.example.com",
      "account": "1212729",
      "subscription_manager_id": "8cea8fa3-c2c1-463a-953c-ae29386ca7b5",
      "satellite_id": "8cea8fa3-c2c1-463a-953c-ae29386ca7b5",
      "convert2rhel_through_foreman": 1,
...
jeremylenz commented 2 weeks ago

The test failures are

NoMethodError: undefined method `convert2rhel_through_foreman' for #<Katello::Host::SubscriptionFacet:0x000055fcfcf4dfe0>

looks like the tests may be using old Katello code?

jeremylenz commented 2 weeks ago

@ShimShtein does the katello pin look good?

jeremylenz commented 1 week ago

@ShimShtein @chris1984 updated to skip tests if multiCV isn't available.