Esempio n. 1
0
    def test_nacked_recipe_results_not_shown(self):
        with session.begin():
            data_setup.create_completed_job(
                    whiteboard=self.job_whiteboard, result=TaskResult.fail,
                    recipe_whiteboard=self.recipe_whiteboard)
            data_setup.create_completed_job(
                    whiteboard=self.job_whiteboard, result=TaskResult.warn,
                    recipe_whiteboard=self.recipe_whiteboard)
            owner = data_setup.create_user(password='******')
            self.passed_job.owner = owner
        b = self.browser
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath("//select[@name='whiteboard']/option[@value='%s']" % self.job_whiteboard).click()
        b.find_element_by_xpath("//input[@name='toggle_nacks_on']").click()
        b.find_element_by_xpath('//input[@value="Generate"]').click()
        report_text = b.find_element_by_xpath("//div[@id='matrix-report']").text
        self.assert_('Pass: 1' in report_text)

        # Nack Recipe
        with session.begin():
            response = Response.by_response('nak')
            self.passed_job.recipesets[0].nacked = RecipeSetResponse(response_id=response.id)

        # Assert it is no longer there
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath("//select[@name='whiteboard']/option[@value='%s']" % self.job_whiteboard).click()
        b.find_element_by_xpath("//input[@name='toggle_nacks_on']").click()
        b.find_element_by_xpath('//input[@value="Generate"]').click()
        report_text = b.find_element_by_xpath("//div[@id='matrix-report']").text
        self.assert_('Pass: 1' not in report_text)
Esempio n. 2
0
    def update_recipe_set_response(self,recipe_set_id,response_id):
        rs = RecipeSet.by_id(recipe_set_id)
        if rs.nacked is None:
            rs.nacked = RecipeSetResponse(response_id=response_id)
        else:
            rs.nacked.response = Response.by_id(response_id)

        return {'success' : 1, 'rs_id' : recipe_set_id }
Esempio n. 3
0
    def update_recipe_set_response(self,recipe_set_id,response_id):
        rs = RecipeSet.by_id(recipe_set_id)
        old_response = None
        if rs.nacked is None:
            rs.nacked = RecipeSetResponse(response_id=response_id)
        else:
            old_response = rs.nacked.response
            rs.nacked.response = Response.by_id(response_id)
        rs.record_activity(user=identity.current.user, service=u'WEBUI',
                           field=u'Ack/Nak', action=u'Changed', old=old_response,
                           new=rs.nacked.response)

        return {'success' : 1, 'rs_id' : recipe_set_id }
Esempio n. 4
0
    def update_recipe_set_response(self, recipe_set_id, response_id):
        rs = RecipeSet.by_id(recipe_set_id)
        old_response = None
        if rs.nacked is None:
            rs.nacked = RecipeSetResponse(response_id=response_id)
        else:
            old_response = rs.nacked.response
            rs.nacked.response = Response.by_id(response_id)
        rs.record_activity(user=identity.current.user,
                           service=u'WEBUI',
                           field=u'Ack/Nak',
                           action=u'Changed',
                           old=old_response,
                           new=rs.nacked.response)

        return {'success': 1, 'rs_id': recipe_set_id}
Esempio n. 5
0
    def test_nacked_recipe_results_not_shown(self):
        with session.begin():
            data_setup.create_completed_job(
                whiteboard=self.job_whiteboard,
                result=TaskResult.fail,
                recipe_whiteboard=self.recipe_whiteboard)
            data_setup.create_completed_job(
                whiteboard=self.job_whiteboard,
                result=TaskResult.warn,
                recipe_whiteboard=self.recipe_whiteboard)
            owner = data_setup.create_user(password='******')
            self.passed_job.owner = owner
        b = self.browser
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath(
            "//select[@name='whiteboard']/option[@value='%s']" %
            self.job_whiteboard).click()
        b.find_element_by_xpath("//input[@name='toggle_nacks_on']").click()
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        report_text = b.find_element_by_xpath(
            "//div[@id='matrix-report']").text
        self.assert_('Pass: 1' in report_text)

        # Nack Recipe
        with session.begin():
            response = Response.by_response('nak')
            self.passed_job.recipesets[0].nacked = RecipeSetResponse(
                response_id=response.id)

        # Assert it is no longer there
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath(
            "//select[@name='whiteboard']/option[@value='%s']" %
            self.job_whiteboard).click()
        b.find_element_by_xpath("//input[@name='toggle_nacks_on']").click()
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        report_text = b.find_element_by_xpath(
            "//div[@id='matrix-report']").text
        self.assert_('Pass: 1' not in report_text)
Esempio n. 6
0
def populate_db(user_name=None,
                password=None,
                user_display_name=None,
                user_email_address=None):
    session.begin()

    try:
        admin = Group.by_name(u'admin')
    except InvalidRequestError:
        admin = Group(group_name=u'admin', display_name=u'Admin')
        session.add(admin)

    try:
        lab_controller = Group.by_name(u'lab_controller')
    except InvalidRequestError:
        lab_controller = Group(group_name=u'lab_controller',
                               display_name=u'Lab Controller')
        session.add(lab_controller)

    #Setup User account
    if user_name:
        user = User.lazy_create(user_name=user_name.decode('utf8'))
        if password:
            user.password = password.decode('utf8')
        if user_display_name:
            user.display_name = user_display_name.decode('utf8')
        if user_email_address:
            user.email_address = user_email_address.decode('utf8')
        # Ensure the user is in the 'admin' group as an owner.
        # Flush for lazy_create.
        session.flush()
        user_group_assoc = UserGroup.lazy_create(user_id=user.user_id,
                                                 group_id=admin.group_id)
        user_group_assoc.is_owner = True

    # Create distro_expire perm if not present
    try:
        distro_expire_perm = Permission.by_name(u'distro_expire')
    except NoResultFound:
        distro_expire_perm = Permission(u'distro_expire')
        session.add(distro_expire_perm)

    # Create proxy_auth perm if not present
    try:
        proxy_auth_perm = Permission.by_name(u'proxy_auth')
    except NoResultFound:
        proxy_auth_perm = Permission(u'proxy_auth')
        session.add(proxy_auth_perm)

    # Create tag_distro perm if not present
    try:
        tag_distro_perm = Permission.by_name(u'tag_distro')
    except NoResultFound:
        tag_distro_perm = Permission(u'tag_distro')
        admin.permissions.append(tag_distro_perm)

    # Create stop_task perm if not present
    try:
        stop_task_perm = Permission.by_name(u'stop_task')
    except NoResultFound:
        stop_task_perm = Permission(u'stop_task')
        lab_controller.permissions.append(stop_task_perm)
        admin.permissions.append(stop_task_perm)

    # Create secret_visible perm if not present
    try:
        secret_visible_perm = Permission.by_name(u'secret_visible')
    except NoResultFound:
        secret_visible_perm = Permission(u'secret_visible')
        lab_controller.permissions.append(secret_visible_perm)
        admin.permissions.append(secret_visible_perm)

    #Setup Hypervisors Table
    if Hypervisor.query.count() == 0:
        for h in [u'KVM', u'Xen', u'HyperV', u'VMWare']:
            session.add(Hypervisor(hypervisor=h))

    #Setup kernel_type Table
    if KernelType.query.count() == 0:
        for type in [u'default', u'highbank', u'imx', u'omap', u'tegra']:
            session.add(KernelType(kernel_type=type, uboot=False))
        for type in [u'mvebu']:
            session.add(KernelType(kernel_type=type, uboot=True))

    #Setup base Architectures
    if Arch.query.count() == 0:
        for arch in [
                u'i386', u'x86_64', u'ia64', u'ppc', u'ppc64', u'ppc64le',
                u's390', u's390x', u'armhfp', u'aarch64', u'arm'
        ]:
            session.add(Arch(arch))

    #Setup base power types
    if PowerType.query.count() == 0:
        for power_type in [
                u'apc_snmp', u'apc_snmp_then_etherwake', u'bladecenter',
                u'bladepap', u'drac', u'ether_wake', u'hyper-v', u'ilo',
                u'integrity', u'ipmilan', u'ipmitool', u'lpar', u'rsa',
                u'virsh', u'wti'
        ]:
            session.add(PowerType(power_type))

    #Setup key types
    if Key.query.count() == 0:
        session.add(Key(u'DISKSPACE', True))
        session.add(Key(u'COMMENT'))
        session.add(Key(u'CPUFAMILY', True))
        session.add(Key(u'CPUFLAGS'))
        session.add(Key(u'CPUMODEL'))
        session.add(Key(u'CPUMODELNUMBER', True))
        session.add(Key(u'CPUSPEED', True))
        session.add(Key(u'CPUVENDOR'))
        session.add(Key(u'DISK', True))
        session.add(Key(u'FORMFACTOR'))
        session.add(Key(u'HVM'))
        session.add(Key(u'MEMORY', True))
        session.add(Key(u'MODEL'))
        session.add(Key(u'MODULE'))
        session.add(Key(u'NETWORK'))
        session.add(Key(u'NR_DISKS', True))
        session.add(Key(u'NR_ETH', True))
        session.add(Key(u'NR_IB', True))
        session.add(Key(u'PCIID'))
        session.add(Key(u'PROCESSORS', True))
        session.add(Key(u'RTCERT'))
        session.add(Key(u'SCRATCH'))
        session.add(Key(u'STORAGE'))
        session.add(Key(u'USBID'))
        session.add(Key(u'VENDOR'))
        session.add(Key(u'XENCERT'))
        session.add(Key(u'NETBOOT_METHOD'))

    #Setup ack/nak reposnses
    if Response.query.count() == 0:
        session.add(Response(response=u'ack'))
        session.add(Response(response=u'nak'))

    if RetentionTag.query.count() == 0:
        session.add(
            RetentionTag(tag=u'scratch', is_default=1, expire_in_days=30))
        session.add(
            RetentionTag(tag=u'60days', needs_product=False,
                         expire_in_days=60))
        session.add(
            RetentionTag(tag=u'120days',
                         needs_product=False,
                         expire_in_days=120))
        session.add(RetentionTag(tag=u'active', needs_product=True))
        session.add(RetentionTag(tag=u'audit', needs_product=True))

    config_items = [
        # name, description, numeric
        (u'root_password', u'Plaintext root password for provisioned systems',
         False),
        (u'root_password_validity',
         u"Maximum number of days a user's root password is valid for", True),
        (u'guest_name_prefix',
         u'Prefix for names of dynamic guests in OpenStack', False),
    ]
    for name, description, numeric in config_items:
        ConfigItem.lazy_create(name=name,
                               description=description,
                               numeric=numeric)
    if ConfigItem.by_name(u'root_password').current_value() is None:
        ConfigItem.by_name(u'root_password').set(u'beaker',
                                                 user=admin.users[0])

    session.commit()
    session.close()