Bug 1313197

Summary: virt-who go to satellite6 check logic although system register to satellite5.7
Product: Red Hat Enterprise Linux 6 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: Radek Novacek <rnovacek>
Status: CLOSED ERRATA QA Contact: Eko <hsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8CC: gxing, lmiksik, ovasik, rbalakri, sgao
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-who-0.16-7.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 23:57:45 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 2016-03-01 07:55:42 UTC
Description of problem:
Register system to satellite5.7, if virt-who run at default mode(not specify VIRTWHO_LIBVIRT=1), virt-who can't send host/guest mapping info to satellite5.7 since "SubscriptionManagerUnregisteredError: Unable to read certificate, system is not registered or you are not root".

Version-Release number of selected component (if applicable):
virt-who-0.16-5.el6.noarch
subscription-manager-1.16.8-3.el6.x86_64
python-rhsm-1.16.6-1.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Register system to satellite5.7
[root@sgi-xe500-01 virt-who.d]# rhnreg_ks --username admin  --password redhat
2. Configure virt-who run at default mode:
VIRTWHO_DEBUG=1
VIRTWHO_SATELLITE5=1
VIRTWHO_SATELLITE_SERVER=10.66.128.78
VIRTWHO_SATELLITE_USERNAME=admin
VIRTWHO_SATELLITE_PASSWORD=redhat
3. Restart virt-who service and check virt-who's log
[root@sgi-xe500-01 virt-who.d]# service virt-who restart && tail -f /var/log/rhsm/rhsm.log
Stopping virt-who: [  OK  ]
Starting virt-who: [  OK  ]
2016-03-01 15:35:40,688 [virtwho.init INFO] MainProcess(2463):MainThread @virtwho.py:main:715 - No configurations found, using libvirt as backend
2016-03-01 15:35:40,689 [virtwho.init INFO] MainProcess(2463):MainThread @virtwho.py:main:722 - Using configuration "env/cmdline" ("libvirt" mode)
2016-03-01 15:35:40,711 [virtwho.main DEBUG] MainProcess(2465):MainThread @virtwho.py:run:229 - Starting infinite loop with 60 seconds interval
2016-03-01 15:35:40,814 [virtwho.env_cmdline DEBUG] Libvirtd-1(2473):MainThread @virt.py:run:358 - Virt backend 'env/cmdline' started
2016-03-01 15:35:40,815 [virtwho.env_cmdline INFO] Libvirtd-1(2473):MainThread @libvirtd.py:_connect:156 - Using libvirt url: ""
2016-03-01 15:35:40,822 [virtwho.env_cmdline DEBUG] Libvirtd-1(2473):MainThread @libvirtd.py:_listDomains:236 - Libvirt domains found: 
2016-03-01 15:35:40,822 [virtwho.env_cmdline DEBUG] Libvirtd-1(2473):MainThread @virt.py:enqueue:351 - Report gathered, putting to queue for sending
2016-03-01 15:35:40,834 [virtwho.main DEBUG] MainProcess(2465):MainThread @subscriptionmanager.py:_connect:121 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-03-01 15:35:40,836 [virtwho.main ERROR] MainProcess(2465):MainThread @virtwho.py:_main:751 - Fatal error:
Traceback (most recent call last):
  File "/usr/share/virt-who/virtwho.py", line 748, in _main
    result = virtWho.run()
  File "/usr/share/virt-who/virtwho.py", line 333, in run
    self.send_current_report()
  File "/usr/share/virt-who/virtwho.py", line 153, in send_current_report
    if self.send(report):
  File "/usr/share/virt-who/virtwho.py", line 195, in send
    self._sendGuestList(report)
  File "/usr/share/virt-who/virtwho.py", line 220, in _sendGuestList
    manager.sendVirtGuests(report, self.options)
  File "/usr/share/virt-who/manager/subscriptionmanager/subscriptionmanager.py", line 139, in sendVirtGuests
    self._connect()
  File "/usr/share/virt-who/manager/subscriptionmanager/subscriptionmanager.py", line 124, in _connect
    "Unable to read certificate, system is not registered or you are not root")
SubscriptionManagerUnregisteredError: Unable to read certificate, system is not registered or you are not root

Actual results:
It will show "system is not registered or you are not root" since virt-who go to satellite6 check logic.

Expected results:
It should show the same info as virt-who specified VIRTWHO_LIBVIRT=1,please see the detail in the "Additional info"

Additional info:
When configure "VIRTWHO_LIBVIRT=1" in /etc/sysconfig/virt-who, it will show info as the following:
2016-03-01 15:23:54,109 [virtwho.main DEBUG] MainProcess(2342):MainThread @virtwho.py:<module>:814 - virt-who terminated
2016-03-01 15:23:54,269 [virtwho.init INFO] MainProcess(2378):MainThread @virtwho.py:parseOptions:630 - Using reporter_id='hp-z220-07.qe.lab.eng.nay.redhat.com'
2016-03-01 15:23:54,271 [virtwho.init INFO] MainProcess(2378):MainThread @virtwho.py:main:722 - Using configuration "env/cmdline" ("libvirt" mode)
2016-03-01 15:23:54,286 [virtwho.main DEBUG] MainProcess(2380):MainThread @virtwho.py:run:229 - Starting infinite loop with 60 seconds interval
2016-03-01 15:23:54,393 [virtwho.env_cmdline DEBUG] Libvirtd-1(2388):MainThread @virt.py:run:358 - Virt backend 'env/cmdline' started
2016-03-01 15:23:54,394 [virtwho.env_cmdline INFO] Libvirtd-1(2388):MainThread @libvirtd.py:_connect:156 - Using libvirt url: ""
2016-03-01 15:23:54,405 [virtwho.env_cmdline DEBUG] Libvirtd-1(2388):MainThread @libvirtd.py:_listDomains:236 - Libvirt domains found: 
2016-03-01 15:23:54,405 [virtwho.env_cmdline DEBUG] Libvirtd-1(2388):MainThread @virt.py:enqueue:351 - Report gathered, putting to queue for sending
2016-03-01 15:23:54,419 [virtwho.main ERROR] MainProcess(2380):MainThread @virtwho.py:send:201 - Unable to send data: virt-who does not support sending local hypervisor data to satellite; use rhn-virtualization-host instead
2016-03-01 15:23:54,419 [virtwho.main DEBUG] MainProcess(2380):MainThread @virtwho.py:send_current_report:166 - Report from "env/cmdline" failed to sent

Comment 1 Radek Novacek 2016-03-10 13:03:36 UTC
There is indeed bug in the code that prevents virt-who from working in satellite 5 mode when configured in /etc/sysconfig/virt-who.

Workaround is to set `sat_server`, `sat_username`, and `sat_password` in the /etc/virt-who.d/* config.

Comment 2 Radek Novacek 2016-03-10 15:18:37 UTC
*** Bug 1313238 has been marked as a duplicate of this bug. ***

Comment 3 Radek Novacek 2016-03-10 18:27:25 UTC
Fixed in virt-who-0.16-7.el6.

Comment 5 Liushihui 2016-03-24 03:50:52 UTC
Verified it on virt-who-0.16-7.el6 since virt-who can send host/guest mapping info to satellite5.7.Therefore, verify it.

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

Verified process:
1. Register system to satellite5.7
[root@sgi-xe500-01 virt-who.d]# rhnreg_ks --username admin  --password redhat
2. Configure virt-who run at default mode:
VIRTWHO_DEBUG=1
VIRTWHO_SATELLITE5=1
VIRTWHO_SATELLITE_SERVER=10.66.128.78
VIRTWHO_SATELLITE_USERNAME=admin
VIRTWHO_SATELLITE_PASSWORD=redhat
3. Restart virt-who service and check virt-who's log
[root@sgi-xe500-01 virt-who.d]# service virt-who restart && tail -f /var/log/rhsm/rhsm.log
Stopping virt-who: [  OK  ]
Starting virt-who: [  OK  ]
2016-03-23 23:37:39,475 [virtwho.env_cmdline DEBUG] Libvirtd-1(7074):MainThread @libvirtd.py:_listDomains:244 - Libvirt domains found: 
2016-03-23 23:37:39,476 [virtwho.env_cmdline DEBUG] Libvirtd-1(7074):MainThread @virt.py:enqueue:351 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-03-23 23:37:39,479 [virtwho.main ERROR] MainProcess(7061):MainThread @virtwho.py:send:203 - Unable to send data: virt-who does not support sending local hypervisor data to satellite; use rhn-virtualization-host instead
2016-03-23 23:37:39,480 [virtwho.main DEBUG] MainProcess(7061):MainThread @virtwho.py:send_report:168 - Report from "env/cmdline" failed to sent
4. Configure multi mode in /etc/virt-who.d/xxx:
[root@sun-x4440-01 ~]# cat /etc/virt-who.d/virtwho 
[test-rhevm1]
type=rhevm
server=https://10.73.3.247:443
username=admin@internal
password=redhat
owner=ACME_Corporation
env=Library
[root@sun-x4440-01 ~]# cat /etc/sysconfig/virt-who  | grep -v ^# | grep -v ^$
VIRTWHO_DEBUG=1
VIRTWHO_SATELLITE5=1
VIRTWHO_SATELLITE_SERVER=10.66.128.78
VIRTWHO_SATELLITE_USERNAME=admin
VIRTWHO_SATELLITE_PASSWORD=redhat
VIRTWHO_HYPERV=1
VIRTWHO_HYPERV_OWNER=ACME_Corporation
VIRTWHO_HYPERV_ENV=Library
VIRTWHO_HYPERV_SERVER=10.73.5.212
VIRTWHO_HYPERV_USERNAME=administrator
VIRTWHO_HYPERV_PASSWORD=Welcome1
5. Restart virt-who can check virt-who's log
[root@sgi-xe500-01 virt-who.d]# service virt-who restart && tail -f /var/log/rhsm/rhsm.log
Stopping virt-who: [  OK  ]
Starting virt-who: [  OK  ]
2016-03-23 23:45:57,685 [virtwho.test-rhevm1 DEBUG] RhevM-1(7509):MainThread @virt.py:enqueue:351 - Report for config "test-rhevm1" gathered, putting to queue for sending
2016-03-23 23:46:01,764 [virtwho.env_cmdline DEBUG] HyperV-2(7511):MainThread @virt.py:enqueue:351 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-03-23 23:46:05,381 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:_connect:73 - Initializing satellite connection to https://10.66.128.78/XMLRPC
2016-03-23 23:46:05,381 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:_connect:79 - Initialized satellite connection
2016-03-23 23:46:05,382 [virtwho.main INFO] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:156 - Sending update in hosts-to-guests mapping: 0 hypervisors and 0 guests found
2016-03-23 23:46:05,383 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:158 - Host-to-guest mapping: {
    "hypervisors": []
}
2016-03-23 23:46:05,383 [virtwho.main INFO] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:176 - Mapping for config "test-rhevm1" updated
2016-03-23 23:46:05,384 [virtwho.main DEBUG] MainProcess(7501):MainThread @virtwho.py:send_report:161 - Report for config "test-rhevm1" sent
2016-03-23 23:46:53,594 [virtwho.env_cmdline DEBUG] HyperV-2(7511):MainThread @hyperv.py:retry_ntlm_negotitate:67 - Using NTLM authentication
2016-03-23 23:46:54,365 [virtwho.env_cmdline DEBUG] HyperV-2(7511):MainThread @hyperv.py:retry_ntlm_authenticate:80 - Sending NTLM authentication data
2016-03-23 23:46:54,763 [virtwho.env_cmdline DEBUG] HyperV-2(7511):MainThread @hyperv.py:retry_ntlm_authenticate:103 - NTLM authentication successful
2016-03-23 23:46:57,814 [virtwho.test-rhevm1 DEBUG] RhevM-1(7509):MainThread @virt.py:enqueue:351 - Report for config "test-rhevm1" gathered, putting to queue for sending
2016-03-23 23:47:00,678 [virtwho.env_cmdline DEBUG] HyperV-2(7511):MainThread @virt.py:enqueue:351 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-03-23 23:47:05,389 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:_connect:73 - Initializing satellite connection to https://10.66.128.78/XMLRPC
2016-03-23 23:47:05,389 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:_connect:79 - Initialized satellite connection
2016-03-23 23:47:05,390 [virtwho.main INFO] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:156 - Sending update in hosts-to-guests mapping: 1 hypervisors and 2 guests found
2016-03-23 23:47:05,392 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:158 - Host-to-guest mapping: {
    "hypervisors": [
        {
            "hypervisorId": {
                "hypervisorId": "564D80F1-61F0-8510-87BF-57F9EC6122D7"
            }, 
            "name": "hyperv_02", 
            "guestIds": [
                {
                    "guestId": "C877953C-A19E-5149-B614-D97873C4CBD2", 
                    "state": 5, 
                    "attributes": {
                        "active": 0, 
                        "hypervisorVersion": "6.3.9600.16404", 
                        "virtWhoType": "hyperv", 
                        "hypervisorType": "hyperv"
                    }
                }, 
                {
                    "guestId": "8329390B-8359-F646-9176-27D738580E81", 
                    "state": 5, 
                    "attributes": {
                        "active": 0, 
                        "hypervisorVersion": "6.3.9600.16404", 
                        "virtWhoType": "hyperv", 
                        "hypervisorType": "hyperv"
                    }
                }
            ], 
            "facts": {
                "cpu.cpu_socket(s)": "4"
            }
        }
    ]
}
2016-03-23 23:47:05,395 [virtwho.main DEBUG] MainProcess(7501):MainThread @satellite.py:hypervisorCheckIn:163 - Loading systemid for 564D80F1-61F0-8510-87BF-57F9EC6122D7

Result:
Virt-who send host/guest mapping info to satellite5.7 when work at multi mode.

Comment 7 errata-xmlrpc 2016-05-10 23:57:45 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