Bug 1635861 - [RFE] As a user, I should be able to identify hosts if they are a hypervisor, guest, physical, virtual
Summary: [RFE] As a user, I should be able to identify hosts if they are a hypervisor,...
Keywords:
Status: CLOSED DUPLICATE of bug 1431232
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hosts - Content
Version: Unspecified
Hardware: All
OS: All
medium
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Stephen Wadeley
URL:
Whiteboard:
Depends On:
Blocks: 1650573
TreeView+ depends on / blocked
 
Reported: 2018-10-03 19:16 UTC by Daniele
Modified: 2023-09-07 19:25 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-05 18:46:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 11914 0 High New As a user, I should be able to search hosts by whether they are a hypervisor, guest, physical, virtual 2020-03-26 08:40:26 UTC

Description Daniele 2018-10-03 19:16:26 UTC
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?

Comment 3 Satellite Program 2018-10-18 16:57:02 UTC
Connecting redmine issue https://projects.theforeman.org/issues/11914 from this bug

Comment 4 Bryan Kearney 2018-10-18 16:58:19 UTC
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.

Comment 5 Bryan Kearney 2018-10-18 16:58:38 UTC
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.

Comment 6 Kenny Tordeurs 2018-11-01 09:04:34 UTC
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.

Comment 7 Kenny Tordeurs 2018-11-01 13:42:57 UTC
// 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

####

~~~

Comment 8 Evgeni Golov 2018-11-21 15:54:54 UTC
Isn't this partially a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1431232?

Comment 9 Bryan Kearney 2019-11-04 14:34:08 UTC
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.

Comment 10 Bryan Kearney 2019-11-05 18:46:24 UTC

*** This bug has been marked as a duplicate of bug 1431232 ***

Comment 11 Marek Hulan 2019-11-06 13:41:48 UTC
You can also search hosts by "hypervisor = true/false" and "facts.virt::is_guest = true" or other facts sources (puppet/ansible/subscription-manager)


Note You need to log in before you can comment on or make changes to this bug.