Exemplo n.º 1
0
    def get_download_directory(self):
        """
        Return directory name for image download directory:

        download_directory: /tmp

        if no configuration exists the download dir name from
        the Defaults class is returned

        :rtype: string
        """
        download_directory = self._get_attribute(
            attribute='download_directory'
        )
        return download_directory if download_directory else \
            Defaults.get_download_dir()
Exemplo n.º 2
0
    def __init__(self,
                 job_id,
                 job_file,
                 download_url,
                 image_name,
                 last_service,
                 log_callback,
                 conditions=None,
                 arch='x86_64',
                 download_directory=Defaults.get_download_dir(),
                 notification_email=None,
                 profile=None,
                 conditions_wait_time=900,
                 disallow_licenses=None,
                 disallow_packages=None):
        self.arch = arch
        self.job_id = job_id
        self.job_file = job_file
        self.download_directory = os.path.join(download_directory, job_id)
        self.download_url = download_url
        self.image_name = image_name
        self.last_service = last_service
        self.image_metadata_name = None
        self.conditions = conditions
        self.scheduler = None
        self.job = None
        self.job_deleted = False
        self.log_callback = None
        self.result_callback = None
        self.notification_email = notification_email
        self.profile = profile
        self.job_status = 'prepared'
        self.progress_log = {}
        self.conditions_wait_time = conditions_wait_time
        self.disallow_licenses = disallow_licenses
        self.disallow_packages = disallow_packages
        self.log_callback = logging.LoggerAdapter(log_callback,
                                                  {'job_id': self.job_id})
        self.errors = []

        # How often to update log callback with download progress.
        # 25 updates every 25%. I.e. 25, 50, 75, 100.
        self.download_progress_percent = 25

        kwargs = {
            'conditions': self.conditions,
            'arch': self.arch,
            'target_directory': self.download_directory,
            'conditions_wait_time': conditions_wait_time,
            'log_callback': self.log_callback,
            'report_callback': self.progress_callback
        }

        if self.profile:
            kwargs['profile'] = self.profile

        if self.disallow_licenses:
            kwargs['filter_licenses'] = self.disallow_licenses

        if self.disallow_packages:
            kwargs['filter_packages'] = self.disallow_packages

        self.downloader = OBSImageUtil(self.download_url, self.image_name,
                                       **kwargs)