On 07.02.2013 19:38, Andreas Piesk wrote:
>
> i haven't figured out, why the import uses sha256 and not the checksum_type
> of the repo it is
> importing into. any pointers will be appreciated.
>
OK, found it and fixed my problem with the little attached patch. it adds a new
parameter --hashtype
to the content admin plugin and prints in verbose how many files have been
processed.
regards,
-ap
diff --git a/src/pulp/client/admin/plugins/content.py b/src/pulp/client/admin/plugins/content.py
index 4d9e458..b656ed1 100644
--- a/src/pulp/client/admin/plugins/content.py
+++ b/src/pulp/client/admin/plugins/content.py
@@ -56,6 +56,9 @@ class Upload(ContentAction):
self.parser.add_option("--chunksize", dest="chunk", default=10485760, type=int,
help=_("chunk size to use for uploads; Default:10485760"))
self.parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("verbose output."))
+ self.parser.add_option("--hashtype", dest="hashtype", default="sha256",
+ help=_("hashtype to use when generating hashes for package paths, default:sha256; \
+ for feed repos, this must match the source checksum type from repomd.xml"))
def run(self):
files = self.args
@@ -78,7 +81,9 @@ class Upload(ContentAction):
fids = {}
exit_code = 0
uapi = UploadAPI()
+ files_processed = 0
for f in files:
+ files_processed += 1
try:
if not self.opts.nosig and f.endswith(".rpm") and not utils.is_signed(f):
msg = _("Package [%s] is not signed. Please use --nosig. Skipping " % f)
@@ -97,7 +102,7 @@ class Upload(ContentAction):
print msg
continue
try:
- metadata = utils.processFile(f)
+ metadata = utils.processFile(filename=f, hashtype=self.opts.hashtype)
except utils.FileError, e:
msg = _('Error: %s') % e
log.error(msg)
@@ -121,7 +126,7 @@ class Upload(ContentAction):
(pobj['filename'], pobj['checksum'][pobj['checksum'].keys()[0]])
log.info(msg)
if self.opts.verbose:
- print msg
+ print msg + " [%i/%i]" % (files_processed, len(files))
if metadata['type'] == 'rpm':
pids[os.path.basename(f)] = pobj['id']
else:
@@ -137,7 +142,7 @@ class Upload(ContentAction):
msg = _("Successfully uploaded [%s] to server") % metadata['pkgname']
log.info(msg)
if self.opts.verbose:
- print msg
+ print msg + " [%i/%i]" % (files_processed, len(files))
else:
msg = _("Error: Failed to upload [%s] to server") % metadata['pkgname']
log.error(msg)
diff --git a/src/pulp/client/lib/utils.py b/src/pulp/client/lib/utils.py
index 9183e64..c6769cb 100644
--- a/src/pulp/client/lib/utils.py
+++ b/src/pulp/client/lib/utils.py
@@ -272,7 +272,7 @@ def getFileChecksum(hashtype, filename=None, fd=None, file=None, buffer_size=Non
class FileError(Exception):
pass
-def processFile(filename, relativeDir=None):
+def processFile(filename, hashtype="sha256", relativeDir=None):
# Is this a file?
if not os.access(filename, os.R_OK):
raise FileError("Could not stat the file %s" % filename)
@@ -288,7 +288,7 @@ def processFile(filename, relativeDir=None):
os.path.basename(filename))
else:
hash["relativePath"] = os.path.basename(filename)
- hash['hashtype'] = "sha256" # we enforce sha256 as default checksum
+ hash['hashtype'] = hashtype
hash['checksum'] = getFileChecksum(hash['hashtype'], filename=filename)
hash['pkgname'] = os.path.basename(filename)
# Read the header
_______________________________________________
Pulp-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/pulp-list