insights/client/connection.py
def upload_archive(self, data_collected, content_type, duration):
        """
        Do an HTTPS Upload of the archive
        """
        if self.config.legacy_upload:
            return self._legacy_upload_archive(data_collected, duration)
        file_name = os.path.basename(data_collected)
        upload_url = self.upload_url
        c_facts = {}

        try:
            c_facts = get_canonical_facts()
        except Exception as e:
            logger.debug('Error getting canonical facts: %s', e)
        if self.config.display_name:
            # add display_name to canonical facts
            c_facts['display_name'] = self.config.display_name
        if self.config.branch_info:
            c_facts["satellite_id"] = self.config.branch_info["remote_leaf"]
        c_facts = json.dumps(c_facts)
        logger.debug('Canonical facts collected:\n%s', c_facts)

        files = {
            'file': (file_name, open(data_collected, 'rb'), content_type),
            'metadata': c_facts
        }
        logger.debug("Uploading %s to %s", data_collected, upload_url)

        net_logger.info("POST %s", upload_url)
        upload = self.session.post(upload_url, files=files, headers={})

        logger.debug("Upload status: %s %s %s",
                     upload.status_code, upload.reason, upload.text)
        logger.debug('Request ID: %s', upload.headers.get('x-rh-insights-request-id', None))
        if upload.status_code in (200, 202):
            # 202 from platform, no json response
            logger.debug(upload.text)
            # upload = registration on platform
            write_registered_file()
        else:
            logger.debug(
                "Upload archive failed with status code %s",
                upload.status_code)
            return upload
        logger.debug("Upload duration: %s", upload.elapsed)
        return upload

        Do an HTTPS Upload of the archive
        
Do an HTTPS Upload of the archive
Do an HTTPS Upload of the archive
def upload_archive(self, data_collected, content_type, duration):
        if self.config.legacy_upload:
            return self._legacy_upload_archive(data_collected, duration)
        file_name = os.path.basename(data_collected)
        upload_url = self.upload_url
        c_facts = {}
        try:
            c_facts = get_canonical_facts()
        except Exception as e:
            logger.debug('Error getting canonical facts: %s', e)
        if self.config.display_name:
            c_facts['display_name'] = self.config.display_name
        if self.config.branch_info:
            c_facts["satellite_id"] = self.config.branch_info["remote_leaf"]
        c_facts = json.dumps(c_facts)
        logger.debug('Canonical facts collected:\n%s', c_facts)
        files = {
            'file': (file_name, open(data_collected, 'rb'), content_type),
            'metadata': c_facts
        }
        logger.debug("Uploading %s to %s", data_collected, upload_url)
        net_logger.info("POST %s", upload_url)
        upload = self.session.post(upload_url, files=files, headers={})
        logger.debug("Upload status: %s %s %s",
                     upload.status_code, upload.reason, upload.text)
        logger.debug('Request ID: %s', upload.headers.get('x-rh-insights-request-id', None))
        if upload.status_code in (200, 202):
            logger.debug(upload.text)
            write_registered_file()
        else:
            logger.debug(
                "Upload archive failed with status code %s",
                upload.status_code)
            return upload
        logger.debug("Upload duration: %s", upload.elapsed)
        return upload
def upload_archive ( self , data_collected , content_type , duration ) : if self . config . legacy_upload : return self . _legacy_upload_archive ( data_collected , duration ) file_name = os . path . basename ( data_collected ) upload_url = self . upload_url c_facts = { } try : c_facts = get_canonical_facts ( ) except Exception as e : logger . debug ( 'Error getting canonical facts: %s' , e ) if self . config . display_name : c_facts [ 'display_name' ] = self . config . display_name if self . config . branch_info : c_facts [ "satellite_id" ] = self . config . branch_info [ "remote_leaf" ] c_facts = json . dumps ( c_facts ) logger . debug ( 'Canonical facts collected:\n%s' , c_facts ) files = { 'file' : ( file_name , open ( data_collected , 'rb' ) , content_type ) , 'metadata' : c_facts } logger . debug ( "Uploading %s to %s" , data_collected , upload_url ) net_logger . info ( "POST %s" , upload_url ) upload = self . session . post ( upload_url , files = files , headers = { } ) logger . debug ( "Upload status: %s %s %s" , upload . status_code , upload . reason , upload . text ) logger . debug ( 'Request ID: %s' , upload . headers . get ( 'x-rh-insights-request-id' , None ) ) if upload . status_code in ( 200 , 202 ) : logger . debug ( upload . text ) write_registered_file ( ) else : logger . debug ( "Upload archive failed with status code %s" , upload . status_code ) return upload logger . debug ( "Upload duration: %s" , upload . elapsed ) return upload
Do an HTTPS Upload of the archive
Do an HTTPS Upload of the archive
"""
        Do an HTTPS Upload of the archive
        """ # add display_name to canonical facts # 202 from platform, no json response # upload = registration on platform
self
data_collected
content_type
duration