Beispiel #1
0
def module_configtemaplate(module_org, module_location):
    pxe_template = entities.ConfigTemplate().search(
        query={'search': 'name="{0}"'.format(DEFAULT_PXE_TEMPLATE)})
    pxe_template = pxe_template[0].read()
    pxe_template.organization.append(module_org)
    pxe_template.location.append(module_location)
    pxe_template.update(['organization', 'location'])
    pxe_template = entities.ConfigTemplate(id=pxe_template.id).read()
    return pxe_template
    def test_positive_delete(self):
        """@Test: Create configuration template and then delete it.

        @Assert: Configuration Template is successfully deleted.

        @Feature: Configuration Template

        """
        c_temp = entities.ConfigTemplate().create()
        c_temp.delete()
        with self.assertRaises(HTTPError):
            entities.ConfigTemplate(id=c_temp.id).read()
Beispiel #3
0
    def test_positive_delete(self):
        """Create configuration template and then delete it.

        @id: 1471f17c-4412-4717-a6c4-b57a8d2f8cfd

        @Assert: Configuration Template is successfully deleted.
        """
        for name in valid_data_list():
            with self.subTest(name):
                c_temp = entities.ConfigTemplate().create()
                c_temp.delete()
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(id=c_temp.id).read()
Beispiel #4
0
    def test_positive_delete(self):
        """Create configuration template and then delete it.

        @Assert: Configuration Template is successfully deleted.

        @Feature: Configuration Template
        """
        for name in valid_data_list():
            with self.subTest(name):
                c_temp = entities.ConfigTemplate().create()
                c_temp.delete()
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(id=c_temp.id).read()
Beispiel #5
0
    def test_positive_clone(self):
        """Assure ability to clone a provisioning template

        @id: 8dfbb234-7a52-4873-be72-4de086472669

        @Assert: The template is cloned successfully

        @CaseLevel: Integration
        """
        template = entities.ConfigTemplate().create()
        for name in valid_data_list():
            with self.subTest(name):
                new_template = entities.ConfigTemplate(id=template.clone(
                    data={u'name': name})['id']).read()
                self.assertEqual(name, new_template.name)
    def test_positive_remove_template(self):
        """Remove config template.

        @feature: Organizations dissociate config templates.

        @assert: Config Template is added and then removed.
        """
        strategy, value = common_locators['entity_select']
        strategy1, value1 = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for template_name in generate_strings_list():
                with self.subTest(template_name):
                    org_name = gen_string('alpha')
                    # Create config template using nailgun
                    entities.ConfigTemplate(name=template_name).create()
                    make_org(session,
                             org_name=org_name,
                             templates=[template_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_template'])
                    element = session.nav.wait_until_element(
                        (strategy1, value1 % template_name))
                    # Item is listed in 'Selected Items' list and not
                    # 'All Items' list.
                    self.assertIsNotNone(element)
                    self.org.update(org_name, templates=[template_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_template'])
                    element = self.org.wait_until_element(
                        (strategy, value % template_name))
                    # Item is listed in 'All Items' list and not
                    # 'Selected Items' list.
                    self.assertIsNotNone(element)
Beispiel #7
0
    def test_positive_add_orgs(self):
        """Associate a config template with organizations.

        :id: b60907c3-47b9-4bc7-99d6-08615ebe9d68

        :expectedresults: Config template is associated with organization

        :CaseLevel: Integration
        """
        orgs = [entities.Organization().create() for _ in range(2)]

        # By default, a configuration template should have no organizations.
        conf_templ = entities.ConfigTemplate().create()
        self.assertEqual(0, len(conf_templ.organization))

        # Associate our configuration template with one organization.
        conf_templ.organization = orgs[:1]
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 1)
        self.assertEqual(conf_templ.organization[0].id, orgs[0].id)

        # Associate our configuration template with two organizations.
        conf_templ.organization = orgs
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 2)
        self.assertEqual(
            set((org.id for org in conf_templ.organization)),
            set((org.id for org in orgs)),
        )

        # Finally, associate our config template with zero organizations.
        conf_templ.organization = []
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 0)
Beispiel #8
0
    def test_positive_update_name(self):
        """Create configuration template providing the initial name,
        then update its name to another valid name.

        @Assert: Configuration Template is created, and its name can be
        updated.

        @Feature: Configuration Template
        """
        c_temp = entities.ConfigTemplate().create()

        for new_name in valid_data_list():
            with self.subTest(new_name):
                updated = entities.ConfigTemplate(
                    id=c_temp.id, name=new_name).update(['name'])
                self.assertEqual(new_name, updated.name)
Beispiel #9
0
    def test_positive_add_orgs(self):
        """Associate a config template with organizations.

        @Assert: Config template is associated with organization

        @Feature: ConfigTemplate
        """
        orgs = [entities.Organization().create() for _ in range(2)]

        # By default, a configuration template should have no organizations.
        conf_templ = entities.ConfigTemplate().create()
        self.assertEqual(0, len(conf_templ.organization))

        # Associate our configuration template with one organization.
        conf_templ.organization = orgs[:1]
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 1)
        self.assertEqual(conf_templ.organization[0].id, orgs[0].id)

        # Associate our configuration template with two organizations.
        conf_templ.organization = orgs
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 2)
        self.assertEqual(
            set((org.id for org in conf_templ.organization)),
            set((org.id for org in orgs)),
        )

        # Finally, associate our config template with zero organizations.
        conf_templ.organization = []
        conf_templ = conf_templ.update(['organization'])
        self.assertEqual(len(conf_templ.organization), 0)
Beispiel #10
0
    def test_positive_add_template(self):
        """Add config template by using organization name and
        config template name.

        @id: 2af534d4-2f92-4b25-81d9-d0129f9cf866

        @assert: config template is added

        @CaseLevel: Integration
        """
        strategy, value = common_locators['entity_deselect']
        with Session(self.browser) as session:
            for template_name in generate_strings_list():
                with self.subTest(template_name):
                    org_name = gen_string('alpha')
                    # Create config template using nailgun
                    entities.ConfigTemplate(name=template_name).create()
                    make_org(session, org_name=org_name)
                    self.assertIsNotNone(self.org.search(org_name))
                    self.org.update(org_name, new_templates=[template_name])
                    self.org.search(org_name).click()
                    session.nav.click(tab_locators['context.tab_template'])
                    element = session.nav.wait_until_element(
                        (strategy, value % template_name))
                    self.assertIsNotNone(element)
Beispiel #11
0
def provisioning_env(module_org, module_loc):
    # Build PXE default template to get default PXE file
    entities.ConfigTemplate().build_pxe_default()
    return configure_provisioning(
        org=module_org,
        loc=module_loc,
        os='Redhat {0}'.format(RHELRepository().repo_data['version']),
    )
Beispiel #12
0
    def test_negative_update_name(self):
        """Create configuration template then update its name to an
        invalid name.

        @Assert: Configuration Template is created, and its name is not
        updated.

        @Feature: Configuration Template
        """
        c_temp = entities.ConfigTemplate().create()
        for new_name in invalid_names_list():
            with self.subTest(new_name):
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(id=c_temp.id,
                                            name=new_name).update(['name'])
                c_temp = entities.ConfigTemplate(id=c_temp.id).read()
                self.assertNotEqual(c_temp.name, new_name)
    def test_positive_update(self):
        """@Test: Create configuration template providing the initial name, then update
        its name to another valid name.

        @Assert: Configuration Template is created, and its name can be
        updated.

        @Feature: Configuration Template

        """
        c_temp = entities.ConfigTemplate().create()

        new_name = gen_string('utf8', 30)
        updated = entities.ConfigTemplate(id=c_temp.id,
                                          name=new_name).update(['name'])
        self.assertEqual(new_name, updated.name)
        self.assertNotEqual(c_temp.name, updated.name)
Beispiel #14
0
    def test_positive_update_name(self):
        """Create configuration template providing the initial name,
        then update its name to another valid name.

        :id: 58ccc4ee-5faa-4fb2-bfd0-e19412e230dd

        :expectedresults: Configuration Template is created, and its name can
            be updated.

        :CaseImportance: Critical
        """
        c_temp = entities.ConfigTemplate().create()

        for new_name in valid_data_list():
            with self.subTest(new_name):
                updated = entities.ConfigTemplate(
                    id=c_temp.id, name=new_name).update(['name'])
                self.assertEqual(new_name, updated.name)
    def test_positive_update_template(self):
        """Create an operating system that points at config template and
        then update it to point to another template

        @Feature: Operating System

        @Assert: The operating system is updated and points at the expected
        config template.
        """
        template_1 = entities.ConfigTemplate(organization=[self.org]).create()
        template_2 = entities.ConfigTemplate(organization=[self.org]).create()
        os = entities.OperatingSystem(config_template=[template_1]).create()
        self.assertEqual(len(os.config_template), 1)
        self.assertEqual(os.config_template[0].id, template_1.id)
        os = entities.OperatingSystem(
            id=os.id, config_template=[template_2]).update(['config_template'])
        self.assertEqual(len(os.config_template), 1)
        self.assertEqual(os.config_template[0].id, template_2.id)
    def test_negative_update(self):
        """@Test: Create configuration template then update its name to an
        invalid name.

        @Assert: Configuration Template is created, and its name is not
        updated.

        @Feature: Configuration Template

        """
        c_temp = entities.ConfigTemplate().create()
        name = c_temp.name
        new_name = gen_string('utf8', 300)
        with self.assertRaises(HTTPError):
            entities.ConfigTemplate(id=c_temp.id,
                                    name=new_name).update(['name'])
        c_temp = entities.ConfigTemplate(id=c_temp.id).read()
        self.assertNotEqual(c_temp.name, new_name)
        self.assertEqual(name, c_temp.name)
Beispiel #17
0
    def test_negative_update_name(self):
        """Create configuration template then update its name to an
        invalid name.

        :id: f6167dc5-26ba-46d7-b61f-14c290d6a8fa

        :expectedresults: Configuration Template is created, and its name is
            not updated.

        :CaseImportance: Critical
        """
        c_temp = entities.ConfigTemplate().create()
        for new_name in invalid_names_list():
            with self.subTest(new_name):
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(id=c_temp.id,
                                            name=new_name).update(['name'])
                c_temp = entities.ConfigTemplate(id=c_temp.id).read()
                self.assertNotEqual(c_temp.name, new_name)
Beispiel #18
0
    def test_positive_update_template(self):
        """Update location with new config template

        @id: 9c8a1306-b0c7-4f72-8a31-4ff441bf5c75

        @Assert: Location updated successfully and has correct config template
        assigned

        @CaseLevel: Integration
        """
        location = entities.Location(
            config_template=[entities.ConfigTemplate().create()], ).create()
        template = entities.ConfigTemplate().create()
        location.config_template = [template]
        ct_list = [
            ct for ct in location.update(['config_template']).config_template
            if ct.id == template.id
        ]
        self.assertEqual(len(ct_list), 1)
Beispiel #19
0
    def test_negative_create_with_invalid_name(self):
        """Create configuration template providing an invalid name.

        @Assert: Configuration Template is not created

        @Feature: Configuration Template
        """
        for name in invalid_names_list():
            with self.subTest(name):
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(name=name).create()
Beispiel #20
0
    def test_positive_create_with_name(self):
        """Create a configuration template providing the initial name.

        @Assert: Configuration Template is created and contains provided name.

        @Feature: Configuration Template
        """
        for name in valid_data_list():
            with self.subTest(name):
                c_temp = entities.ConfigTemplate(name=name).create()
                self.assertEqual(name, c_temp.name)
Beispiel #21
0
    def test_positive_create_with_name(self):
        """Create a configuration template providing the initial name.

        @id: 20ccd5c8-98c3-4f22-af50-9760940e5d39

        @Assert: Configuration Template is created and contains provided name.
        """
        for name in valid_data_list():
            with self.subTest(name):
                c_temp = entities.ConfigTemplate(name=name).create()
                self.assertEqual(name, c_temp.name)
    def test_positive_create(self):
        """@Test: Create a configuration template providing the initial name.

        @Assert: Configuration Template is created and contains provided name.

        @Feature: Configuration Template

        """
        name = gen_string('utf8', 30)
        c_temp = entities.ConfigTemplate(name=name).create()
        self.assertEqual(name, c_temp.name)
Beispiel #23
0
    def test_negative_create_with_invalid_name(self):
        """Create configuration template providing an invalid name.

        @id: 2ec7023f-db4d-49ed-b783-6a4fce79064a

        @Assert: Configuration Template is not created
        """
        for name in invalid_names_list():
            with self.subTest(name):
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(name=name).create()
Beispiel #24
0
    def test_positive_update_template(self):
        """Update location with new config template

        @Assert: Location updated successfully and has correct config template
        assigned

        @Feature: Location - Update
        """
        location = entities.Location(
            config_template=[entities.ConfigTemplate().create()],
        ).create()
        template = entities.ConfigTemplate().create()
        location.config_template = [template]
        ct_list = [
            ct
            for ct
            in location.update(['config_template']).config_template
            if ct.id == template.id
        ]
        self.assertEqual(len(ct_list), 1)
    def test_negative_create(self):
        """@Test: Create configuration template providing an invalid initial name.
        set.

        @Assert: Configuration Template is not created

        @Feature: Configuration Template

        """
        with self.assertRaises(HTTPError):
            entities.ConfigTemplate(name=gen_string('utf8', 300)).create()
    def test_positive_update_template(self):
        """Create an operating system that points at config template and
        then update it to point to another template

        :id: 02125a7a-905a-492a-a49b-768adf4ac00c

        :expectedresults: The operating system is updated and points at the
            expected config template.

        :CaseLevel: Integration
        """
        template_1 = entities.ConfigTemplate(organization=[self.org]).create()
        template_2 = entities.ConfigTemplate(organization=[self.org]).create()
        os = entities.OperatingSystem(config_template=[template_1]).create()
        self.assertEqual(len(os.config_template), 1)
        self.assertEqual(os.config_template[0].id, template_1.id)
        os = entities.OperatingSystem(
            id=os.id, config_template=[template_2]).update(['config_template'])
        self.assertEqual(len(os.config_template), 1)
        self.assertEqual(os.config_template[0].id, template_2.id)
Beispiel #27
0
 def setUpClass(cls):
     """Set up reusable entities for tests."""
     super(LocationTestCase, cls).setUpClass()
     cls.org = entities.Organization().create()
     cls.org2 = entities.Organization().create()
     cls.domain = entities.Domain().create()
     cls.subnet = entities.Subnet().create()
     cls.env = entities.Environment().create()
     cls.host_group = entities.HostGroup().create()
     cls.template = entities.ConfigTemplate().create()
     cls.test_cr = entities.LibvirtComputeResource().create()
     cls.new_user = entities.User().create()
    def test_positive_create_with_template(self):
        """Create an operating system that points at a config template.

        @Feature: Operating System

        @Assert: The operating system is created and points at the expected
        config template.
        """
        template = entities.ConfigTemplate(organization=[self.org]).create()
        operating_sys = entities.OperatingSystem(
            config_template=[template]).create()
        self.assertEqual(len(operating_sys.config_template), 1)
        self.assertEqual(operating_sys.config_template[0].id, template.id)
Beispiel #29
0
    def test_negative_create_with_invalid_name(self):
        """Create configuration template providing an invalid name.

        :id: 2ec7023f-db4d-49ed-b783-6a4fce79064a

        :expectedresults: Configuration Template is not created

        :CaseImportance: Critical
        """
        for name in invalid_names_list():
            with self.subTest(name):
                with self.assertRaises(HTTPError):
                    entities.ConfigTemplate(name=name).create()
Beispiel #30
0
    def test_positive_build_pxe_default(self):
        """Call the "build_pxe_default" path.

        @Assert: The response is a JSON payload.

        @Feature: ConfigTemplate
        """
        response = client.get(
            entities.ConfigTemplate().path('build_pxe_default'),
            auth=settings.server.get_credentials(),
            verify=False,
        )
        response.raise_for_status()
        self.assertIsInstance(response.json(), dict)