Bug 1130637

Summary: rhn-migrate-classic-to-rhsm fails on RHEL6 Client with "TypeError: isfile() takes exactly 1 argument (2 given)"
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: bkearney, jesusr, redakkan, tlavigne
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 07:48:25 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:    
Bug Blocks: 1014343    

Description John Sefler 2014-08-15 18:12:46 UTC
Description of problem:
This only seems to fail on RHEL6 variant Client (both i386 and x86_64)


Version-Release number of selected component (if applicable):
[root@ibm-x3550m3-07 ~]# rpm -qa | grep subscription
subscription-manager-migration-1.12.12-1.el6.x86_64
subscription-manager-1.12.12-1.el6.x86_64
subscription-manager-migration-data-2.0.10-1.el6.noarch
[root@ibm-x3550m3-07 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Client release 6.6 Beta (Santiago)


How reproducible:


Steps to Reproduce:
[root@ibm-x3550m3-07 ~]# rhnreg_ks -v --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=redhatqa --force --norhnsd --nohardware --nopackages --novirtinfo 
[root@ibm-x3550m3-07 ~]# rhn-channel --list
rhel-x86_64-client-6
[root@ibm-x3550m3-07 ~]# rhn-migrate-classic-to-rhsm --serverurl=subscription.rhn.stage.redhat.com
Red Hat username: qa
Red Hat password: 
Subscription Service username: qa
Subscription Service password: 

Retrieving existing RHN Classic subscription information...

+-----------------------------------------------------+
System is currently subscribed to these RHN Classic Channels:
+-----------------------------------------------------+
rhel-x86_64-client-6

+-----------------------------------------------------+
Installing product certificates for these RHN Classic channels:
+-----------------------------------------------------+
rhel-x86_64-client-6

Product certificates installed successfully to /etc/pki/product.
isfile() takes exactly 1 argument (2 given)
[root@ibm-x3550m3-07 ~]# echo $?
255



Actual results:
above

Expected results:
successful migration 


Additional info:
[root@ibm-x3550m3-07 ~]# tail -f /var/log/rhsm/rhsm.log 
2014-08-15 20:05:42,946 [DEBUG] rhn-migrate-classic-to-rhsm @profile.py:97 - Loading current RPM profile.
2014-08-15 20:05:43,034 [INFO] rhn-migrate-classic-to-rhsm @connection.py:648 - Using basic authentication as: qa
2014-08-15 20:05:43,034 [INFO] rhn-migrate-classic-to-rhsm @connection.py:670 - Connection Built: host: subscription.rhn.stage.redhat.com, port: 443, handler: /subscription
2014-08-15 20:05:43,034 [DEBUG] rhn-migrate-classic-to-rhsm @identity.py:131 - Loading consumer info from identity certificates.
2014-08-15 20:05:43,035 [ERROR] rhn-migrate-classic-to-rhsm @identity.py:143 - [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/identity.py", line 135, in reload
    self.consumer = self._get_consumer_identity()
  File "/usr/share/rhsm/subscription_manager/identity.py", line 151, in _get_consumer_identity
    return ConsumerIdentity.read()
  File "/usr/share/rhsm/subscription_manager/identity.py", line 48, in read
    f = open(cls.keypath())
IOError: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
2014-08-15 20:05:43,036 [INFO] rhn-migrate-classic-to-rhsm @identity.py:144 - Error reading consumer identity cert
2014-08-15 20:05:43,037 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: redhat-uep.pem, candlepin-stage.pem
2014-08-15 20:05:43,038 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:446 - Making request: GET /subscription/users/qa%40redhat.com/owners
2014-08-15 20:05:45,767 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:469 - Response: status=200, requestUuid=9e4d983a-2b39-4efd-949c-0823fc16b6ed
2014-08-15 20:05:45,770 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: redhat-uep.pem, candlepin-stage.pem
2014-08-15 20:05:45,770 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:446 - Making request: GET /subscription/users/qa%40redhat.com/owners
2014-08-15 20:05:49,778 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:469 - Response: status=200, requestUuid=c356397f-0899-4b7b-ae07-b264506814f5
2014-08-15 20:05:49,780 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: redhat-uep.pem, candlepin-stage.pem
2014-08-15 20:05:49,780 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:446 - Making request: GET /subscription/
2014-08-15 20:05:51,569 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:469 - Response: status=200, requestUuid=076520a2-cf35-4813-a350-7d9dfa41587f
2014-08-15 20:05:51,572 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:686 - Server supports the following resources:
2014-08-15 20:05:51,572 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:687 - {'': '/', 'guestids': '/consumers/{consumer_uuid}/guestids', 'cdn': '/cdn', 'content_overrides': '/consumers/{consumer_uuid}/content_overrides', 'hypervisors': '/hypervisors', 'serials': '/serials', 'deleted_consumers': '/deleted_consumers', 'consumers': '/consumers', 'migrations': '/migrations', 'content': '/content', 'entitlements': '/entitlements', 'statistics/generate': '/statistics/generate', 'status': '/status', 'jobs': '/jobs', 'users': '/users', 'subscriptions': '/subscriptions', 'rules': '/rules', 'distributor_versions': '/distributor_versions', 'consumertypes': '/consumertypes', 'pools': '/pools', 'atom': '/atom', 'owners': '/owners', 'roles': '/roles', 'admin': '/admin', 'events': '/events', 'products': '/products', 'activation_keys': '/activation_keys', 'crl': '/crl'}
2014-08-15 20:05:57,023 [INFO] rhn-migrate-classic-to-rhsm @migrate.py:458 - Using mapping file /usr/share/rhsm/product/RHEL-6/channel-cert-mapping.txt
2014-08-15 20:05:57,031 [INFO] rhn-migrate-classic-to-rhsm @migrate.py:479 - mapping found for: rhel-x86_64-client-6 = Client-Client-x86_64-71f61609ac32-68.pem
2014-08-15 20:05:57,031 [INFO] rhn-migrate-classic-to-rhsm @migrate.py:513 - certs to be installed: {'68': {'Client-Client-x86_64-71f61609ac32-68.pem': ['rhel-x86_64-client-6']}}
2014-08-15 20:05:57,031 [INFO] rhn-migrate-classic-to-rhsm @migrate.py:530 - copying /usr/share/rhsm/product/RHEL-6/Client-Client-x86_64-71f61609ac32-68.pem to /etc/pki/product/68.pem 
2014-08-15 20:05:57,033 [ERROR] rhn-migrate-classic-to-rhsm @managercli.py:154 - Exception caught in rhm-migrate-classic-to-rhsm
2014-08-15 20:05:57,033 [ERROR] rhn-migrate-classic-to-rhsm @managercli.py:155 - isfile() takes exactly 1 argument (2 given)
Traceback (most recent call last):
  File "/usr/sbin/rhn-migrate-classic-to-rhsm", line 78, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/sbin/rhn-migrate-classic-to-rhsm", line 69, in main
    return migrate.MigrationEngine().main()
  File "/usr/share/rhsm/subscription_manager/migrate/migrate.py", line 780, in main
    self.clean_up(subscribed_channels)
  File "/usr/share/rhsm/subscription_manager/migrate/migrate.py", line 549, in clean_up
    os.path.isfile(os.path.join(product_dir.path), "71.pem"):
TypeError: isfile() takes exactly 1 argument (2 given)

Comment 1 Alex Wood 2014-08-15 18:28:14 UTC
This issue is in

  File "/usr/share/rhsm/subscription_manager/migrate/migrate.py", line 549, in clean_up
    os.path.isfile(os.path.join(product_dir.path), "71.pem")

The issue is a misplaced parenthesis.  The code should be

    os.path.isfile(os.path.join(product_dir.path, "71.pem"))

Comment 4 Rehana 2014-08-26 08:01:37 UTC
Retested on  RHEL6 variant Client x86_64

Below is the test steps followed on x86_64 machine

tested on :

[root@test ~]# rpm -qa | grep subscription
subscription-manager-gui-1.12.13-1.el6.x86_64
subscription-manager-firstboot-1.12.13-1.el6.x86_64
subscription-manager-migration-1.12.13-1.el6.x86_64
subscription-manager-migration-data-2.0.12-1.el6.noarch
subscription-manager-debuginfo-1.12.13-1.el6.x86_64
subscription-manager-1.12.13-1.el6.x86_64


1) rhel6.6 client beta 
# cat /etc/redhat-release 
Red Hat Enterprise Linux Client release 6.6 Beta (Santiago)

2)rhn_register

[root@test ~]# rhnreg_ks -v --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=redhatqa --force --norhnsd --nohardware --nopackages --novirtinfo

3)[root@test ~]#  rhn-channel --list
rhel-x86_64-client-6

4)root@test ~]# rhn-migrate-classic-to-rhsm --serverurl=subscription.rhn.stage.redhat.com
Red Hat username: qa
Red Hat password: 
Subscription Service username: qa
Subscription Service password: 

Retrieving existing RHN Classic subscription information...

+-----------------------------------------------------+
System is currently subscribed to these RHN Classic Channels:
+-----------------------------------------------------+
rhel-x86_64-client-6

+-----------------------------------------------------+
Installing product certificates for these RHN Classic channels:
+-----------------------------------------------------+
rhel-x86_64-client-6

Product certificates installed successfully to /etc/pki/product.

Preparing to unregister system from RHN Classic...
System successfully unregistered from RHN Classic.

Attempting to register system to Red Hat Subscription Management...
The system has been registered with ID: 283a92f2-3e18-40f0-a128-7d774ea210a1 
System 'test' successfully registered to Red Hat Subscription Management.

Attempting to auto-attach to appropriate subscriptions...
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Desktop
Status:       Subscribed


Please visit https://access.redhat.com/management/consumers/283a92f2-3e18-40f0-a128-7d774ea210a1 to view the details, and to make changes if necessary.

[root@test ~]# echo $?
0

Successfully migrated from RHN to RHSM

Marking this bug to "Verified"

Comment 5 errata-xmlrpc 2014-10-14 07:48:25 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.

http://rhn.redhat.com/errata/RHBA-2014-1384.html