Bug 1103944 - Need to be able to associate gpg key to a repository by gpg key name
Summary: Need to be able to associate gpg key to a repository by gpg key name
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Adam Price
QA Contact: Sachin Ghai
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On: 1103945
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-03 00:33 UTC by Partha Aji
Modified: 2019-04-01 20:27 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-09 11:02:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 6028 0 None None None 2016-04-22 16:33:41 UTC
Red Hat Product Errata RHSA-2015:1592 0 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 09:04:35 UTC

Description Partha Aji 2014-06-03 00:33:48 UTC
Assuming Redmine issue #6023 is resolved... We need to be able to use a gpg key name when associating a gpg key to a product,
When #6023 is fixed we 'll have 

hammer -v repository create  --url='http://omaciel.fedorapeople.org/fakerepo01/' --product-id='3' --name='foobar345678' --publish-via-http=1  --content-type='yum' --gpg-key-id=1

working but not

hammer -v repository create  --url='http://omaciel.fedorapeople.org/fakerepo01/' --product-id='3' --name='foobar345678' --publish-via-http=1  --content-type='yum' --gpg-key=test --organization-id=1

Comment 1 Partha Aji 2014-06-03 00:33:49 UTC
Created from redmine issue http://projects.theforeman.org/issues/6028

Comment 2 Partha Aji 2014-06-03 00:33:54 UTC
Upstream bug assigned to paji

Comment 4 Mike McCune 2014-06-03 17:12:53 UTC
This is awaiting fixes being worked on here:

http://projects.theforeman.org/issues/5747

Comment 5 sthirugn@redhat.com 2014-06-12 18:01:59 UTC
Test Scenario 1:

# hammer repository create --product-id='94' --name='newrepo' --publish-via-http='true' --url='**valid url**' --gpg-key='testgpgkey' --content-type='yum'
Repository created

# hammer repository list --organization=ACME_Corporation
---|------------------------------------------------------------|-------------
ID | NAME                                                       | CONTENT TYPE
---|------------------------------------------------------------|-------------
11 | newrepo                                                    | yum         
---|------------------------------------------------------------|-------------

# hammer repository info --id=11
ID:                 11
Name:               newrepo
Label:              newrepo
Organization:       ACME_Corporation
Red Hat Repository: no
Content Type:       yum
URL:                ****
Publish Via HTTP:   yes
Published At:       http://host/pulp/repos/ACME_Corporation/Library/custom/product1/newrepo
Product:            
    ID:   94
    Name: product1
GPG Key:            
    ID:   1
    Name: testgpgkey
Sync:               
    Status: Not Synced
Created:            2014/06/12 17:29:52
Updated:            2014/06/12 17:29:55
Content Counts:


Test Scenario 2:
# hammer repository create --product-id='94' --name='newtestrepo' --publish-via-http='true' --url='*valid url' --gpg-key-id=1 --content-type='yum'
Repository created

# hammer repository list --organization=ACME_Corporation
---|------------------------------------------------------------|-------------
ID | NAME                                                       | CONTENT TYPE
---|------------------------------------------------------------|-------------
11 | newrepo                                                    | yum         
12 | newtestrepo                                                | yum         
---|------------------------------------------------------------|-------------

# hammer repository info --id=12
ID:                 12
Name:               newtestrepo
Label:              newtestrepo
Organization:       ACME_Corporation
Red Hat Repository: no
Content Type:       yum
URL:                ****
Publish Via HTTP:   yes
Published At:       http://host/pulp/repos/ACME_Corporation/Library/custom/product1/newtestrepo
Product:            
    ID:   94
    Name: product1
GPG Key:            
    ID:   1
    Name: testgpgkey
Sync:               
    Status: Not Synced
Created:            2014/06/12 17:36:22
Updated:            2014/06/12 17:36:25
Content Counts:


Version Tested:
* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.7-1.el6_5.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.9.7-1.el6_5.noarch
* candlepin-tomcat6-0.9.7-1.el6_5.noarch
* elasticsearch-0.90.10-4.el6sat.noarch
* foreman-1.6.0.16-1.el6sat.noarch
* foreman-compute-1.6.0.16-1.el6sat.noarch
* foreman-gce-1.6.0.16-1.el6sat.noarch
* foreman-libvirt-1.6.0.16-1.el6sat.noarch
* foreman-ovirt-1.6.0.16-1.el6sat.noarch
* foreman-postgresql-1.6.0.16-1.el6sat.noarch
* foreman-proxy-1.6.0.7-1.el6sat.noarch
* foreman-selinux-1.6.0-4.el6sat.noarch
* foreman-vmware-1.6.0.16-1.el6sat.noarch
* katello-1.5.0-25.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.5-1.el6sat.noarch
* katello-installer-0.0.48-1.el6sat.noarch
* openldap-2.4.23-32.el6_4.1.x86_64
* openldap-devel-2.4.23-32.el6_4.1.x86_64
* pulp-katello-0.3-3.el6sat.noarch
* pulp-nodes-common-2.4.0-0.20.beta.el6sat.noarch
* pulp-nodes-parent-2.4.0-0.20.beta.el6sat.noarch
* pulp-puppet-plugins-2.4.0-0.20.beta.el6sat.noarch
* pulp-puppet-tools-2.4.0-0.20.beta.el6sat.noarch
* pulp-rpm-plugins-2.4.0-0.20.beta.el6sat.noarch
* pulp-selinux-2.4.0-0.20.beta.el6sat.noarch
* pulp-server-2.4.0-0.20.beta.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch

Comment 6 Elyézer Rezende 2014-06-27 16:44:57 UTC
# LANG=en_US hammer -v -u admin -p changeme  --output csv organization create --name='1wd68kt3'
Message,Id,Name
Organization created,167,1wd68kt3

# LANG=en_US hammer -v -u admin -p changeme  organization info --id='167'
Id:                     167
Name:                   1wd68kt3
Users:

Smart proxies:
    somehost.com
Subnets:

Compute resources:

Installation media:

Templates:

Domains:

Environments:

Hostgroups:

Parameters:

Created at:             2014/06/27 16:32:12
Updated at:             2014/06/27 16:32:14
Label:                  1wd68kt3
Description:
Red Hat Repository URL: https://cdn.redhat.com

# LANG=en_US hammer -v -u admin -p changeme  --output csv product create --description='CoacLBSeiqNOpNoIcurF' --label='pzWiYtjcUQhSLiPxJtig' --organization-id='167' --name='DKKRSTdvnLJgqLwTeCqL'
Message,Id,Name
Product created,86,DKKRSTdvnLJgqLwTeCqL

# LANG=en_US hammer -v -u admin -p changeme  product info --id='86' --organization-id='167'
ID:           86
Name:         DKKRSTdvnLJgqLwTeCqL
Label:        pzWiYtjcUQhSLiPxJtig
Description:  CoacLBSeiqNOpNoIcurF
Sync State:   not_synced
Sync Plan ID:
GPG:
    GPG Key ID:
    GPG Key:
Organization: 1wd68kt3
Readonly:     false
Deletable:    true
Content:

# LANG=en_US hammer -v -u admin -p changeme  --output csv gpg create --organization-id='167' --name='42ou' --key='/tmp/h6gpxkr'
Message,Id,Name
GPG Key created,56,42ou

# LANG=en_US hammer -v -u admin -p changeme  --output csv gpg info --id='56' --organization-id='167'
ID,Name,Organization,Content
56,42ou,1wd68kt3,9sdajdvql0o5yvqu0lcekhhfs6zqqc9zy

# LANG=en_US hammer -v -u admin -p changeme  --output csv repository create --product-id='86' --name='794327675264689' --publish-via-http='true' --url='http://somehost.org/fakerepo01/' --gpg-key='42ou' --content-type='yum'
Message,Id,Name
Repository created,104,794327675264689

# LANG=en_US hammer -v -u admin -p changeme  repository info --id='104'
ID:                 104
Name:               794327675264689
Label:              794327675264689
Organization:       1wd68kt3
Red Hat Repository: no
Content Type:       yum
URL:                http://somehost.org/fakerepo01/
Publish Via HTTP:   yes
Published At:       http://somehost.com/pulp/repos/1wd68kt3/Library/custom/pzWiYtjcUQhSLiPxJtig/794327675264689
Product:
    ID:   86
    Name: DKKRSTdvnLJgqLwTeCqL
GPG Key:

Sync:
    Status: Not Synced
Created:            2014/06/27 16:33:15
Updated:            2014/06/27 16:33:18
Content Counts:

Comment 7 Elyézer Rezende 2014-06-27 16:48:34 UTC
As demonstrated in the last comment, GPG key is not being associated to a repository again.

Comment 9 Corey Welton 2014-06-27 17:17:15 UTC
Moving this to assigned.

Comment 10 sthirugn@redhat.com 2014-06-27 17:39:31 UTC
Workaround:

Using gpg key name fails but using gpg key id works - See below for the illustration of using gpg key id


# hammer repository create --product-id=10 --name='brandrepo2' --publish-via-http='true' --url='**url**' --gpg-key-id='1' --content-type='yum'
Repository created

# hammer repository list --organization='ACME_Corporation'
---|------------------------------------------------------------|-------------
ID | NAME                                                       | CONTENT TYPE
---|------------------------------------------------------------|-------------
11 | brandrepo2                                                 | yum         
---|------------------------------------------------------------|-------------

# hammer repository info --id=11
ID:                 11
Name:               brandrepo2
Label:              brandrepo2
Organization:       ACME_Corporation
Red Hat Repository: no
Content Type:       yum
URL:                **url**
Publish Via HTTP:   yes
Published At:       http://host/pulp/repos/ACME_Corporation/Library/custom/satellite6/brandrepo2
Product:            
    ID:   10
    Name: satellite6
GPG Key:            
    ID:   1
    Name: key1
Sync:               
    Status: Not Synced
Created:            2014/06/27 17:34:48
Updated:            2014/06/27 17:34:51
Content Counts:

Comment 12 Adam Price 2015-01-26 20:45:05 UTC
appears to be working for me


# hammer repository create --organization adamprice --url "*** valid url ***" --product prod1 --name repo1 --publish-via-http 1 --content-type yum --gpg-key key1
Repository created

# hammer repository info --organization adamprice --name repo1 --product prod1
ID:                 1
Name:               repo1
Label:              repo1
Organization:       adamprice
Red Hat Repository: no
Content Type:       yum
URL:                *** valid url ***
Publish Via HTTP:   yes
Published At:       http://FQDN/pulp/repos/adamprice/Library/custom/prod1/repo1
Product:            
    ID:   9
    Name: prod1
GPG Key:            
    ID:   1
    Name: key1
Sync:               
    Status:
Created:            2015/01/26 20:39:21
Updated:            2015/01/26 20:39:26
Content Counts:     
    Packages:       0
    Package Groups: 0
    Errata:         0

Comment 14 Sachin Ghai 2015-02-13 06:57:31 UTC
Verified with:
Satellite-6.1.0-RHEL-6-20150210.0
Sat6.1.0 beta snap2

Now gpg_key can be associated to repository by gpgkey name.

[root@dhcp201-167 ~]# hammer --username admin --password changeme gpg list --organization-id=3
/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:68: warning: already initialized constant DEFAULT_LABEL_INDENT
---|------
ID | NAME 
---|------
1  | g_key
---|------


[root@dhcp201-167 ~]# hammer --username admin --password changeme product list --organization-id=3

----|------|-------------|--------------|--------------|-----------
ID  | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE
----|------|-------------|--------------|--------------|-----------
114 | p1   |             | testorg      | 0            | not_synced
----|------|-------------|--------------|--------------|-----------


[root@dhcp201-167 ~]# hammer --username admin --password changeme repository create  --url='http://omaciel.fedorapeople.org/fakerepo01/' --product-id='114' --name='r1' --publish-via-http=1  --content-type='yum' --gpg-key=g_key --organization-id=3
Repository created


[root@dhcp201-167 ~]# hammer --username admin --password changeme product list --organization-id=3
----|------|-------------|--------------|--------------|-----------
ID  | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE
----|------|-------------|--------------|--------------|-----------
114 | p1   |             | testorg      | 1            | not_synced
----|------|-------------|--------------|--------------|-----------


[root@dhcp201-167 ~]# hammer --username admin --password changeme repository list --organization-id=3

---|------|---------|--------------|--------------------------------------------
ID | NAME | PRODUCT | CONTENT TYPE | URL                                        
---|------|---------|--------------|--------------------------------------------
8  | r1   | p1      | yum          | http://omaciel.fedorapeople.org/fakerepo01/
---|------|---------|--------------|--------------------------------------------
[root@dhcp201-167 ~]# hammer --username admin --password changeme repository info --id 8

ID:                 8
Name:               r1
Label:              r1
Organization:       testorg
Red Hat Repository: no
Content Type:       yum
URL:                http://omaciel.fedorapeople.org/fakerepo01/
Publish Via HTTP:   yes
Published At:       http://dhcp201-167.englab.pnq.redhat.com/pulp/repos/testorg/Library/custom/p1/r1
Product:            
    ID:   114
    Name: p1
GPG Key:            
    ID:   1
    Name: g_key
Sync:               
    Status:
Created:            2015/02/13 01:23:27
Updated:            2015/02/13 01:23:31
Content Counts:     
    Packages:       0
    Package Groups: 0
    Errata:         0

Comment 15 Elyézer Rezende 2015-04-02 01:31:31 UTC
Automation got this as regression again, see the steps below:

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv organization create --name="M0vU9Y"
Message,Id,Name
Organization created,561,M0vU9Y

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme  organization info --id="561"
Id:                     561
Name:                   M0vU9Y
Users:

Smart proxies:
    sat6.example.com
Subnets:

Compute resources:

Installation media:

Templates:
    Boot disk iPXE - generic host (Bootdisk)
    Boot disk iPXE - host (Bootdisk)
    idm_register ()
    Kickstart default iPXE (iPXE)
    Kickstart default PXELinux (PXELinux)
    kickstart_networking_setup ()
    puppet.conf ()
    PXELinux default local boot (PXELinux)
    PXELinux global default (PXELinux)
    Satellite Kickstart Default (provision)
    Satellite Kickstart Default Finish (finish)
    Satellite Kickstart Default User Data (user_data)
    subscription_manager_registration ()
Domains:

Environments:

Hostgroups:

Parameters:

Created at:             2015/04/02 01:17:02
Updated at:             2015/04/02 01:17:02
Label:                  M0vU9Y
Description:
Red Hat Repository URL: https://cdn.redhat.com


# LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv product create --organization-id="561" --description="cBCnGqcbOruTIlxpfLdt" --name="NijEpmtIwjgGAcPWdohe" --label="NzIWdeiTJceNySAirQBu"
Message,Id,Name
Product created,2469,NijEpmtIwjgGAcPWdohe

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme  product info --id="2469" --organization-id="561"
ID:           2469
Name:         NijEpmtIwjgGAcPWdohe
Label:        NzIWdeiTJceNySAirQBu
Description:  cBCnGqcbOruTIlxpfLdt
Sync State:   not_synced
Sync Plan ID:
GPG:
    GPG Key ID:
    GPG Key:
Organization: M0vU9Y
Readonly:     false
Deletable:
Content:


# LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv gpg create --organization-id="561" --name="8KFXTy9PCs" --key="/tmp/bt7hyehMbE"
Message,Id,Name
GPG Key created,64,8KFXTy9PCs

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv gpg info --id="64" --organization-id="561"
ID,Name,Organization,Content
64,8KFXTy9PCs,M0vU9Y,HseUq9bGAzmJFbaqwhQC04lF6iND9eyoQNeOt9

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme --output=csv repository create --product-id="2469" --name="izupyLoDyChcuBG" --publish-via-http="true" --url="http://inecas.fedorapeople.org/fakerepos/zoo3/" --gpg-key="8KFXTy9PCs" --content-type="yum"
Message,Id,Name
Repository created,373,izupyLoDyChcuBG

# LANG=en_US.UTF-8 hammer -v -u admin -p changeme  repository info --id="373"
ID:                 373
Name:               izupyLoDyChcuBG
Label:              izupyLoDyChcuBG
Organization:       M0vU9Y
Red Hat Repository: no
Content Type:       yum
URL:                http://inecas.fedorapeople.org/fakerepos/zoo3/
Publish Via HTTP:   yes
Published At:       http://sat6.example.com/pulp/repos/M0vU9Y/Library/custom/NzIWdeiTJceNySAirQBu/izupyLoDyChcuBG
Product:
    ID:   2469
    Name: NijEpmtIwjgGAcPWdohe
GPG Key:

Sync:
    Status:
Created:            2015/04/02 01:17:32
Updated:            2015/04/02 01:17:33
Content Counts:
    Packages: 0
    Errata:   0

Comment 17 errata-xmlrpc 2015-08-12 05:09:06 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/RHSA-2015:1592

Comment 18 sthirugn@redhat.com 2015-08-14 20:29:59 UTC
Reopened as per Comment 15

Comment 19 Bryan Kearney 2015-08-25 17:23:51 UTC
Upstream bug component is Hammer

Comment 20 Bryan Kearney 2015-08-25 17:57:06 UTC
Upstream bug component is Content Management

Comment 21 Bryan Kearney 2015-08-25 17:58:39 UTC
Upstream bug component is Hammer

Comment 23 Bryan Kearney 2016-02-26 21:12:33 UTC
Upstream bug assigned to adprice

Comment 24 Adam Price 2016-04-05 21:52:11 UTC
I attempted this on Satellite 6.2 SNAP 6.1 and it appears to be working correctly.

# hammer organization create --name acme
Organization created
# hammer product create --organization acme --name product1
Product created
# vim fake.key
# hammer gpg create --organization acme --name fakekey1 --key fake.key
GPG Key created
# hammer repository create --organization acme --product product1 --name repo1 --publish-via-http true --url http://inecas.fedorapeople.org/fakerepos/zoo3/ --gpg-key fakekey1 --content-type yum
Repository created
# hammer repository info --organization acme --product product1 --name repo1
ID:                 1
Name:               repo1
Label:              repo1
Organization:       acme
Red Hat Repository: no
Content Type:       yum
URL:                http://inecas.fedorapeople.org/fakerepos/zoo3/
Publish Via HTTP:   yes
Published At:       http://sat6.example.com/pulp/repos/acme/Library/custom/product1/repo1
Relative Path:      acme/Library/custom/product1/repo1
Download Policy:    on_demand
Product:            
    ID:   1
    Name: product1
GPG Key:            
    ID:   1
    Name: fakekey1
Sync:               
    Status: Not Synced
Created:            2016/04/05 21:43:44
Updated:            2016/04/05 21:43:46
Content Counts:     
    Packages:       0
    Package Groups: 0
    Errata:         0

Comment 25 Sachin Ghai 2016-04-09 11:02:17 UTC
Verified with sat6.2 beta snap6.2

I can associate gpgkey by name to selected repository

[root@qe-sat6-rhel7 ~]# hammer -u admin -p changeme organization create --name acme
Organization created

[root@qe-sat6-rhel7 ~]#  hammer -u admin -p changeme product create --organization acme --name product1
Product created

[root@qe-sat6-rhel7 ~]#  hammer -u admin -p changeme gpg create --organization acme --name fakekey1 --key fake.key
GPG Key created


[root@qe-sat6-rhel7 ~]# hammer -u admin -p changeme repository create --organization acme --product product1 --name repo1 --publish-via-http true --url http://inecas.fedorapeople.org/fakerepos/zoo3/ --gpg-key fakekey1 --content-type yum
Repository created



[root@qe-sat6-rhel7 ~]#  hammer -u admin -p changeme repository info --organization acme --product product1 --name repo1
ID:                 673
Name:               repo1
Label:              repo1
Organization:       acme
Red Hat Repository: no
Content Type:       yum
URL:                http://inecas.fedorapeople.org/fakerepos/zoo3/
Publish Via HTTP:   yes
Published At:       http://qe-sat6-rhel7.satqe.lab.eng.rdu2.redhat.com/pulp/repos/acme/Library/custom/product1/repo1
Relative Path:      acme/Library/custom/product1/repo1
Download Policy:    immediate
Product:            
    ID:   667
    Name: product1
GPG Key:            
    ID:   82
    Name: fakekey1
Sync:               
    Status: Not Synced
Created:            2016/04/09 10:58:44
Updated:            2016/04/09 10:58:45
Content Counts:     
    Packages:       0
    Package Groups: 0
    Errata:         0


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