Пример #1
0
    def index(self, **kwargs):
        # CherryPy will give us distro_tree_id as a scalar if it only has one 
        # value, but we want it to always be a list of int
        if not kwargs.get('distro_tree_id'):
            kwargs['distro_tree_id'] = []
        elif not isinstance(kwargs['distro_tree_id'], list):
            kwargs['distro_tree_id'] = [int(kwargs['distro_tree_id'])]
        else:
            kwargs['distro_tree_id'] = [int(x) for x in kwargs['distro_tree_id']]

        # If we got a distro_tree_id but no osmajor or distro, fill those in 
        # with the right values so that the distro picker is populated properly
        if kwargs['distro_tree_id']:
            distro_tree = DistroTree.by_id(kwargs['distro_tree_id'][0])
            if not kwargs.get('distro'):
                kwargs['distro'] = distro_tree.distro.name
            if not kwargs.get('osmajor'):
                kwargs['osmajor'] = distro_tree.distro.osversion.osmajor.osmajor

        options = {}
        options['tag'] = [tag.tag for tag in DistroTag.used()]
        options['osmajor'] = [osmajor.osmajor for osmajor in
                OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
        options['distro'] = self._get_distro_options(
                osmajor=kwargs.get('osmajor'), tag=kwargs.get('tag'))
        options['distro_tree_id'] = self._get_distro_tree_options(
                distro=kwargs.get('distro'))
        options['lab'] = [lc.fqdn for lc in
                LabController.query.filter(LabController.removed == None)]
        return dict(title=_(u'Reserve Workflow'),
                selection=kwargs, options=options)
Пример #2
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath,osmajor)
        if os.path.islink(dest):
            continue # skip symlinks
        syncer = RepoSyncer(urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            syncer.sync()
        except KeyboardInterrupt:
            raise
        except HarnessRepoNotFoundError:
            log.warning('Harness packages not found for OS major %s, ignoring', osmajor)
            continue
        flag_path = os.path.join(dest, '.new_files')
        if os.path.exists(flag_path):
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError('Createrepo failed.\nreturncode:%s cmd:%s err:%s'
                        % (returncode, command, err))
            os.unlink(flag_path)
Пример #3
0
    def index(self, **kwargs):
        kwargs.setdefault('tag', 'STABLE')
        value = dict((k, v) for k, v in kwargs.iteritems()
                if k in ['osmajor', 'tag', 'distro'])

        options = {}
        tags = DistroTag.used()
        options['tag'] = [('', 'None selected')] + \
                [(tag.tag, tag.tag) for tag in tags]
        options['osmajor'] = [('', 'None selected')] + \
                [(osmajor.osmajor, osmajor.osmajor) for osmajor
                in OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
        options['distro'] = self._get_distro_options(**kwargs)
        options['lab_controller_id'] = [(None, 'None selected')] + \
                LabController.get_all(valid=True)
        options['distro_tree_id'] = self._get_distro_tree_options(**kwargs)

        attrs = {}
        if not options['distro']:
            attrs['distro'] = dict(disabled=True)

        return dict(title=_(u'Reserve Workflow'),
                    widget=self.widget,
                    value=value,
                    widget_options=options,
                    widget_attrs=attrs)
Пример #4
0
    def index(self, **kwargs):
        value = dict((k, v) for k, v in kwargs.iteritems()
                if k in ['osmajor', 'tag', 'distro'])
        options = {}
        tags = DistroTag.used()
        # It's important that  'None selected' is prepended
        # rather then appended to the list of tags, as that will ensure
        # it is the default option in the drop down.
        options['tag'] = [('', 'None selected')] + \
                [(tag.tag, tag.tag) for tag in tags]
        options['osmajor'] = [('', 'None selected')] + \
                [(osmajor.osmajor, osmajor.osmajor) for osmajor
                in OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())]
        options['distro'] = self._get_distro_options(**kwargs)
        options['lab_controller_id'] = [(None, 'None selected')] + \
                LabController.get_all(valid=True)
        options['distro_tree_id'] = self._get_distro_tree_options(**kwargs)

        attrs = {}
        if not options['distro']:
            attrs['distro'] = dict(disabled=True)

        return dict(title=_(u'Reserve Workflow'),
                    widget=self.widget,
                    value=value,
                    widget_options=options,
                    widget_attrs=attrs)
Пример #5
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath, osmajor)
        if os.path.islink(dest):
            continue  # skip symlinks
        syncer = RepoSyncer(
            urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            has_new_packages = syncer.sync()
        except KeyboardInterrupt:
            raise
        except Exception, e:
            log.warning('%s', e)
            continue
        if has_new_packages:
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError(
                    'Createrepo failed.\nreturncode:%s cmd:%s err:%s' %
                    (returncode, command, err))
Пример #6
0
    def index(self, **kwargs):
        # CherryPy will give us distro_tree_id as a scalar if it only has one
        # value, but we want it to always be a list of int
        if not kwargs.get('distro_tree_id'):
            kwargs['distro_tree_id'] = []
        elif not isinstance(kwargs['distro_tree_id'], list):
            kwargs['distro_tree_id'] = [int(kwargs['distro_tree_id'])]
        else:
            kwargs['distro_tree_id'] = [
                int(x) for x in kwargs['distro_tree_id']
            ]

        # If we got a distro_tree_id but no osmajor or distro, fill those in
        # with the right values so that the distro picker is populated properly
        if kwargs['distro_tree_id']:
            distro_tree = DistroTree.by_id(kwargs['distro_tree_id'][0])
            if not kwargs.get('distro'):
                kwargs['distro'] = distro_tree.distro.name
            if not kwargs.get('osmajor'):
                kwargs[
                    'osmajor'] = distro_tree.distro.osversion.osmajor.osmajor

        options = {}
        options['tag'] = [tag.tag for tag in DistroTag.used()]
        options['osmajor'] = [
            osmajor.osmajor
            for osmajor in OSMajor.ordered_by_osmajor(OSMajor.in_any_lab())
        ]
        options['distro'] = self._get_distro_options(
            osmajor=kwargs.get('osmajor'), tag=kwargs.get('tag'))
        options['distro_tree_id'] = self._get_distro_tree_options(
            distro=kwargs.get('distro'))
        options['lab'] = [
            lc.fqdn
            for lc in LabController.query.filter(LabController.removed == None)
        ]
        return dict(title=_(u'Reserve Workflow'),
                    selection=kwargs,
                    options=options)
Пример #7
0
def update_repos(baseurl, basepath):
    # We only sync repos for the OS majors that have existing trees in the lab controllers.
    for osmajor in OSMajor.in_any_lab():
        # urlgrabber < 3.9.1 doesn't handle unicode urls
        osmajor = unicode(osmajor).encode('utf8')
        dest = "%s/%s" % (basepath,osmajor)
        if os.path.islink(dest):
            continue # skip symlinks
        syncer = RepoSyncer(urlparse.urljoin(baseurl, '%s/' % urllib.quote(osmajor)), dest)
        try:
            has_new_packages = syncer.sync()
        except KeyboardInterrupt:
            raise
        except Exception, e:
            log.warning('%s', e)
            continue
        if has_new_packages:
            createrepo_results = run_createrepo(cwd=dest)
            returncode = createrepo_results.returncode
            if returncode != 0:
                err = createrepo_results.err
                command = createrepo_results.command
                raise RuntimeError('Createrepo failed.\nreturncode:%s cmd:%s err:%s'
                     % (returncode, command, err))