Bug 1220493

Summary: rhn-migrate-classic-to-rhsm is failing when specifying a --destination-url
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Alex Wood <awood>
Status: CLOSED NOTABUG QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.7CC: bkearney, jsefler, tlavigne, wpoteat
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: 2015-05-14 20:57:51 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: 1125249    

Description John Sefler 2015-05-11 16:31:51 UTC
Description of problem:
A --destination-url is used to specify an rhsm server hostname:port/prefix on the command line.  It should be used to override the [server] hostname port and prefix configurations in rhsm.conf.  In the current rhel6.7 version of subscription-manager-migration, an exception is being thrown because the rhsm.conf file configurations are being used.  This is a regression from the prior rhel6.6 version of subscription-manager-migration.

Version-Release number of selected component (if applicable):
[root@jsefler-os6 ~]# rpm -q subscription-manager-migration
subscription-manager-migration-1.14.6-1.el6.x86_64


How reproducible:
always


Steps to Reproduce:
[root@jsefler-os6 ~]# rhnreg_ks --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=REDACTED --profilename=rhsm-automation.jsefler-os6 --force --norhnsd --nohardware --nopackages --novirtinfo
[root@jsefler-os6 ~]# rhn-channel --list
rhel-x86_64-server-6
[root@jsefler-os6 ~]# subscription-manager config --server.hostname=bad-hostname.com --server.port=000 --server.prefix=/bad-prefix
[root@jsefler-os6 ~]# rhn-migrate-classic-to-rhsm --destination-url=subscription.rhn.stage.redhat.com
Legacy username: qa
Legacy password: 
Destination username: stage_auto_testuser
Destination password: 
Unable to connect to certificate server: Server error attempting a GET to /bad-prefix/status returned status 404.  See /var/log/rhsm/rhsm.log for more details.
[root@jsefler-os6 ~]# 


Actual results:
above

Expected results:
successful migration to the destination rhsm server

Additional info:

[root@jsefler-os6 ~]# tail -f /var/log/rhsm/rhsm.log

2015-05-11 12:28:50,146 [INFO] rhn-migrate-classic-to-rhsm:6223 @connection.py:727 - Connection built: host=subscription.rhn.stage.redhat.com port=443 handler=/bad-prefix auth=basic username=stage_auto_testuser
2015-05-11 12:28:50,146 [DEBUG] rhn-migrate-classic-to-rhsm:6223 @identity.py:131 - Loading consumer info from identity certificates.
2015-05-11 12:28:50,147 [DEBUG] rhn-migrate-classic-to-rhsm:6223 @identity.py:143 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
2015-05-11 12:28:50,152 [DEBUG] rhn-migrate-classic-to-rhsm:6223 @connection.py:446 - Loaded CA certificates from /etc/rhsm/ca/: candlepin-stage.pem, jsefler-f14-7candlepin.pem, jsefler-os-candlepin.pem, jsefler-f14-candlepin.pem, jsefler-os6candlepin.pem, redhat-uep.pem
2015-05-11 12:28:50,152 [DEBUG] rhn-migrate-classic-to-rhsm:6223 @connection.py:494 - Making request: GET /bad-prefix/status
2015-05-11 12:28:50,373 [DEBUG] rhn-migrate-classic-to-rhsm:6223 @connection.py:521 - Response: status=404
2015-05-11 12:28:50,374 [ERROR] rhn-migrate-classic-to-rhsm:6223 @connection.py:550 - Response: 404
2015-05-11 12:28:50,375 [ERROR] rhn-migrate-classic-to-rhsm:6223 @connection.py:551 - JSON parsing error: No JSON object could be decoded
2015-05-11 12:28:50,375 [ERROR] rhn-migrate-classic-to-rhsm:6223 @migrate.py:263 - Server error attempting a GET to /bad-prefix/status returned status 404
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/migrate/migrate.py", line 258, in check_ok_to_proceed
    self.cp.getStatus()
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 1194, in getStatus
    return self.conn.request_get(method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 602, in request_get
    return self._request("GET", method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 530, in _request
    self.validateResponse(result, request_type, handler)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 578, in validateResponse
    handler=handler)
RemoteServerException: Server error attempting a GET to /bad-prefix/status returned status 404

Comment 3 Alex Wood 2015-05-14 19:47:31 UTC
The destination URL needs to be like so:

 --destination-url=subscription.rhn.stage.redhat.com:443/subscription

The format requirements have not changed, so I do not believe this is a regression.  Can you please test again and close this if it is not a bug?

Comment 4 John Sefler 2015-05-14 20:57:51 UTC
My apologies, I destructively configured a bad hostname, bad port, and bad prefix.  Then I neglected to include a good port and good prefix within the --destination-url.  Of course the steps in comment 0 failed.

 
Retesting....

[root@jsefler-os6 ~]# subscription-manager config --server.hostname=bad-hostname.com --server.port=000 --server.prefix=/bad-prefix
[root@jsefler-os6 ~]# rhn-migrate-classic-to-rhsm --destination-url=subscription.rhn.stage.redhat.com:443/subscription
Legacy username: qa
Legacy password: 
Destination username: stage_auto_testuser
Destination password: 

Retrieving existing legacy subscription information...

+-----------------------------------------------------+
System is currently subscribed to these legacy channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

+-----------------------------------------------------+
Installing product certificates for these legacy channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

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

Preparing to unregister system from legacy server...
System successfully unregistered from legacy server.

Attempting to register system to destination server...
The system has been registered with ID: 82be1bc0-a06c-4b6f-92d3-710aa9cb6e2c 

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

System 'jsefler-os6' successfully registered.

[root@jsefler-os6 ~]# 

VERIFIED: --destination-url should be of the format https://hostname:port/prefix
VERIFIED (but not shown):  --destination-url can exclude ":port" or "/prefix" when they are already configured properly in /etc/rhsm/rhsm.conf