Beispiel #1
0
 def install_options(self, distro_tree_id, **kwargs):
     try:
         distro_tree = DistroTree.by_id(distro_tree_id)
     except NoResultFound:
         flash(_(u'Invalid distro tree id %s') % distro_tree_id)
         redirect('.')
     if 'ks_meta' in kwargs:
         distro_tree.activity.append(DistroTreeActivity(
                 user=identity.current.user, service=u'WEBUI',
                 action=u'Changed', field_name=u'InstallOption:ks_meta',
                 old_value=distro_tree.ks_meta,
                 new_value=kwargs['ks_meta']))
         distro_tree.ks_meta = kwargs['ks_meta']
     if 'kernel_options' in kwargs:
         distro_tree.activity.append(DistroTreeActivity(
                 user=identity.current.user, service=u'WEBUI',
                 action=u'Changed', field_name=u'InstallOption:kernel_options',
                 old_value=distro_tree.kernel_options,
                 new_value=kwargs['kernel_options']))
         distro_tree.kernel_options = kwargs['kernel_options']
     if 'kernel_options_post' in kwargs:
         distro_tree.activity.append(DistroTreeActivity(
                 user=identity.current.user, service=u'WEBUI',
                 action=u'Changed', field_name=u'InstallOption:kernel_options_post',
                 old_value=distro_tree.kernel_options_post,
                 new_value=kwargs['kernel_options_post']))
         distro_tree.kernel_options_post = kwargs['kernel_options_post']
     flash(_(u'Updated install options'))
     redirect(str(distro_tree.id))
Beispiel #2
0
 def distrotree(self, **kw):
     activities = DistroTreeActivity.all()
     activity_search = search_utility.DistroTreeActivity.search
     search_bar = SearchBar(activity_search.create_complete_search_table(),
                            name='activitysearch',)
     return self._activities_grid(activities, search_bar, 'distrotree',
         search_utility.DistroTreeActivity, title='Distro Tree Activity', **kw)
Beispiel #3
0
    def lab_controller_add(self, distro_tree_id, lab_controller_id, url):
        try:
            distro_tree = DistroTree.by_id(distro_tree_id)
        except NoResultFound:
            flash(_(u'Invalid distro tree id %s') % distro_tree_id)
            redirect('.')
        try:
            lab_controller = LabController.by_id(lab_controller_id)
        except ValueError:
            flash(_(u'Invalid lab controller id %s') % lab_controller_id)
            redirect(str(distro_tree.id))

        url = url.strip()
        if not url.endswith('/'):
            url = url + '/'
        if not urlparse.urlparse(url).scheme:
            flash(_(u'URL %r is not absolute') % url)
            redirect(str(distro_tree.id))
        distro_tree.lab_controller_assocs.append(
                LabControllerDistroTree(lab_controller=lab_controller, url=url))
        distro_tree.activity.append(DistroTreeActivity(
                user=identity.current.user, service=u'WEBUI',
                action=u'Added', field_name=u'lab_controller_assocs',
                old_value=None, new_value=u'%s %s' % (lab_controller, url)))
        flash(_(u'Added %s %s') % (lab_controller, url))
        redirect(str(distro_tree.id))
Beispiel #4
0
    def setUp(self):
        self.distro = data_setup.create_distro()
        self.distro_tree1 = data_setup.create_distro_tree(distro=self.distro,
                                                          arch='x86_64')
        self.distro_tree2 = data_setup.create_distro_tree(distro=self.distro,
                                                          arch='i386')

        self.distro_tree1.activity.append(
            DistroTreeActivity(user=User.by_user_name(data_setup.ADMIN_USER),
                               service=u'testdata',
                               field_name=u'Nonesente',
                               old_value=u'sdfas',
                               new_value=u'sdfa',
                               action='Added'))
        self.distro_tree2.activity.append(
            DistroTreeActivity(user=User.by_user_name(data_setup.ADMIN_USER),
                               service=u'testdata',
                               field_name=u'Noneseonce',
                               old_value=u'bsdf',
                               new_value=u'sdfas',
                               action='Added'))

        self.distro.activity.append(
            DistroActivity(user=User.by_user_name(data_setup.ADMIN_USER),
                           service=u'testdata',
                           action=u'Nothing',
                           field_name=u'Nonsense',
                           old_value=u'asdf',
                           new_value=u'omgwtfbbq'))
        self.system = data_setup.create_system()
        self.system.activity.append(
            SystemActivity(user=User.by_user_name(data_setup.ADMIN_USER),
                           service=u'testdata',
                           action=u'Nothing',
                           field_name=u'Nonsense',
                           old_value=u'asdf',
                           new_value=u'omgwtfbbq'))
        self.group2 = data_setup.create_group()
        self.group = data_setup.create_group()
        self.group.activity.append(
            GroupActivity(user=User.by_user_name(data_setup.ADMIN_USER),
                          service=u'testdata',
                          action=u'Nothing',
                          field_name=u'Nonsense',
                          old_value=u'asdf',
                          new_value=u'omgwtfbbq'))
        self.browser = self.get_browser()
Beispiel #5
0
 def test_can_search_custom_service(self):
     with session.begin():
         self.distro_tree1.activity.append(
             DistroTreeActivity(user=User.by_user_name(
                 data_setup.ADMIN_USER),
                                service=u'TESTSERVICE',
                                field_name=u'Nonesente',
                                old_value=u'sdfas',
                                new_value=u'sdfa',
                                action='Removed'))
         self.distro_tree2.activity.append(
             DistroTreeActivity(user=User.by_user_name(
                 data_setup.ADMIN_USER),
                                service=u'TESTSERVICE2',
                                field_name=u'Noneseonce',
                                old_value=u'bsdf',
                                new_value=u'sdfas',
                                action='Removed'))
     b = self.browser
     b.get(get_server_base() + 'activity/distrotree')
     b.find_element_by_link_text('Show Search Options').click()
     # Make sure only distrotree1 is returned
     b.find_element_by_xpath(
         "//select[@id='activitysearch_0_table']/option[@value='Via']"
     ).click()
     b.find_element_by_xpath(
         "//select[@id='activitysearch_0_operation']/option[@value='is']"
     ).click()
     b.find_element_by_xpath(
         "//input[@id='activitysearch_0_value']").send_keys('TESTSERVICE')
     b.find_element_by_id('searchform').submit()
     self.assertTrue(
         is_activity_row_present(b,
                                 via='TESTSERVICE',
                                 action='Removed',
                                 object_='DistroTree: %s' %
                                 self.distro_tree1))
     self.assertFalse(
         is_activity_row_present(b,
                                 via='TESTSERVICE2',
                                 action='Removed',
                                 object_='DistroTree: %s' %
                                 self.distro_tree2))
Beispiel #6
0
 def add_distro_urls(distro_tree, lab_controller, urls):
     """
     Adds supplied URLs to specific distro tree under specific lab controller.
     Old URL will be replaced if new URL uses the same scheme
     """
     new_urls_by_scheme = dict(
         (urlparse.urlparse(url, scheme=None).scheme, url) for url in urls)
     if None in new_urls_by_scheme:
         raise ValueError('URL %r is not absolute' %
                          new_urls_by_scheme[None])
     for lca in distro_tree.lab_controller_assocs:
         if lca.lab_controller == lab_controller:
             scheme = urlparse.urlparse(lca.url).scheme
             new_url = new_urls_by_scheme.pop(scheme, None)
             # replace old url if it's the same scheme
             if new_url is not None and lca.url != new_url:
                 distro_tree.activity.append(
                     DistroTreeActivity(user=identity.current.user,
                                        service=u'XMLRPC',
                                        action=u'Changed',
                                        field_name=u'lab_controller_assocs',
                                        old_value=u'%s %s' %
                                        (lca.lab_controller, lca.url),
                                        new_value=u'%s %s' %
                                        (lca.lab_controller, new_url)))
                 lca.url = new_url
     for url in new_urls_by_scheme.values():
         distro_tree.lab_controller_assocs.append(
             LabControllerDistroTree(lab_controller=lab_controller,
                                     url=url))
         distro_tree.activity.append(
             DistroTreeActivity(user=identity.current.user,
                                service=u'XMLRPC',
                                action=u'Added',
                                field_name=u'lab_controller_assocs',
                                old_value=None,
                                new_value=u'%s %s' % (lab_controller, url)))
Beispiel #7
0
    def lab_controller_remove(self, id):
        try:
            lca = LabControllerDistroTree.by_id(id)
        except NoResultFound:
            flash(_(u'Invalid lab_controller_assoc id %s') % id)
            redirect('.')

        session.delete(lca)
        lca.distro_tree.activity.append(DistroTreeActivity(
                user=identity.current.user, service=u'WEBUI',
                action=u'Removed', field_name=u'lab_controller_assocs',
                old_value=u'%s %s' % (lca.lab_controller, lca.url),
                new_value=None))
        flash(_(u'Deleted %s %s') % (lca.lab_controller, lca.url))
        redirect(str(lca.distro_tree.id))
Beispiel #8
0
    def add_distro_tree(self, new_distro):
        lab_controller = identity.current.user.lab_controller

        variant = new_distro.get('variant')
        arch = Arch.lazy_create(arch=new_distro['arch'])

        osmajor = OSMajor.lazy_create(osmajor=new_distro['osmajor'])
        try:
            osmajor = OSMajor.by_alias(new_distro['osmajor'])
        except NoResultFound:
            pass
        else:
            raise BX(
                _('Cannot import distro as %s: it is configured as an alias for %s'
                  % (new_distro['osmajor'], osmajor.osmajor)))

        osversion = OSVersion.lazy_create(osmajor=osmajor,
                                          osminor=new_distro['osminor'])
        if 'arches' in new_distro:
            for arch_name in new_distro['arches']:
                osversion.add_arch(Arch.lazy_create(arch=arch_name))
        osversion.add_arch(arch)

        distro = Distro.lazy_create(name=new_distro['name'],
                                    osversion=osversion)
        # Automatically tag the distro if tags exists
        if 'tags' in new_distro:
            for tag in new_distro['tags']:
                distro.add_tag(tag)
        distro.date_created = datetime.utcfromtimestamp(
            float(new_distro['tree_build_time']))

        distro_tree = DistroTree.lazy_create(distro=distro,
                                             variant=variant,
                                             arch=arch)
        distro_tree.date_created = datetime.utcfromtimestamp(
            float(new_distro['tree_build_time']))

        if 'repos' in new_distro:
            for repo in new_distro['repos']:
                dtr = DistroTreeRepo.lazy_create(distro_tree=distro_tree,
                                                 repo_id=repo['repoid'],
                                                 repo_type=repo['type'],
                                                 path=repo['path'])

        if 'kernel_options' in new_distro:
            distro_tree.kernel_options = new_distro['kernel_options']

        if 'kernel_options_post' in new_distro:
            distro_tree.kernel_options_post = new_distro['kernel_options_post']

        if 'ks_meta' in new_distro:
            distro_tree.ks_meta = new_distro['ks_meta']

        if 'images' in new_distro:
            for image in new_distro['images']:
                try:
                    image_type = ImageType.from_string(image['type'])
                except ValueError:
                    continue  # ignore
                if 'kernel_type' not in image:
                    image['kernel_type'] = 'default'
                try:
                    kernel_type = KernelType.by_name(image['kernel_type'])
                except ValueError:
                    continue  # ignore
                dti = DistroTreeImage.lazy_create(distro_tree=distro_tree,
                                                  image_type=image_type,
                                                  kernel_type=kernel_type,
                                                  path=image['path'])

        new_urls_by_scheme = dict(
            (urlparse.urlparse(url).scheme, url) for url in new_distro['urls'])
        if None in new_urls_by_scheme:
            raise ValueError('URL %r is not absolute' %
                             new_urls_by_scheme[None])
        for lca in distro_tree.lab_controller_assocs:
            if lca.lab_controller == lab_controller:
                scheme = urlparse.urlparse(lca.url).scheme
                new_url = new_urls_by_scheme.pop(scheme, None)
                if new_url != None and lca.url != new_url:
                    distro_tree.activity.append(
                        DistroTreeActivity(user=identity.current.user,
                                           service=u'XMLRPC',
                                           action=u'Changed',
                                           field_name=u'lab_controller_assocs',
                                           old_value=u'%s %s' %
                                           (lca.lab_controller, lca.url),
                                           new_value=u'%s %s' %
                                           (lca.lab_controller, new_url)))
                    lca.url = new_url
        for url in new_urls_by_scheme.values():
            distro_tree.lab_controller_assocs.append(
                LabControllerDistroTree(lab_controller=lab_controller,
                                        url=url))
            distro_tree.activity.append(
                DistroTreeActivity(user=identity.current.user,
                                   service=u'XMLRPC',
                                   action=u'Added',
                                   field_name=u'lab_controller_assocs',
                                   old_value=None,
                                   new_value=u'%s %s' % (lab_controller, url)))

        return distro_tree.id