RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1359653 - Can't filter host when set two hosts in "filter_host_uuids" with same quotes
Summary: Can't filter host when set two hosts in "filter_host_uuids" with same quotes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: virt-who
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Radek Novacek
QA Contact: Eko
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-25 08:51 UTC by Liushihui
Modified: 2016-12-01 00:36 UTC (History)
3 users (show)

Fixed In Version: virt-who-0.17-7.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 05:10:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2387 0 normal SHIPPED_LIVE virt-who bug fix and enhancement update 2016-11-03 13:53:39 UTC

Description Liushihui 2016-07-25 08:51:17 UTC
Description of problem:
When two hosts in "filter_host_uuids" with same quotes('' or "") in /etc/virt-who.d/XXX, if one host is not exist, virt-who can't filter the other legal one.
if one host is set to null, virt-who will show error info and stop automatically.

Version-Release number of selected component (if applicable):
virt-who-0.17-6.el7.noarch
subscription-manager-1.17.9-1.el7.x86_64
python-rhsm-1.17.5-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Register system to satellite6.2
2. Set "filter_host_uuids" with same quotes '' or "",564D80F1-61F0-8510-87BF-57F9EC6122D7 is legal, "test" is illegal.
# cat /etc/virt-who.d/virt
[hyperv]
type=hyperv
server=10.73.5.212
username=administrator
password=Welcome1
owner=7970632
env=7970632
filter_host_uuids='564D80F1-61F0-8510-87BF-57F9EC6122D7','test'
or 
# cat /etc/virt-who.d/virt
[hyperv]
type=hyperv
server=10.73.5.212
username=administrator
password=Welcome1
owner=7970632
env=7970632
filter_host_uuids="564D80F1-61F0-8510-87BF-57F9EC6122D7","test"
3. Restart virt-who and check virt-who's log
4. Set "filter_host_uuids" with same quotes '' or "",564D80F1-61F0-8510-87BF-57F9EC6122D7 is legal, the other host is null.
[hyperv]
type=hyperv
server=10.73.5.212
username=administrator
password=Welcome1
owner=7970632
env=7970632
filter_host_uuids="564D80F1-61F0-8510-87BF-57F9EC6122D7",""
5. Restart virt-who and check virt-who's log

Actual results:
After step 3: Virt-who can't filter the legal host "564D80F1-61F0-8510-87BF-57F9EC6122D7", it will show null host.
"2016-07-25 04:38:56,550 [virtwho.main INFO] MainProcess(14047):MainThread @subscriptionmanager.py:hypervisorCheckIn:194 - Sending update in hosts-to-guests mapping for config "hyperv": 0 hypervisors and 0 guests found
2016-07-25 04:38:56,550 [virtwho.main DEBUG] MainProcess(14047):MainThread @subscriptionmanager.py:hypervisorCheckIn:195 - Host-to-guest mapping: {}
" 

After step5, it will show error info and virt-who will stop automatically
2016-07-25 04:43:10,874 [virtwho.main ERROR] MainProcess(14113):MainThread @__main__.py:main:16 - Fatal error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/virtwho/__main__.py", line 8, in main
    res = virtwho.main.main()
  File "/usr/lib/python2.7/site-packages/virtwho/main.py", line 178, in main
    return _main(executor)
  File "/usr/lib/python2.7/site-packages/virtwho/main.py", line 186, in _main
    result = executor.run()
  File "/usr/lib/python2.7/site-packages/virtwho/executor.py", line 249, in run
    if self.last_reports_hash.get(report.config.name, None) == report.hash:
  File "/usr/lib/python2.7/site-packages/virtwho/virt/virt.py", line 245, in hash
    return hashlib.sha256(json.dumps(self.serializedAssociation, sort_keys=True)).hexdigest()
  File "/usr/lib/python2.7/site-packages/virtwho/virt/virt.py", line 240, in serializedAssociation
    'hypervisors': sorted([h.toDict() for h in self.association['hypervisors']], key=itemgetter('hypervisorId'))
  File "/usr/lib/python2.7/site-packages/virtwho/virt/virt.py", line 231, in association
    if self._config.filter_hosts is not None and host.hypervisorId not in self._config.filter_hosts:
  File "/usr/lib/python2.7/site-packages/virtwho/config.py", line 123, in __getattr__
    return parse_list(value)
  File "/usr/lib/python2.7/site-packages/virtwho/config.py", line 75, in parse_list
    raise ValueError("Unterminated %s sign" % {"'": "single quote", '"': "double quote"}.get(read_to, read_to))
ValueError: Unterminated single quote sign

Expected results:
Virt-who should filter host correctly no matter with the same quotes or different quotes. it also shouldn't show error info but show correct host when filter a null host.

Additional info:
When two hosts with different quotes, virt-who can work normally.

Comment 1 Radek Novacek 2016-07-26 14:41:13 UTC
This issue is now addressed upstream.

https://github.com/virt-who/virt-who/commit/4054161b2bc259539ea72eeee7c15dda369654fe

Comment 3 Liushihui 2016-08-02 03:43:25 UTC
Verified it on virt-who-0.17-7.el7.noarch since virt-who can handle filter_host_uuids, excluded_host_uuids, filter_hosts,exclude_hosts with same quotes. Therefore, verify it.

Verified version:
virt-who-0.17-7.el7.noarch
subscription-manager-1.17.9-1.el7.x86_64
python-rhsm-1.17.5-1.el7.x86_64

Verified process:
1. Register system to satellite6.2
2. Set "filter_host_uuids" with same quotes '' or "",564D80F1-61F0-8510-87BF-57F9EC6122D7 is legal, "test" is illegal.
# cat /etc/virt-who.d/virt
[hyperv]
type=hyperv
server=10.73.5.212
username=administrator
password=Welcome1
owner=7970632
env=7970632
filter_host_uuids='564D80F1-61F0-8510-87BF-57F9EC6122D7','test'
or 
filter_host_uuids="564D80F1-61F0-8510-87BF-57F9EC6122D7","test"

3. Restart virt-who and check virt-who's log
2016-08-01 23:33:48,522 [virtwho.main DEBUG] MainProcess(108554):MainThread @subscriptionmanager.py:hypervisorCheckIn:195 - Host-to-guest mapping: {
    "564D80F1-61F0-8510-87BF-57F9EC6122D7": [
        {
            "guestId": "C877953C-A19E-5149-B614-D97873C4CBD2", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "virtWhoType": "hyperv"
            }
        }, 
        {
            "guestId": "8329390B-8359-F646-9176-27D738580E81", 
            "state": 1, 
            "attributes": {
                "active": 1, 
                "virtWhoType": "hyperv"
            }
        }, 
        {
            "guestId": "EB2C30F2-A847-3749-9828-20EBFB664490", 
            "state": 5, 
            "attributes": {
                "active": 0, 
                "virtWhoType": "hyperv"
            }
        }
    ]
}
2016-08-01 23:33:49,383 [virtwho.main DEBUG] MainProcess(108554):MainThread @executor.py:send_report:101 - Report for config "hyperv" sent

Result:
Virt-who should filter host correctly no matter with the same quotes or different quotes

Note:
When set as the following conditions, virt-who also can work normally.
filter_host_uuids="",""
exclude_host_uuids="",""
exclude_host_uuids='',''
exclude_hosts="test",""
exclude_host_uuids= "564D80F1-61F0-8510-87BF-57F9EC6122D7", "test"

Comment 5 errata-xmlrpc 2016-11-04 05:10:10 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-2016-2387.html


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