Bug 1133515 - [RFE] Hammer repository upload-content doesn't support globs
Summary: [RFE] Hammer repository upload-content doesn't support globs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer - Content
Version: 6.0.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: Unspecified
Assignee: David Davis
QA Contact: Adam Ruzicka
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-25 10:57 UTC by Pavel Studeník
Modified: 2019-09-25 20:33 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 12:28:04 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 16521 0 Normal Closed CLI: Support globs when uploading files to repositories 2020-08-17 14:45:10 UTC
Red Hat Product Errata RHSA-2018:0336 0 normal SHIPPED_LIVE Important: Satellite 6.3 security, bug fix, and enhancement update 2018-02-21 22:43:42 UTC

Description Pavel Studeník 2014-08-25 10:57:49 UTC
Description of problem:
I created own product with a repository and I tried to upload packages to this repository. If I upload only one package, then it works good. Following command:

>> ls packages/test-regular-0-0.1-*

packages/test-regular-0-0.1-1.x86_64.rpm

>> hammer --server $HOST --username=$USER --password=$PASS  repository upload-content --path packages/test-regular-0-0.1-*  --product test-katelloagent-po25srp2014_12_30_19_5755 --organization-label Default_Organization --name test-katelloagent-po25srp2014_12_30_19_5755

Successfully uploaded file 'test-regular-0-0.1-1.x86_64.rpm'.


But if I chose more then one packages (two or more), I got irrelevant message:

>> ls packages/test-regular-0-0.*
packages/test-regular-0-0.1-1.x86_64.rpm  packages/test-regular-0-0.2-2.x86_64.rpm

>> hammer --server $HOST --username=$USER --password=$PASS  repository upload-content --path packages/test-regular-0-0.*  --product test-katelloagent-po25srp2014_12_30_19_5755 --organization-label Default_Organization --name test-katelloagent-po25srp2014_12_30_19_5755

Could not upload the content:
  Error: too many arguments
  
  See: 'hammer repository upload-content --help'

Expression (for --path) "packages/test-regular-0-0.*" doesn't work correct when contains more than 1 file.

Version-Release number of selected component (if applicable):
rubygem-hammer_cli_foreman-0.1.1-15.el6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3-3.el6sat.noarch
rubygem-hammer_cli-0.1.1-12.el6sat.noarch
rubygem-hammer_cli_katello-0.0.4-14.el6sat.noarch


How reproducible:
always

Steps to Reproduce:
1. create product and new custom repository
2. upload 1 package by hammer - works
3. upload more then 1 package - doesn't work

Actual results:
I can't upload more then 1 packages

Expected results:
I can.

Comment 1 RHEL Program Management 2014-08-25 11:03:12 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 4 Paul Wayper 2015-05-26 06:36:52 UTC
Ideally, as with most other commands that deal with files, this command should take all file or path arguments that remain after command line processing and put them in the files to list.  So it should be possible to do:

hammer repository upload-content --name unix_engineering --organization NOMURA --product Unix_Engineering nmr-sunjdk1601964-1.6.0_19_64-1.x86_64.rpm nmr-sunjdk1601764-1.6.0_17_64-1.x86_64.rpm nmr-netbackup-7.1-redhat-1.0-0.x86_64.rpm nmr-sunjdk16019-1.6.0_19-1.i386.rpm nmr-sunjdk16017-1.6.0_17-1.i386.rpm nmr-autosys-linux-4.5-2.i386.rpm

as one command and have hammer import all the listed RPMs.

Hope this helps,

Paul

Comment 5 David Davis 2016-03-11 13:21:07 UTC
Currently, hammer upload-content only supports a filename or a directory. The latter can be used to upload multiple packages (as Dave Sullivan indicates).

What you're asking for is for hammer to support glob patterns or lists of files. It's doable but it's more of an RFE than a bug.

Comment 6 David Davis 2016-03-17 20:19:03 UTC
Moving to 6.3. Workaround is to use a directory or to pipe it to hammer:

for i in packages/test-regular-0-0.1-*; do hammer upload-content --id 5 --path $i; done

Comment 9 Bryan Kearney 2016-08-04 20:16:14 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 10 David Davis 2016-09-12 15:26:15 UTC
I'm adding glob support. To list files you can just do the following:

hammer repository upload-content --name unix_engineering --organization NOMURA --product Unix_Engineering --path {nmr-sunjdk1601964-1.6.0_19_64-1.x86_64.rpm,nmr-sunjdk1601764-1.6.0_17_64-1.x86_64.rpm}


Or also if this is being scripted you can issue a separate hammer command for each file.

Comment 11 David Davis 2016-09-12 16:08:34 UTC
Pavel/Paul,

If you'd still like a way to list all the files without using a glob, I'd recommend that we open a new RFE and request that an option be added (e.g. '--files') to the command. Let me know your thoughts.

Comment 12 Bryan Kearney 2016-09-12 18:03:37 UTC
Upstream bug component is Hammer - Content

Comment 13 David Davis 2016-09-15 20:24:45 UTC
Just a note on testing this. You must escape the glob with single or double quotes otherwise the shell will automatically expand the glob which won't work. I looked into supporting expanded globs but there's a technical limitation in clamp which hammer-cli uses.

Comment 14 Paul Wayper 2016-09-15 22:28:25 UTC
I don't see why just collecting all the files on the command line and adding them in one go is a problem.  Is it?

Processing globs inside a script, when you've got a perfectly good shell to expand them exactly as the user expects, is a waste of time and leads to mismatches in glob semantics.  I think it would be better to just take a list of files.

Hope this helps,

Paul

Comment 15 Bryan Kearney 2016-09-16 14:03:57 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16521 has been resolved.

Comment 16 Adam Ruzicka 2017-08-23 12:34:24 UTC
Verified.
Version Tested: Satellite-6.3 Snap 12

Package versions:
satellite-6.3.0-16.0.beta.el7sat.noarch
katello-3.4.4-2.el7sat.noarch
tfm-rubygem-hammer_cli_katello-0.10.0-1.el7sat.noarch

Created a product and a repository, uploaded some files into the repository using globs.

# h repository upload-content --name Dotfiles --product Stuff --path '.{zsh,bash}rc' --organization-id 1
Successfully uploaded file '.zshrc'.
Successfully uploaded file '.bashrc'.

# h repository upload-content --name Dotfiles --product Stuff --path 'thing-*' --organization-id 1
Successfully uploaded file 'thing-1'.
Successfully uploaded file 'thing-2'.
Successfully uploaded file 'thing-3'.
Successfully uploaded file 'thing-4'.
Successfully uploaded file 'thing-5'.
Successfully uploaded file 'thing-6'.
Successfully uploaded file 'thing-7'.
Successfully uploaded file 'thing-8'.
Successfully uploaded file 'thing-9'.
Successfully uploaded file 'thing-10'.
Successfully uploaded file 'thing-11'.
Successfully uploaded file 'thing-12'.
Successfully uploaded file 'thing-13'.
Successfully uploaded file 'thing-14'.
Successfully uploaded file 'thing-15'.

h repository upload-content --name Dotfiles --product Stuff --path 'thing-[1-3]' --organization-id 1
Successfully uploaded file 'thing-1'.
Successfully uploaded file 'thing-2'.
Successfully uploaded file 'thing-3'.

Comment 19 errata-xmlrpc 2018-02-21 12:28:04 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-2018:0336


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