Bug 1253614 - virt-who offline function can't support local libvirt mode
virt-who offline function can't support local libvirt mode
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: virt-who (Show other bugs)
7.2
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Radek Novacek
xingge
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-14 05:19 EDT by Eko
Modified: 2016-11-30 19:34 EST (History)
6 users (show)

See Also:
Fixed In Version: virt-who-0.14-4.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-19 06:58:14 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Eko 2015-08-14 05:19:25 EDT
Description of problem:
make virt-who running for local libvirt mode and create the fake data for local host/guest maaping. virt-who can't send the fake date to server even I set is_hypervisor=False.

Version-Release number of selected component (if applicable):
 - RHEL7.2-20150806.1-Server-x86_64(KVM) against stage candlepin
 - virt-who-0.14-3.el7.noarch
 - subscription-manager-1.15.9-2.el7.x86_64
 - python-rhsm-1.15.4-2.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. stop virt-who service

2. set virt-who running for local libvirt
# grep -E -v '(^#|^$)'  /etc/sysconfig/virt-who
VIRTWHO_DEBUG=1
VIRTWHO_INTERVAL=2

3. run virt-who with -p to create the fake data "/root/fake"
# virt-who -p -d > /root/fake
2015-08-14 17:12:06,885 INFO: No configurations found, using libvirt as backend
2015-08-14 17:12:06,885 INFO: Using configuration "env/cmdline" ("libvirt" mode)
2015-08-14 17:12:06,918 INFO: Using libvirt url: ""
2015-08-14 17:12:06,922 DEBUG: Virtual machine found: rhel7.0: 95572a0b-390a-4364-ae96-a48c5134d47d
2015-08-14 17:12:06,923 DEBUG: Virtual machine found: rhel7.0-backup: 5262e779-29c6-4331-a344-c46e78012425
2015-08-14 17:12:06,923 DEBUG: Libvirt domains found: ['95572a0b-390a-4364-ae96-a48c5134d47d', '5262e779-29c6-4331-a344-c46e78012425']
2015-08-14 17:12:06,924 DEBUG: Association for config env/cmdline gathered
2015-08-14 17:12:06,924 DEBUG: Associations found: {
    "hypervisors": [
        {
            "guests": [
                {
                    "guestId": "95572a0b-390a-4364-ae96-a48c5134d47d", 
                    "state": 1, 
                    "attributes": {
                        "active": 1, 
                        "virtWhoType": "libvirt", 
                        "hypervisorType": "QEMU"
                    }
                }, 
                {
                    "guestId": "5262e779-29c6-4331-a344-c46e78012425", 
                    "state": 5, 
                    "attributes": {
                        "active": 0, 
                        "virtWhoType": "libvirt", 
                        "hypervisorType": "QEMU"
                    }
                }
            ]
        }
    ]
}
2015-08-14 17:12:06,925 DEBUG: virt-who shut down started


4. create /etc/virt-who.d/virt.fake for offline mode
# vi /etc/virt-who.d/virt.fake
[fake-virt]
type=fake
file=/root/fake
is_hypervisor=True
owner=7652501
env=7652501

5. restart virt-who service and check rhsm.log 
2015-08-14 17:14:22,232 [DEBUG]  @virtwho.py:126 - Using config named 'fake-virt'
2015-08-14 17:14:22,233 [INFO]  @virtwho.py:662 - Using configuration "fake-virt" ("fake" mode)
2015-08-14 17:14:22,233 [DEBUG]  @virtwho.py:209 - Starting infinite loop with 2 seconds interval
2015-08-14 17:14:22,266 [ERROR]  @virt.py:302 - Virt backend 'fake-virt' fails with error: Fake virt file '/root/fake' is not properly formed: 'uuid'

6. change is_hypervisor=False
# vi /etc/virt-who.d/virt.fake
[fake-virt]
type=fake
file=/root/fake
is_hypervisor=False
owner=7652501
env=7652501

7. restart virt-who service again and check rhsm.log
2015-08-14 17:16:58,113 [DEBUG]  @virtwho.py:126 - Using config named 'fake-virt'
2015-08-14 17:16:58,113 [INFO]  @virtwho.py:662 - Using configuration "fake-virt" ("fake" mode)
2015-08-14 17:16:58,114 [DEBUG]  @virtwho.py:209 - Starting infinite loop with 2 seconds interval
2015-08-14 17:16:58,147 [ERROR]  @virt.py:304 - Virt backend 'fake-virt' fails with exception:
Traceback (most recent call last):
  File "/usr/share/virt-who/virt/virt.py", line 300, in run
    self._run()
  File "/usr/share/virt-who/virt/virt.py", line 328, in _run
    report = self._get_report()
  File "/usr/share/virt-who/virt/virt.py", line 276, in _get_report
    return DomainListReport(self.config, self.listDomains())
  File "/usr/share/virt-who/virt/fakevirt/fakevirt.py", line 53, in listDomains
    return hypervisor['guestIds']
KeyError: 'guestIds'


Actual results:
virt-who offline function can't work for local libvirt mode

Expected results:
If I set is_hypervisor=False for offline mode, virt-who can send the local fake date to server

Additional info:
Comment 2 Radek Novacek 2015-08-18 11:57:34 EDT
Fixed in virt-who-0.14-4.el7.
Comment 4 Liushihui 2015-08-25 03:34:32 EDT
Verified it on virt-who-0.14-4.el7 since virt-who can support local libvirt mode when it run at offline mode. Therefore, verify it.

Verified version
virt-who-0.14-4.el7.noarch
subscription-manager-1.15.9-6.el7.x86_64
python-rhsm-1.15.4-2.el7.x86_64
SAM-1.4.1-RHEL-6-20141113.0

Verified process:
1. Register system to SAM
2. Stop virt-who service.
3. Make virt-who run at off-line mode and monitor local host.
[root@ibm-hs22-01 ~]# virt-who -p -d > /root/fake
2015-08-25 09:23:48,882 INFO: No configurations found, using libvirt as backend
2015-08-25 09:23:48,883 INFO: Using configuration "env/cmdline" ("libvirt" mode)
2015-08-25 09:23:48,933 INFO: Using libvirt url: ""
2015-08-25 09:23:48,939 DEBUG: Virtual machine found: 6.7_Server_x86_64: 26e37471-67da-43f4-a5d6-bafb8afe037d
2015-08-25 09:23:48,942 DEBUG: Virtual machine found: 6.5_Server_x86_64: fe8fbb34-fdf3-4f85-adee-d74f5a88cc82
2015-08-25 09:23:48,943 DEBUG: Virtual machine found: 7.1_Server_x86_64: 391246e5-bf3e-44f7-bc13-34308bc04f93
2015-08-25 09:23:48,943 DEBUG: Libvirt domains found: ['26e37471-67da-43f4-a5d6-bafb8afe037d', 'fe8fbb34-fdf3-4f85-adee-d74f5a88cc82', '391246e5-bf3e-44f7-bc13-34308bc04f93']
2015-08-25 09:23:48,945 DEBUG: Association for config env/cmdline gathered
2015-08-25 09:23:48,946 DEBUG: Associations found: {
    "hypervisors": [
        {
            "guests": [
                {
                    "guestId": "26e37471-67da-43f4-a5d6-bafb8afe037d", 
                    "state": 1, 
                    "attributes": {
                        "active": 1, 
                        "virtWhoType": "libvirt", 
                        "hypervisorType": "QEMU"
                    }
                }, 
                {
                    "guestId": "fe8fbb34-fdf3-4f85-adee-d74f5a88cc82", 
                    "state": 5, 
                    "attributes": {
                        "active": 0, 
                        "virtWhoType": "libvirt", 
                        "hypervisorType": "QEMU"
                    }
                }, 
                {
                    "guestId": "391246e5-bf3e-44f7-bc13-34308bc04f93", 
                    "state": 5, 
                    "attributes": {
                        "active": 0, 
                        "virtWhoType": "libvirt", 
                        "hypervisorType": "QEMU"
                    }
                }
            ]
        }
    ]
}

4. create /etc/virt-who.d/virt.fake for offline mode
# vi /etc/virt-who.d/virt.fake
[fake-virt]
type=fake
file=/root/fake
is_hypervisor=False

5. Check virt-who's log, virt-who can support local libvirt mode when it run at offline mode.
Comment 5 errata-xmlrpc 2015-11-19 06:58:14 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2370.html

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