Bug 1259038

Summary: virt-who fake backend not working with virt-who.noarch-0.14-1.el6_6sat.noarch
Product: Red Hat Enterprise Linux 6 Reporter: Leo Thomas <lthomas>
Component: virt-whoAssignee: Radek Novacek <rnovacek>
Status: CLOSED ERRATA QA Contact: gaoshang <sgao>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0CC: bkearney, ovasik, pmutha, rbalakri, shihliu
Target Milestone: pre-dev-freeze   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-who-0.16-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 23:56:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1258765    
Bug Blocks: 1272873    

Description Leo Thomas 2015-09-01 20:02:42 UTC
Description of problem:

The virt-who fake backend fails to work with virt-who.noarch-0.14-1.el6_6sat.noarch 


Version-Release number of selected component (if applicable):

virt-who.noarch-0.14-1.el6_6sat.noarch 


How reproducible:

always

Steps to Reproduce:

1. Install virt-who.noarch-0.14-1.el6_6sat.noarch on the server.

Collect host/guest mapping to create fake virt-who file using following command :-

# virt-who --esx --esx-owner=Default_Organization --esx-env=Library --esx-server=lab-ex5.gsslab.pnq.redhat.com --esx-username=root --esx-password=RedHat1! -p -d > /root/fake

Configure virt-who as following :-

cat /etc/virt-who.d/virt 

[fake-virt]
type=fake
file=/root/fake
is_hypervisor=True
owner=Defualt_Organization
env=Library 

cat /etc/sysconfig/virt-who

VIRTWHO_BACKGROUND=1
VIRTWHO_DEBUG=1

Restart virt-who service 

Actual results:

tailf /var/log/rhsm/rhsm.log

2015-09-02 00:47:30,800 [DEBUG]  @virtwho.py:152 - Starting infinite loop with 3600 seconds interval
2015-09-02 00:47:31,093 [ERROR]  @virtwho.py:123 - Error in communication with subscription manager:
Traceback (most recent call last):
  File "/usr/share/virt-who/virtwho.py", line 107, in send
    self._sendGuestAssociation(report)
  File "/usr/share/virt-who/virtwho.py", line 134, in _sendGuestAssociation
    result = manager.hypervisorCheckIn(report.config, report.association, report.config.type)
  File "/usr/share/virt-who/manager/subscriptionmanager/subscriptionmanager.py", line 145, in hypervisorCheckIn
    serialized_mapping[host] = [guest.toDict() for guest in guests]
AttributeError: 'dict' object has no attribute 'toDict'

Expected results:

virt-who should send the host/guest mapping to Satellite and should see the following message on the rhsm.log file

[INFO]  @virtwho.py:147 - virt-who host/guest association update successful

Additional info:

virt-who-0.12-10.el6.noarch works perfectly with the same configuration file. 

tailf /var/log/rhsm/rhsm.log

[--snip--]
0ace-f22f-b9febf779b7a', 'attributes': {'active': 1, 'virtWhoType': 'esx'}, 'state': 1}, {'guestId': '564d6eb5-85f9-9172-7bd3-d214c915fdc0', 'attributes': {'active': 1, 'virtWhoType': 'esx'}, 'state': 1}]}
2015-09-02 00:52:37,048 [DEBUG]  @subscriptionmanager.py:76 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2015-09-02 00:52:38,497 [INFO]  @virtwho.py:147 - virt-who host/guest association update successful

Comment 2 Radek Novacek 2015-09-29 11:56:10 UTC
This issue has been addressed upstream and will be part of rebased virt-who package.

Comment 3 Radek Novacek 2015-12-17 12:30:59 UTC
Fixed by rebase to virt-who-0.16-1.el6.

Comment 5 Liushihui 2016-02-24 08:14:33 UTC
Verified it on virt-who-0.16-4.el6.noarch since virt-who can send host/guest mapping to server when run at fake mode. Therefore, verified it.

Verified version:
virt-who-0.16-4.el6.noarch
subscription-manager-1.16.8-2.el6.x86_64
python-rhsm-1.16.6-1.el6.x86_64

Verified process:
1 Register system to satellite6
2 Collect host/guest mapping to create fake virt-who file using following command:
[root@sgi-xe500-01 ~]# virt-who --esx --esx-owner=Default_Organization --esx-env=Library --esx-server=10.73.2.95 --esx-username=root --esx-password=Welcome1! -p -d > /root/fake
[root@sgi-xe500-01 ~]# cat /root/fake
{"hypervisors": [{"uuid": "7a384d56-085c-0e32-c7ad-f7181c3f6ddf", "guests": []}, {"uuid": "77ea4d56-2176-2518-74f6-d350749401dd", "guests": []}, {"uuid": "c74a4d56-677e-dd13-828f-617c5cdf0329", "guests": []}, {"uuid": "60554d56-20cb-f25e-7ab9-33e7e330dc15", "guests": []}, {"uuid": "3e504d56-3982-037b-f3e6-669289892fa1", "guests": [{"guestId": "564db653-006a-906b-d2e3-43e033df954a", "state": 5, "attributes": {"active": 0, "hypervisorVersion": "6.0.0", "virtWhoType": "esx", "hypervisorType": "VMware ESXi"}}]}]}
3. Configure virt-who run at fake mode as the following:
[root@sgi-xe500-01 ~]# cat /etc/virt-who.d/virt 
[fake-virt]
type=fake
file=/root/fake
is_hypervisor=True
owner=Defualt_Organization
env=Library
[root@sgi-xe500-01 ~]# cat /etc/sysconfig/virt-who  | grep -v ^# | grep -v ^$
VIRTWHO_DEBUG=1
VIRTWHO_INTERVAL=2
4. Check virt-who log in /var/log/rhsm/rhsm.log
2016-02-24 03:05:23,895 [virtwho.init DEBUG] MainProcess(31357):MainThread @virtwho.py:__init__:125 - Using config named 'fake-virt'
2016-02-24 03:05:23,895 [virtwho.init INFO] MainProcess(31357):MainThread @virtwho.py:main:722 - Using configuration "fake-virt" ("fake" mode)
2016-02-24 03:05:23,917 [virtwho.main DEBUG] MainProcess(31359):MainThread @virtwho.py:run:229 - Starting infinite loop with 60 seconds interval
2016-02-24 03:05:24,059 [virtwho.fake-virt DEBUG] FakeVirt-1(31367):MainThread @virt.py:run:358 - Virt backend 'fake-virt' started
2016-02-24 03:05:24,062 [virtwho.fake-virt DEBUG] FakeVirt-1(31367):MainThread @virt.py:enqueue:351 - Report gathered, putting to queue for sending
2016-02-24 03:05:24,078 [virtwho.main DEBUG] MainProcess(31359):MainThread @subscriptionmanager.py:_connect:121 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-02-24 03:05:24,454 [virtwho.main DEBUG] MainProcess(31359):MainThread @subscriptionmanager.py:hypervisorCheckIn:162 - Checking if server has capability 'hypervisor_async'
2016-02-24 03:05:25,315 [virtwho.main DEBUG] MainProcess(31359):MainThread @subscriptionmanager.py:hypervisorCheckIn:174 - Server does not have 'hypervisors_async' capability
2016-02-24 03:05:25,315 [virtwho.main INFO] MainProcess(31359):MainThread @subscriptionmanager.py:hypervisorCheckIn:185 - Sending update in hosts-to-guests mapping for config "fake-virt": 5 hypervisors and 1 guests found
2016-02-24 03:05:25,315 [virtwho.main DEBUG] MainProcess(31359):MainThread @subscriptionmanager.py:hypervisorCheckIn:186 - Host-to-guest mapping: {
    "7a384d56-085c-0e32-c7ad-f7181c3f6ddf": [], 
    "3e504d56-3982-037b-f3e6-669289892fa1": [
        {
            "guestId": "564db653-006a-906b-d2e3-43e033df954a", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "hypervisorVersion": "6.0.0", 
                "virtWhoType": "esx", 
                "hypervisorType": "VMware ESXi"
            }
        }
    ], 
    "77ea4d56-2176-2518-74f6-d350749401dd": [], 
    "c74a4d56-677e-dd13-828f-617c5cdf0329": [], 
    "60554d56-20cb-f25e-7ab9-33e7e330dc15": []
}

Result: virt-who can send host/guest mapping info to satellite

Comment 7 errata-xmlrpc 2016-05-10 23:56:23 UTC
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/RHEA-2016-0859.html