예제 #1
0
    def handler(self, req):
        ret = basePackageUpload.BasePackageUpload.handler(self, req)
        if ret != apache.OK:
            return ret

        a_pkg = rhnPackageUpload.save_uploaded_package(req,
                                                       (self.package_name, None, self.package_version,
                                                        self.package_release, self.package_arch),
                                                       str(self.org_id),
                                                       self.packaging,
                                                       self.file_checksum_type, self.file_checksum)

        self.rel_package_path = rhnPackageUpload.relative_path_from_header(
            a_pkg.header, org_id=self.org_id,
            checksum_type=a_pkg.checksum_type, checksum=a_pkg.checksum)
        self.package_path = os.path.join(CFG.MOUNT_POINT,
                                         self.rel_package_path)

        package_dict, diff_level = rhnPackageUpload.push_package(a_pkg,
                                                                 force=self.force,
                                                                 relative_path=self.rel_package_path, org_id=self.org_id)

        if diff_level:
            return self._send_package_diff(req, diff_level, package_dict)

        # Everything went fine
        rhnSQL.commit()
        reply = "All OK"
        req.headers_out['Content-Length'] = str(len(reply))
        req.send_http_header()
        req.write(reply)
        log_debug(2, "Returning with OK")

        return apache.OK
예제 #2
0
    def _uploadPackage(self, channels, org_id, force, info):
        """ Write the bits to a temporary file """
        packageBits = info['package']

        package_stream = tempfile.TemporaryFile()
        package_stream.write(packageBits)
        package_stream.seek(0, 0)
        del packageBits

        header, payload_stream, header_start, header_end = \
            rhnPackageUpload.load_package(package_stream)

        checksum_type = header.checksum_type()
        checksum = getFileChecksum(header.checksum_type(), file=payload_stream)

        relative_path = rhnPackageUpload.relative_path_from_header(
            header, org_id=org_id,checksum=checksum, checksum_type=checksum_type)

        package_dict, diff_level = rhnPackageUpload.push_package(
            header, payload_stream, checksum_type, checksum, org_id=org_id, force=force,
            header_start=header_start, header_end=header_end,
            relative_path=relative_path)

        if diff_level:
            return package_dict, diff_level

        return 0
예제 #3
0
 def upload_package(self, channel):
     rel_package_path = rhnPackageUpload.relative_path_from_header(
         self.a_pkg.header, channel["org_id"], self.a_pkg.checksum_type, self.a_pkg.checksum
     )
     package_dict, diff_level = rhnPackageUpload.push_package(
         self.a_pkg, force=False, relative_path=rel_package_path, org_id=channel["org_id"]
     )
예제 #4
0
 def upload_package(self, channel):
     rel_package_path = rhnPackageUpload.relative_path_from_header(
         self.a_pkg.header, channel['org_id'], self.a_pkg.checksum_type,
         self.a_pkg.checksum)
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=channel['org_id'])
예제 #5
0
 def upload_package(self, channel):
     rel_package_path = rhnPackageUpload.relative_path_from_header(
         self.a_pkg.header, channel['org_id'],
         self.a_pkg.checksum_type, self.a_pkg.checksum)
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=channel['org_id'])
예제 #6
0
 def upload_package(self, channel, metadata_only=False):
     rel_package_path = rhnPackageUpload.relative_path_from_header(
         self.a_pkg.header, channel['org_id'],
         self.a_pkg.checksum_type, self.a_pkg.checksum) if not metadata_only else None
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=channel['org_id'])
예제 #7
0
 def upload_package(self, channel, metadata_only=False):
     rel_package_path = rhnPackageUpload.relative_path_from_header(
         self.a_pkg.header, channel['org_id'], self.a_pkg.checksum_type,
         self.a_pkg.checksum) if not metadata_only else None
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=channel['org_id'])
예제 #8
0
 def upload_package(self, org_id, metadata_only=False):
     if not metadata_only:
         rel_package_path = rhnPackageUpload.relative_path_from_header(
             self.a_pkg.header, org_id, self.a_pkg.checksum_type, self.a_pkg.checksum)
     else:
         rel_package_path = None
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=org_id)
     return rel_package_path
예제 #9
0
 def upload_package(self, org_id, metadata_only=False):
     if not metadata_only:
         rel_package_path = rhnPackageUpload.relative_path_from_header(
             self.a_pkg.header, org_id, self.a_pkg.checksum_type, self.a_pkg.checksum)
     else:
         rel_package_path = None
     _unused = rhnPackageUpload.push_package(self.a_pkg,
                                             force=False,
                                             relative_path=rel_package_path,
                                             org_id=org_id)
     return rel_package_path
예제 #10
0
    def upload_package(self, package, path):
        temp_file = open(path, 'rb')
        header, payload_stream, header_start, header_end = \
                rhnPackageUpload.load_package(temp_file)
        package.checksum_type = header.checksum_type()
        package.checksum = getFileChecksum(package.checksum_type, file=temp_file)

        rel_package_path = rhnPackageUpload.relative_path_from_header(
                header, self.channel['org_id'],
                package.checksum_type, package.checksum)
        package_dict, diff_level = rhnPackageUpload.push_package(header,
                payload_stream, package.checksum_type, package.checksum,
                force=False,
                header_start=header_start, header_end=header_end,
                relative_path=rel_package_path,
                org_id=self.channel['org_id'])
        temp_file.close()
예제 #11
0
    def handler(self, req):
        ret = basePackageUpload.BasePackageUpload.handler(self, req)
        if ret != apache.OK:
            return ret

        temp_stream = rhnPackageUpload.write_temp_file(req, 16384, self.packaging)

        header, payload_stream, header_start, header_end = \
            rhnPackageUpload.load_package(temp_stream)

        # Sanity check - removed, the package path can no longer be determined 
        # without the header
        checksum_type = header.checksum_type()
        checksum = getFileChecksum(checksum_type, file=payload_stream)
        self.rel_package_path = rhnPackageUpload.relative_path_from_header(
            header, org_id=self.org_id, checksum_type=checksum_type, checksum=checksum)
        self.package_path = os.path.join(CFG.MOUNT_POINT,
            self.rel_package_path)
        # Verify the checksum of the bytes we downloaded against the checksum
        # presented by rhnpush in the HTTP headers
        if not (checksum_type == self.file_checksum_type
                 and checksum == self.file_checksum):
            log_debug(1, "Mismatching checksums: expected",
                         self.file_checksum_type, self.file_checksum,
                        "; got:", checksum_type, checksum)
            raise rhnFault(104, "Mismatching information")
        
        package_dict, diff_level = rhnPackageUpload.push_package(header,
            payload_stream, checksum_type, checksum, force=self.force,
            header_start=header_start, header_end=header_end,
            relative_path=self.rel_package_path, org_id=self.org_id)

        if diff_level:
            return self._send_package_diff(req, diff_level, package_dict)

        # Everything went fine
        rhnSQL.commit()
        reply = "All OK"
        req.headers_out['Content-Length'] = str(len(reply))
        req.send_http_header()
        req.write(reply)
        log_debug(2, "Returning with OK")
        
        return apache.OK