Red Hat Bugzilla – Bug 1133515
[RFE] Hammer repository upload-content doesn't support globs
Last modified: 2018-02-21 07:28:04 EST
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.
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.
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
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.
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
Moving 6.2 bugs out to sat-backlog.
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.
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.
Upstream bug component is Hammer - Content
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.
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
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16521 has been resolved.
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'.
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