Downstream tracker for: https://projects.theforeman.org/issues/17148 https://projects.theforeman.org/issues/11914 Description: Searching by the "flavor" of the content host is important. Specifically, being able to find all of the hypervisors, all of the guests, guests of a specific hypervisor, whether the host is physical or virtual. the candlepin 'type' shoudl provide the information we need This seems to be happening because of the API rework. Questions: - why the "type" field has not been moved into Hosts API call for hypervisor? - which field is used by Satellite to identify if a host is an hypervisor or not? - which field is used by Satellite to identify if a host is an physical server?
Connecting redmine issue https://projects.theforeman.org/issues/11914 from this bug
upstream issue https://projects.theforeman.org/issues/17148 was delivered by https://bugzilla.redhat.com/show_bug.cgi?id=1246554 in 6.3. This will track the delivery of upstream issue 11914 only.
Adding some more details about this issue: Following API call in Satellite 6.2.15 # curl -X GET -s -k -u admin:redhat https://localhost/api/v2/hosts/4 | python -m json.tool | egrep -w "virt::host_type|is_guest|virt" ~~~ "virt": null, "virt::host_type": "kvm", "virt::is_guest": "true", "virt::uuid": "d39ad2e5-c218-4d4e-a484-036c33a73953" ~~~ Example for physical,virtual,hypervisor on Satellite 6.2.15: ~~~ Physical Server: physical.example.com (physical_host.json) """ virt::host_type : "Not Applicable" virt::is_guest : false virt : null """ VMWare Guest: VMguest.example.com (vmware_guest.json) """ virt::host_type : "vmware" virt::is_guest : true virt : null """ RHEV / KVM Guest: KVMguest.example.com (rhev_guest.json) """ virt::host_type : "rhev, kvm" virt::is_guest : true virt : null """ Hypervisor: virt-who-hypervisor.example.com-3 (hypervisor.json) """ virt::host_type : not present virt::is_guest : not present virt : not present """ ~~~ ##################################################### On Satellite 6.4: # curl -X GET -s -k -u admin:redhat https://localhost/api/v2/hosts/411 | python -m json.tool | egrep -w "virt::host_type|is_guest|virt" Against a VM: ~~~ "virt": null, "virt::host_type": "kvm", "virt::is_guest": "true", "virt::uuid": "8b762480-d097-4470-b1f4-289846c186a5", "name": "virt-who-satotest.gsslab.brq.redhat.com-1" ~~~ Against a hypervisor: ~~~ Hypervisor: virt-who-hypervisor.example.com-1 (hypervisor.json) """ virt::host_type : not present virt::is_guest : not present virt : not present """ ~~~ If we could add "hypervisor" to host_type this might be sufficient to identify the different types.
// found some issues with is_virtual not being set for lots of VMs so modified the script This is as is and was not exhaustively tested, following is how we determine the type: - if certname contains virt-who we identify the system as a hypervisor - if is_guest is true we identify the system as a VM - if host_type is Not Applicable we identify the system as physical Loop trough all hosts of the organization 1 and execute the script: # for host_id in `hammer host list --organization-id 1 | cut -d "|" -f 1 | tail -n +4 | head -n -1`; do bash test.sh $host_id; done contents of test.sh ~~~ #### #!/bin/bash user='admin' password='password' satellite='localhost' host_id=$1 echo "Performing check against $host_id :" is_guest=`curl -X GET -s -k -u $user:$password https://$satellite/api/v2/hosts/$host_id | python -m json.tool | grep -i "is_guest" | cut -d ":" -f4| tr -d ',"'` is_hypervisor=`curl -X GET -s -k -u $user:$password https://$satellite/api/v2/hosts/$host_id | python -m json.tool | grep certname | cut -d ":" -f 2 | tr -d '",' | grep virt-who` is_physical=`curl -X GET -s -k -u $user:$password https://$satellite/api/v2/hosts/$host_id | python -m json.tool | grep host_type | cut -d ":" -f 4 | tr -d "\""` ## debug #echo "is a guest: $is_guest" #echo "is a hypervisor: $is_hypervisor" #echo "host type: $is_physical" ## if [[ "$is_hypervisor" == *"virt-who"* ]]; then echo "This host is a hypervisor" elif [ "$is_physical" = " Not Applicable" ]; then echo "This is a physical machine" elif [ "$is_guest" = " true" ]; then echo "This is a virtual machine" else echo "I don't know, probably the subscription-manager facts for the host have not been uploaded to Satellite" fi #### ~~~
Isn't this partially a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1431232?
The Satellite Team is attempting to provide an accurate backlog of bugzilla requests which we feel will be resolved in the next few releases. We do not believe this bugzilla will meet that criteria, and have plans to close it out in 1 month. This is not a reflection on the validity of the request, but a reflection of the many priorities for the product. If you have any concerns about this, feel free to contact Red Hat Technical Support or your account team. If we do not hear from you, we will close this bug out. Thank you.
*** This bug has been marked as a duplicate of bug 1431232 ***
You can also search hosts by "hypervisor = true/false" and "facts.virt::is_guest = true" or other facts sources (puppet/ansible/subscription-manager)