Bug 1248425

Summary: Failed to filter host as "AttributeError"
Product: Red Hat Enterprise Linux 7 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: Radek Novacek <rnovacek>
Status: CLOSED ERRATA QA Contact: xingge <gxing>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: gxing, hsun, ldai, ovasik, sgao
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-who-0.14-3.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 11:57:41 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:

Description Liushihui 2015-07-30 09:22:57 UTC
Description of problem:
Virt-who failed to filter host as "AttributeError: 'str' object has no attribute 'hypervisorId'" when communicate with subscription-manager

Version-Release number of selected component (if applicable):
virt-who-0.14-2.el7.noarch
subscription-manager-1.15.6-1.el7.x86_64
python-rhsm-1.15.3-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1.Register system to SAM server
2.Configure virt-who run at esx mode and configure a host which can be filtered.
[root@hp-z220-06 virt-who.d]# cat /etc/virt-who.d/vir 
[test-esx1]
type=esx
server=10.66.79.72
username=Administrator
password=qwer1234P!
owner=ACME_Corporation
env=Library
filter_host_uuids="aee4ff00-8c33-11e2-994a-6c3be51d959a"
3. Restart virt-who service , check the virt-who log
2015-07-30 17:16:40,245 [DEBUG]  @virtwho.py:120 - Using config named 'test-esx1'
2015-07-30 17:16:40,246 [INFO]  @virtwho.py:655 - Using configuration "test-esx1" ("esx" mode)
2015-07-30 17:16:40,246 [DEBUG]  @virtwho.py:203 - Starting infinite loop with 3600 seconds interval
2015-07-30 17:16:40,284 [DEBUG]  @esx.py:55 - Log into ESX
2015-07-30 17:16:40,516 [DEBUG]  @esx.py:58 - Creating ESX event filter
2015-07-30 17:16:40,604 [DEBUG]  @esx.py:142 - Waiting for ESX changes
2015-07-30 17:16:40,606 [ERROR]  @virtwho.py:177 - Error in communication with subscription manager:
Traceback (most recent call last):
  File "/usr/share/virt-who/virtwho.py", line 160, in send
    self._sendGuestAssociation(report)
  File "/usr/share/virt-who/virtwho.py", line 190, in _sendGuestAssociation
    report.association,
  File "/usr/share/virt-who/virt/virt.py", line 171, in association
    if self._config.filter_host_uuids is not None and host.hypervisorId not in self._config.filter_host_uuids:
AttributeError: 'str' object has no attribute 'hypervisorId'

Actual results:
Failed to filter out host as "AttributeError: 'str' object has no attribute 'hypervisorId'" when virt-who communicate with subscription-manager

Expected results:
Virt-who should support filter out host after setting filter_host_uuids/exclude_host_uuids

Additional info:

Comment 1 Radek Novacek 2015-07-30 13:16:10 UTC
Fixed in virt-who-0.14-3.el7.

Comment 3 Liushihui 2015-08-11 06:01:14 UTC
Verified it on virt-who-0.14-3.el7.noarch since virt-who can filter out host after configure "filter_host_uuids". 

Verified version
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
Satellite 6.1.0-20150731.0

Verified process:
1.Register system to SAM server
2.Configure virt-who run at esx mode and configure a host which can't  be filtered.
[root@hp-z220-06 virt-who.d]# cat /etc/virt-who.d/virt
[test-esx1]
type=esx
server=10.66.78.97
username=Administrator
password=qwer1234P!
owner=ACME_Corporation
env=Library
filter_host_uuids="aee4ff00-8c33-11e2-994a-6c3be51d959a"
3. Restart virt-who service, check virt-who's log
2015-08-11 13:51:19,924 [DEBUG]  @virtwho.py:126 - Using config named 'test-esx1'
2015-08-11 13:51:19,925 [INFO]  @virtwho.py:662 - Using configuration "test-esx1" ("esx" mode)
2015-08-11 13:51:19,925 [DEBUG]  @virtwho.py:209 - Starting infinite loop with 3600 seconds interval
2015-08-11 13:51:19,960 [DEBUG]  @esx.py:55 - Log into ESX
2015-08-11 13:51:20,184 [DEBUG]  @esx.py:58 - Creating ESX event filter
2015-08-11 13:51:20,255 [DEBUG]  @esx.py:142 - Waiting for ESX changes
2015-08-11 13:51:20,259 [DEBUG]  @virt.py:173 - Skipping host '86b2bd00-8bad-11e2-87f4-6c3be514699d' because its uuid is not included
2015-08-11 13:51:20,259 [DEBUG]  @subscriptionmanager.py:112 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2015-08-11 13:51:23,269 [DEBUG]  @subscriptionmanager.py:146 - Checking if server has capability 'hypervisor_async'
2015-08-11 13:51:26,594 [DEBUG]  @subscriptionmanager.py:158 - Server does not have 'hypervisors_async' capability
2015-08-11 13:51:26,595 [INFO]  @subscriptionmanager.py:165 - Sending update in hosts-to-guests mapping: {}
4.configure another host which can be filtered.
[root@hp-z220-07 ~]# cat /etc/virt-who.d/virt 
[test-esx1]
type=esx
server=10.66.78.97
username=Administrator
password=qwer1234P!
owner=ACME_Corporation
env=Library
filter_host_uuids="86b2bd00-8bad-11e2-87f4-6c3be514699d"
5. Restart virt-who service, check virt-who's log
2015-08-11 13:52:18,550 [DEBUG]  @virtwho.py:126 - Using config named 'test-esx1'
2015-08-11 13:52:18,551 [INFO]  @virtwho.py:662 - Using configuration "test-esx1" ("esx" mode)
2015-08-11 13:52:18,552 [DEBUG]  @virtwho.py:209 - Starting infinite loop with 3600 seconds interval
2015-08-11 13:52:18,586 [DEBUG]  @esx.py:55 - Log into ESX
2015-08-11 13:52:18,845 [DEBUG]  @esx.py:58 - Creating ESX event filter
2015-08-11 13:52:18,912 [DEBUG]  @esx.py:142 - Waiting for ESX changes
2015-08-11 13:52:18,916 [DEBUG]  @subscriptionmanager.py:112 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2015-08-11 13:52:22,410 [DEBUG]  @subscriptionmanager.py:146 - Checking if server has capability 'hypervisor_async'
2015-08-11 13:52:25,654 [DEBUG]  @subscriptionmanager.py:158 - Server does not have 'hypervisors_async' capability
2015-08-11 13:52:25,654 [INFO]  @subscriptionmanager.py:165 - Sending update in hosts-to-guests mapping: {
    "86b2bd00-8bad-11e2-87f4-6c3be514699d": [
        {
            "guestId": "42390187-0ca7-6139-dadb-549a990f34e3", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "virtWhoType": "esx"
            }
        }, 
        {
            "guestId": "564d1d17-06d9-46c3-beea-fed130d564e7", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "virtWhoType": "esx"
            }
        }, 
        {
            "guestId": "4239d107-b6b3-ec67-3317-678288dafe5a", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "virtWhoType": "esx"
            }
        }
    ]
}

Result: according to the result of step 3 and step 5, virt-who can filter out host after configure "filter_host_uuids". Therefore, verify it

Comment 4 errata-xmlrpc 2015-11-19 11:57:41 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/RHBA-2015-2370.html