Bug 1374072

Summary: hammer csv can't import activation keys with multiple guest vdc subscriptions
Product: Red Hat Satellite Reporter: jcallaha
Component: Hammer - ContentAssignee: Tom McKay <tomckay>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: akofink, bbuckingham, dhlavacd, ehelms, mhulan, tomckay, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_csv-2.2.1.1-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1405487 (view as bug list) Environment:
Last Closed: 2017-01-26 10:42:26 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: 1405487    
Attachments:
Description Flags
import debug none

Description jcallaha 2016-09-07 21:09:31 UTC
Description of problem:
When attempting to re-import an activation key that has multiple guest vdc subscriptions attached, you are presented with the following error:
Error: Too many subscriptions match 'Red Hat Enterprise Linux for Virtual Datacenters, Premium'

Version-Release number of selected component (if applicable):
Satellite 6.2.2

How reproducible:
Always

Steps to Reproduce:
1. Setup virt-who with at least one hypervisor
2. Add the guest subscriptions provided by each of the hypervisors.
3. Export the activation key(s) using hammer csv
4. re-import the activation key(s) using hammer csv

Actual results:
Error message above is shown and unable to progress further.

Expected results:
The tool is able to correctly handle the multiple vdc guest subscriptions.

Comment 3 Andrew Kofink 2016-10-20 19:11:25 UTC
Created redmine issue http://projects.theforeman.org/issues/17052 from this bug

Comment 4 Bryan Kearney 2016-10-20 20:09:39 UTC
Upstream bug component is Uncategorized

Comment 5 Bryan Kearney 2016-12-13 21:07:43 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17052 has been resolved.

Comment 6 Bryan Kearney 2016-12-16 19:07:26 UTC
Upstream bug component is Hammer

Comment 7 Bryan Kearney 2016-12-16 19:07:30 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17052 has been resolved.

Comment 8 Bryan Kearney 2016-12-16 19:08:56 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17052 has been resolved.

Comment 9 Bryan Kearney 2016-12-16 19:15:11 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/17052 has been resolved.

Comment 10 jcallaha 2017-01-15 18:50:44 UTC
Failed QA in Satellite 6.2.7 Snap 1

The activation key still fails to import. Looking at the csv file, there doesn't seem to be any data distinguishing one vdc guest sub from another. Will attach debug output as well.

-bash-4.2# hammer -u admin -p changeme csv activation-keys --export --file akeys.csv --organization "Default Organization"
-bash-4.2# cat akeys.csv 
Name,Organization,Description,Limit,Environment,Content View,Host Collections,Auto-Attach,Service Level,Release Version,Subscriptions
rhel7 tools,Default Organization,,,,rhel7 tools,"",Yes,,,""
multi vdc,Default Organization,,,,rhel7 tools,"",Yes,,,"""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"",""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"",""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"""
-bash-4.2# hammer -u admin -p changeme csv activation-keys --file akeys.csv --organization "Default Organization"
Error: No matching subscriptions
multi vdc,Default Organization,,,,rhel7 tools,"",Yes,,,"""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"",""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"",""1|RH00001|Red Hat Enterprise Linux for Virtual Datacenters, Premium|11045754|477931"""

Comment 11 jcallaha 2017-01-15 18:52:16 UTC
Created attachment 1240999 [details]
import debug

Comment 12 Satellite Program 2017-01-16 09:07:52 UTC
Upstream bug assigned to tomckay

Comment 13 Tom McKay 2017-01-16 13:20:24 UTC
Use the --itemized-subscriptions when exporting/importing activation-keys with VDC subscriptions in them. Without that flag you are correct in that there is not full info to recreate.

Comment 15 jcallaha 2017-01-16 16:07:54 UTC
Verified in Satellite 6.2.7 Snap 1

I first exported the current activation keys, two of which had vdc guest subscriptions.

-bash-4.2# hammer -u admin -p changeme csv activation-keys --export --file akeys.csv --organization "Default Organization" --itemized-subscriptions
-bash-4.2# 
-bash-4.2# cat akeys.csv 
Name,Organization,Description,Limit,Environment,Content View,Host Collections,Auto-Attach,Service Level,Release Version,Subscription Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription Contract,Subscription Account,Subscription Start,Subscription End,Subscription Guest
tom multi vdc,Default Organization,,,,Default Organization View,"",Yes,,,"Red Hat Enterprise Linux for Virtual Datacenters, Premium",Red Hat Guest,1,RH00001,11045754,477931,2016-08-04T04:00:00+00:00,2022-01-01T04:59:59+00:00,virt-who-ironforge.satellite.lab.eng.rdu2.redhat.com-1
tom multi vdc,Default Organization,,,,Default Organization View,"",Yes,,,"Red Hat Enterprise Linux for Virtual Datacenters, Premium",Red Hat Guest,1,RH00001,11045754,477931,2016-08-04T04:00:00+00:00,2022-01-01T04:59:59+00:00,virt-who-inorbit.hq.gsslab.rdu.redhat.com-1
tom multi vdc,Default Organization,,,,Default Organization View,"",Yes,,,"Red Hat Enterprise Linux for Virtual Datacenters, Premium",Red Hat Guest,1,RH00001,11045754,477931,2016-08-04T04:00:00+00:00,2022-01-01T04:59:59+00:00,virt-who-bulgaria.hq.gsslab.rdu.redhat.com-1
rhel7 tools,Default Organization,,,,rhel7 tools,"",Yes,,,"Red Hat Enterprise Linux for Virtual Datacenters, Premium",Red Hat Guest,1,RH00001,11045754,477931,2016-08-04T04:00:00+00:00,2022-01-01T04:59:59+00:00,virt-who-nightwing.hq.gsslab.rdu.redhat.com-1
no vdc,Default Organization,,,,rhel7 tools,"",Yes,,,627,Custom,1,1484498805923,,,2017-01-15T16:46:45+00:00,2047-01-08T16:46:45+00:00,
7capsule,Default Organization,,,,rhel7 capsule,"",Yes,,,Red Hat Satellite Employee Subscription,Red Hat,1,SER0232US,10538625,477931,2014-09-19T04:00:00+00:00,2022-01-01T04:59:59+00:00,
7capsule,Default Organization,,,,rhel7 capsule,"",Yes,,,627,Custom,1,1484498805923,,,2017-01-15T16:46:45+00:00,2047-01-08T16:46:45+00:00,

I then removed a vdc guest sub from the "tom multi vdc" activation key and re-imported.

-bash-4.2# hammer -u admin -p changeme csv activation-keys --file akeys.csv --organization "Default Organization" --itemized-subscriptions

The re-import successfully restored the missing subscription.

Comment 17 errata-xmlrpc 2017-01-26 10:42:26 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://access.redhat.com/errata/RHBA-2017:0197