Esempio n. 1
0
    def test_positive_update_with_manager_role(self):
        """Create template providing the initial name, then update its name
        with manager user role.

        :id: 28c4357a-93cb-4b01-a445-5db50435bcc0

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

        :CaseImportance: Critical

        :BZ: 1277308
        """
        new_name = gen_string('alpha')
        username = gen_string('alpha')
        password = gen_string('alpha')
        org = make_org()
        loc = make_location()
        template = make_template({
            'organization-ids': org['id'], 'location-ids': loc['id']})
        # Create user with Manager role
        user = make_user({
            'login': username,
            'password': password,
            'admin': False,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        User.add_role({'id': user['id'], 'role': "Manager"})
        # Update template name with that user
        Template.with_user(username=username, password=password).update({
            'id': template['id'], 'name': new_name})
        template = Template.info({'id': template['id']})
        self.assertEqual(new_name, template['name'])
Esempio n. 2
0
    def test_dump_template_1(self):
        """@Test: Check if Template can be created with specific content

        @Feature: Template - Create

        @Assert: Template is created with specific content

        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        new_obj = make_template(
            {
                'name': name,
                'content': content,
            }
        )

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        template_content = Template.dump({'id': new_obj['id']})
        self.assertIn(content, template_content.stdout[0])
Esempio n. 3
0
def test_positive_update_with_manager_role(module_location, module_org):
    """Create template providing the initial name, then update its name
    with manager user role.

    :id: 28c4357a-93cb-4b01-a445-5db50435bcc0

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

    :CaseImportance: Medium

    :BZ: 1277308
    """
    new_name = gen_string('alpha')
    username = gen_string('alpha')
    password = gen_string('alpha')
    template = make_template(
        {'organization-ids': module_org.id, 'location-ids': module_location.id}
    )
    # Create user with Manager role
    user = entities.User(
        login=username,
        password=password,
        admin=False,
        organization=[module_org.id],
        location=[module_location.id],
    ).create()
    User.add_role({'id': user.id, 'role': "Manager"})
    # Update template name with that user
    Template.with_user(username=username, password=password).update(
        {'id': template['id'], 'name': new_name}
    )
    template = Template.info({'id': template['id']})
    assert new_name == template['name']
Esempio n. 4
0
    def test_positive_update_with_manager_role(self):
        """Create template providing the initial name, then update its name
        with manager user role.

        :id: 28c4357a-93cb-4b01-a445-5db50435bcc0

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

        :CaseImportance: Critical

        :BZ: 1277308
        """
        new_name = gen_string('alpha')
        username = gen_string('alpha')
        password = gen_string('alpha')
        org = make_org()
        loc = make_location()
        template = make_template({
            'organization-ids': org['id'], 'location-ids': loc['id']})
        # Create user with Manager role
        user = make_user({
            'login': username,
            'password': password,
            'admin': False,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        User.add_role({'id': user['id'], 'role': "Manager"})
        # Update template name with that user
        Template.with_user(username=username, password=password).update({
            'id': template['id'], 'name': new_name})
        template = Template.info({'id': template['id']})
        self.assertEqual(new_name, template['name'])
Esempio n. 5
0
    def test_delete_template_1(self):
        """
        @Test: Check if Template can be deleted
        @Feature: Template - Delete
        @Assert: Template is deleted
        @BZ: 1096333
        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        new_obj = make_template({
            'name': name,
            'content': content,
        })

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        Template.delete({'id': new_obj['id']})

        result = Template.info({'id': new_obj['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Esempio n. 6
0
    def test_update_template_1(self):
        """@Test: Check if Template can be updated

        @Feature: Template - Update

        @Assert: Template is updated

        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        try:
            new_obj = make_template(
                {
                    'name': name,
                    'content': content,
                }
            )
        except CLIFactoryError as e:
            self.fail(e)

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        updated_name = generate_string("alpha", 10)
        Template.update({'id': new_obj['id'], 'name': updated_name})
        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(updated_name, result.stdout['name'])
Esempio n. 7
0
    def test_add_operating_system_1(self):
        """@Test: Check if Template can be assigned operating system

        @Feature: Template - Add Operating System

        @Assert: Template has an operating system

        """

        content = gen_string("alpha", 10)
        name = gen_string("alpha", 10)

        try:
            new_template = make_template({
                'name': name,
                'content': content,
            })
            new_os = make_os()
        except CLIFactoryError as err:
            self.fail(err)

        result = Template.add_operatingsystem({
            "id": new_template["id"],
            "operatingsystem-id": new_os["id"],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_template['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, result.stdout['operating-systems'])
Esempio n. 8
0
    def test_delete_template_1(self):
        """@Test: Check if Template can be deleted

        @Feature: Template - Delete

        @Assert: Template is deleted

        @BZ: 1096333

        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        new_obj = make_template(
            {
                'name': name,
                'content': content,
            }
        )

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        Template.delete({'id': new_obj['id']})

        result = Template.info({'id': new_obj['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Esempio n. 9
0
def foreman_discovery(self):
    """Steps to Configure foreman discovery

    1. Build PXE default template
    2. Create Organization/Location
    3. Update Global parameters to set default org and location for
        discovered hosts.
    4. Enable auto_provision flag to perform discovery via discovery
        rules.
    """
    # Build PXE default template to get default PXE file
    Template.build_pxe_default()
    # let's just modify the timeouts to speed things up
    ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' "
                "/var/lib/tftpboot/pxelinux.cfg/default")
    ssh.command("sed -ie '/APPEND initrd/s/$/ fdi.countdown=1/' "
                "/var/lib/tftpboot/pxelinux.cfg/default")

    # Create Org and location
    org = make_org()
    loc = make_location()

    # Get default settings values
    default_discovery_loc = Settings.list(
        {'search': 'name=discovery_location'})[0]
    default_discovery_org = Settings.list(
        {'search': 'name=discovery_organization'})[0]
    default_discovery_auto = Settings.list({'search':
                                            'name=discovery_auto'})[0]

    # Update default org and location params to place discovered host
    Settings.set({'name': 'discovery_location', 'value': loc['name']})
    Settings.set({'name': 'discovery_organization', 'value': org['name']})

    # Enable flag to auto provision discovered hosts via discovery rules
    Settings.set({'name': 'discovery_auto', 'value': 'true'})

    # Flag which shows whether environment is fully configured for
    # discovered host provisioning.
    configured_env = configure_env_for_provision(org=org, loc=loc)
    yield {
        'default_discovery_auto': default_discovery_auto,
        'default_discovery_loc': default_discovery_loc,
        'default_discovery_org': default_discovery_org,
        'configured_env': configured_env,
    }
    # Restore default global setting's values
    Settings.set({
        'name': 'discovery_location',
        'value': default_discovery_loc['value']
    })
    Settings.set({
        'name': 'discovery_organization',
        'value': default_discovery_org['value']
    })
    Settings.set({
        'name': 'discovery_auto',
        'value': default_discovery_auto['value']
    })
Esempio n. 10
0
    def test_positive_import_force_locked_template(
            self, module_org, create_import_export_local_dir):
        """Assure locked templates are updated from repository when `force` is
        specified.

        :id: b80fbfc4-bcab-4a5d-b6c1-0e22906cd8ab

        :Steps:
            1. Import some of the locked template specifying the `force`
               parameter `false`.
            2. After ensuring the template is not updated, Import same locked template
               specifying the `force` parameter `true`.

        :expectedresults:
            1. Assert result is {'message': 'success'}
            2. With force - false, assert that locked template is not updated.
            3. With force - true, assert that the locked template is updated.

        :CaseImportance: Medium

        :CaseAutomation: NotAutomated
        """
        prefix = gen_string('alpha')
        _, dir_path = create_import_export_local_dir
        TemplateSync.imports({
            'repo': dir_path,
            'prefix': prefix,
            'organization-ids': module_org.id,
            'lock': 'true'
        })
        ptemplate = entities.ProvisioningTemplate().search(
            query={
                'per_page': 10,
                'search': f'name~{prefix}',
                'organization_id': module_org.id
            })
        if ptemplate:
            assert ptemplate[0].read().locked
            update_txt = 'updated a little'
            ssh.command(
                f"echo {update_txt} >> {dir_path}/example_template.erb")
            TemplateSync.imports({
                'repo': dir_path,
                'prefix': prefix,
                'organization-id': module_org.id
            })
            assert update_txt not in Template.dump(
                {'name': f'{prefix}example template'})
            TemplateSync.imports({
                'repo': dir_path,
                'prefix': prefix,
                'organization-id': module_org.id,
                'force': 'true',
            })
            assert update_txt in Template.dump(
                {'name': f'{prefix}example template'})
        else:
            pytest.fail('The template is not imported for force test')
Esempio n. 11
0
    def test_remove_operating_system_1(self):
        """@Test: Check if OS can be removed Template

        @Feature: Template - Remove Operating System

        @Assert: Template no longer has an operating system

        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        try:
            new_obj = make_template(
                {
                    'name': name,
                    'content': content,
                }
            )
            new_os = make_os()
        except CLIFactoryError as e:
            self.fail(e)

        result = Template.add_operatingsystem(
            {
                "id": new_obj["id"],
                "operatingsystem-id": new_os["id"]
            }
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = "%s %s.%s" % (
            new_os['name'], new_os['major'], new_os['minor']
        )
        self.assertIn(os_string, result.stdout['operating-systems'])

        result = Template.remove_operatingsystem(
            {
                "id": new_obj["id"],
                "operatingsystem-id": new_os["id"]
            }
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        os_string = "%s %s.%s" % (
            new_os['name'], new_os['major'], new_os['minor']
        )
        self.assertNotIn(os_string, result.stdout['operating-systems'])
Esempio n. 12
0
    def setUpClass(cls):
        """Steps to Configure foreman discovery

        1. Build PXE default template
        2. Create Organization/Location
        3. Update Global parameters to set default org and location for
           discovered hosts.
        4. Enable auto_provision flag to perform discovery via discovery
           rules.
        """
        super(DiscoveredTestCase, cls).setUpClass()

        # Build PXE default template to get default PXE file
        Template.build_pxe_default()
        # let's just modify the timeouts to speed things up
        ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' "
                    "/var/lib/tftpboot/pxelinux.cfg/default")
        ssh.command("sed -ie '/APPEND initrd/s/$/ fdi.countdown=1/' "
                    "/var/lib/tftpboot/pxelinux.cfg/default")

        # Create Org and location
        cls.org = make_org()
        cls.loc = make_location()

        # Get default settings values
        cls.default_discovery_loc = Settings.list(
            {'search': 'name=%s' % 'discovery_location'})[0]
        cls.default_discovery_org = Settings.list(
            {'search': 'name=%s' % 'discovery_organization'})[0]
        cls.default_discovery_auto = Settings.list(
            {'search': 'name=%s' % 'discovery_auto'})[0]

        # Update default org and location params to place discovered host
        Settings.set({'name': 'discovery_location', 'value': cls.loc['name']})
        Settings.set({
            'name': 'discovery_organization',
            'value': cls.org['name']
        })

        # Enable flag to auto provision discovered hosts via discovery rules
        Settings.set({'name': 'discovery_auto', 'value': 'true'})

        # Flag which shows whether environment is fully configured for
        # discovered host provisioning.
        cls.configured_env = False

        if bz_bug_is_open(1578290):
            ssh.command('mkdir /var/lib/tftpboot/boot/fdi-image')
            ssh.command('ln -s /var/lib/tftpboot/boot/'
                        'foreman-discovery-image-3.4.4-1.iso-vmlinuz'
                        ' /var/lib/tftpboot/boot/fdi-image/vmlinuz0')
            ssh.command('ln -s /var/lib/tftpboot/boot/'
                        'foreman-discovery-image-3.4.4-1.iso-img'
                        ' /var/lib/tftpboot/boot/fdi-image/initrd0.img')
            ssh.command('chown -R foreman-proxy /var/lib/tftpboot/boot/')
Esempio n. 13
0
    def test_positive_delete_by_id(self):
        """Check if Template can be deleted

        @Feature: Template - Delete

        @Assert: Template is deleted
        """
        template = make_template()
        Template.delete({'id': template['id']})
        with self.assertRaises(CLIReturnCodeError):
            Template.info({'id': template['id']})
Esempio n. 14
0
    def test_positive_delete_by_id(self):
        """Check if Template can be deleted

        @Feature: Template - Delete

        @Assert: Template is deleted
        """
        template = make_template()
        Template.delete({'id': template['id']})
        with self.assertRaises(CLIReturnCodeError):
            Template.info({'id': template['id']})
Esempio n. 15
0
    def test_positive_delete_by_id(self):
        """Check if Template can be deleted

        @id: 8e5245ee-13dd-44d4-8111-d4382cacf005

        @Assert: Template is deleted
        """
        template = make_template()
        Template.delete({'id': template['id']})
        with self.assertRaises(CLIReturnCodeError):
            Template.info({'id': template['id']})
Esempio n. 16
0
    def test_positive_update_name(self):
        """Check if Template can be updated

        @Feature: Template - Update

        @Assert: Template is updated
        """
        template = make_template()
        updated_name = gen_string("alpha")
        Template.update({"id": template["id"], "name": updated_name})
        template = Template.info({"id": template["id"]})
        self.assertEqual(updated_name, template["name"])
Esempio n. 17
0
    def setUpClass(cls):
        """Steps to Configure foreman discovery

        1. Build PXE default template
        2. Create Organization/Location
        3. Update Global parameters to set default org and location for
           discovered hosts.
        4. Enable auto_provision flag to perform discovery via discovery
           rules.
        """
        super(DiscoveredTestCase, cls).setUpClass()

        # Build PXE default template to get default PXE file
        Template.build_pxe_default()
        # let's just modify the timeouts to speed things up
        ssh.command("sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' "
                    "/var/lib/tftpboot/pxelinux.cfg/default")
        ssh.command("sed -ie '/APPEND initrd/s/$/ fdi.countdown=1/' "
                    "/var/lib/tftpboot/pxelinux.cfg/default")

        # Create Org and location
        cls.org = make_org()
        cls.loc = make_location()

        # Get default settings values
        cls.default_discovery_loc = Settings.list(
            {'search': 'name=%s' % 'discovery_location'})[0]
        cls.default_discovery_org = Settings.list(
            {'search': 'name=%s' % 'discovery_organization'})[0]
        cls.default_discovery_auto = Settings.list(
            {'search': 'name=%s' % 'discovery_auto'})[0]

        # Update default org and location params to place discovered host
        Settings.set({'name': 'discovery_location', 'value': cls.loc['name']})
        Settings.set(
            {'name': 'discovery_organization', 'value': cls.org['name']})

        # Enable flag to auto provision discovered hosts via discovery rules
        Settings.set({'name': 'discovery_auto', 'value': 'true'})

        # Flag which shows whether environment is fully configured for
        # discovered host provisioning.
        cls.configured_env = False

        if bz_bug_is_open(1578290):
            ssh.command('mkdir /var/lib/tftpboot/boot/fdi-image')
            ssh.command('ln -s /var/lib/tftpboot/boot/'
                        'foreman-discovery-image-3.4.4-1.iso-vmlinuz'
                        ' /var/lib/tftpboot/boot/fdi-image/vmlinuz0')
            ssh.command('ln -s /var/lib/tftpboot/boot/'
                        'foreman-discovery-image-3.4.4-1.iso-img'
                        ' /var/lib/tftpboot/boot/fdi-image/initrd0.img')
            ssh.command('chown -R foreman-proxy /var/lib/tftpboot/boot/')
Esempio n. 18
0
    def test_positive_delete_by_id(self):
        """Check if Template can be deleted

        :id: 8e5245ee-13dd-44d4-8111-d4382cacf005

        :expectedresults: Template is deleted

        :CaseImportance: Critical
        """
        template = make_template()
        Template.delete({'id': template['id']})
        with self.assertRaises(CLIReturnCodeError):
            Template.info({'id': template['id']})
Esempio n. 19
0
def test_positive_delete_by_id():
    """Check if Template can be deleted

    :id: 8e5245ee-13dd-44d4-8111-d4382cacf005

    :expectedresults: Template is deleted

    :CaseImportance: Critical
    """
    template = make_template()
    Template.delete({'id': template['id']})
    with pytest.raises(CLIReturnCodeError):
        Template.info({'id': template['id']})
Esempio n. 20
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @Feature: Template - Add Operating System

        @Assert: Operating system is added to the template
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({"id": new_template["id"], "operatingsystem-id": new_os["id"]})
        new_template = Template.info({"id": new_template["id"]})
        os_string = "{0} {1}.{2}".format(new_os["name"], new_os["major-version"], new_os["minor-version"])
        self.assertIn(os_string, new_template["operating-systems"])
Esempio n. 21
0
def test_positive_update_name():
    """Check if Template can be updated

    :id: 99bdab7b-1279-4349-a655-4294395ecbe1

    :expectedresults: Template is updated

    :CaseImportance: Critical
    """
    template = make_template()
    updated_name = gen_string('alpha')
    Template.update({'id': template['id'], 'name': updated_name})
    template = Template.info({'id': template['id']})
    assert updated_name == template['name']
Esempio n. 22
0
def test_positive_clone():
    """Assure ability to clone a provisioning template

    :id: 27d69c1e-0d83-4b99-8a3c-4f1bdec3d261

    :expectedresults: The template is cloned successfully

    :CaseLevel: Integration
    """
    cloned_template_name = gen_string('alpha')
    template = make_template()
    result = Template.clone({'id': template['id'], 'new-name': cloned_template_name})
    new_template = Template.info({'id': result[0]['id']})
    assert new_template['name'] == cloned_template_name
Esempio n. 23
0
    def test_positive_update_name(self):
        """Check if Template can be updated

        @Feature: Template - Update

        @Assert: Template is updated
        """
        template = make_template()
        updated_name = gen_string('alpha')
        Template.update({
            'id': template['id'],
            'name': updated_name,
        })
        template = Template.info({'id': template['id']})
        self.assertEqual(updated_name, template['name'])
Esempio n. 24
0
    def test_positive_update_name(self):
        """Check if Template can be updated

        @id: 99bdab7b-1279-4349-a655-4294395ecbe1

        @Assert: Template is updated
        """
        template = make_template()
        updated_name = gen_string('alpha')
        Template.update({
            'id': template['id'],
            'name': updated_name,
        })
        template = Template.info({'id': template['id']})
        self.assertEqual(updated_name, template['name'])
Esempio n. 25
0
    def test_positive_update_name(self):
        """Check if Template can be updated

        @Feature: Template - Update

        @Assert: Template is updated
        """
        template = make_template()
        updated_name = gen_string('alpha')
        Template.update({
            'id': template['id'],
            'name': updated_name,
        })
        template = Template.info({'id': template['id']})
        self.assertEqual(updated_name, template['name'])
Esempio n. 26
0
    def test_add_configtemplate(self):
        """@test: Add configtemplate to os

        @feature: Operating System - Add comfigtemplate

        @assert: Operating System is updated with config template

        """

        conf_obj = make_template()

        result = Template.info({'id': conf_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(conf_obj['name'], result.stdout['name'])

        new_obj = make_os()
        result = OperatingSys.add_config_template(
            {'id': new_obj['id'],
             'config-template': conf_obj['name']})
        self.assertEqual(result.return_code, 0, "Failed to add configtemplate")
        self.assertEqual(
            len(result.stderr), 0, "Should not have gotten an error")

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to find object")
        self.assertEqual(len(result.stdout['templates']), 1)
        template_name = result.stdout['templates'][0]
        self.assertTrue(template_name.startswith(conf_obj['name']))
Esempio n. 27
0
    def test_add_configtemplate(self):
        """@test: Add configtemplate to os

        @feature: Operating System - Add comfigtemplate

        @assert: Operating System is updated with config template

        """

        conf_obj = make_template()

        result = Template.info({'id': conf_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(conf_obj['name'], result.stdout['name'])

        new_obj = make_os()
        result = OperatingSys.add_config_template({
            'id':
            new_obj['id'],
            'config-template':
            conf_obj['name']
        })
        self.assertEqual(result.return_code, 0, "Failed to add configtemplate")
        self.assertEqual(len(result.stderr), 0,
                         "Should not have gotten an error")

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0, "Failed to find object")
        self.assertEqual(len(result.stdout['templates']), 1)
        template_name = result.stdout['templates'][0]
        self.assertTrue(template_name.startswith(conf_obj['name']))
Esempio n. 28
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @Feature: Template - Add Operating System

        @Assert: Operating system is added to the template
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 29
0
    def test_positive_clone(self):
        """Assure ability to clone a provisioning template

        :id: 27d69c1e-0d83-4b99-8a3c-4f1bdec3d261

        :expectedresults: The template is cloned successfully

        :CaseLevel: Integration
        """
        cloned_template_name = gen_string('alpha')
        template = make_template()
        result = Template.clone({
            'id': template['id'],
            'new-name': cloned_template_name,
        })
        new_template = Template.info({'id': result[0]['id']})
        self.assertEqual(new_template['name'], cloned_template_name)
Esempio n. 30
0
    def test_add_operating_system_1(self):
        """@Test: Check if Template can be assigned operating system

        @Feature: Template - Add Operating System

        @Assert: Template has an operating system
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 31
0
    def test_positive_clone(self):
        """Assure ability to clone a provisioning template

        @id: 27d69c1e-0d83-4b99-8a3c-4f1bdec3d261

        @Assert: The template is cloned successfully

        @CaseLevel: Integration
        """
        cloned_template_name = gen_string('alpha')
        template = make_template()
        result = Template.clone({
            'id': template['id'],
            'new-name': cloned_template_name,
        })
        new_template = Template.info({'id': result[0]['id']})
        self.assertEqual(new_template['name'], cloned_template_name)
Esempio n. 32
0
    def test_positive_update_name(self):
        """Check if Template can be updated

        :id: 99bdab7b-1279-4349-a655-4294395ecbe1

        :expectedresults: Template is updated

        :CaseImportance: Critical
        """
        template = make_template()
        updated_name = gen_string('alpha')
        Template.update({
            'id': template['id'],
            'name': updated_name,
        })
        template = Template.info({'id': template['id']})
        self.assertEqual(updated_name, template['name'])
Esempio n. 33
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @Feature: Template - Add Operating System

        @Assert: Operating system is added to the template
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(new_os['name'],
                                         new_os['major-version'],
                                         new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 34
0
def test_positive_add_os_by_id(module_os_with_minor):
    """Check if operating system can be added to a template

    :id: d9f481b3-9757-4208-b451-baf4792d4d70

    :expectedresults: Operating system is added to the template

    :CaseLevel: Integration
    """
    new_template = make_template()
    Template.add_operatingsystem(
        {'id': new_template['id'], 'operatingsystem-id': module_os_with_minor.id}
    )
    new_template = Template.info({'id': new_template['id']})
    os_string = (
        f'{module_os_with_minor.name} {module_os_with_minor.major}.{module_os_with_minor.minor}'
    )
    assert os_string in new_template['operating-systems']
Esempio n. 35
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        @id: d9f481b3-9757-4208-b451-baf4792d4d70

        @Assert: Operating system is added to the template

        @CaseLevel: Integration
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 36
0
    def test_positive_add_os_by_id(self):
        """Check if operating system can be added to a template

        :id: d9f481b3-9757-4208-b451-baf4792d4d70

        :expectedresults: Operating system is added to the template

        :CaseLevel: Integration
        """
        new_template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': new_template['id'],
            'operatingsystem-id': new_os['id'],
        })
        new_template = Template.info({'id': new_template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version'])
        self.assertIn(os_string, new_template['operating-systems'])
Esempio n. 37
0
    def setUpClass(cls):
        """Steps to Configure foreman discovery

        1. Build PXE default template
        2. Create Organization/Location
        3. Update Global parameters to set default org and location for
           discovered hosts.
        4. Enable auto_provision flag to perform discovery via discovery
           rules.
        """
        super(DiscoveredTestCase, cls).setUpClass()

        # Build PXE default template to get default PXE file
        Template.build_pxe_default()

        # Create Org and location
        cls.org = make_org()
        cls.loc = make_location()

        # Get default settings values
        cls.default_discovery_loc = Settings.list(
            {'search': 'name=%s' % 'discovery_location'})[0]
        cls.default_discovery_org = Settings.list(
            {'search': 'name=%s' % 'discovery_organization'})[0]
        cls.default_discovery_auto = Settings.list(
            {'search': 'name=%s' % 'discovery_auto'})[0]

        # Update default org and location params to place discovered host
        Settings.set({'name': 'discovery_location', 'value': cls.loc['name']})
        Settings.set({
            'name': 'discovery_organization',
            'value': cls.org['name']
        })

        # Enable flag to auto provision discovered hosts via discovery rules
        Settings.set({'name': 'discovery_auto', 'value': 'true'})

        # Flag which shows whether environment is fully configured for
        # discovered host provisioning.
        cls.configured_env = False
Esempio n. 38
0
def test_positive_remove_os_by_id(module_os_with_minor):
    """Check if operating system can be removed from a template

    :id: b5362565-6dce-4770-81e1-4fe3ec6f6cee

    :expectedresults: Operating system is removed from template

    :CaseLevel: Integration

    :CaseImportance: Medium

    :BZ: 1395229
    """
    template = make_template()
    Template.add_operatingsystem(
        {'id': template['id'], 'operatingsystem-id': module_os_with_minor.id}
    )
    template = Template.info({'id': template['id']})
    os_string = (
        f'{module_os_with_minor.name} {module_os_with_minor.major}.{module_os_with_minor.minor}'
    )
    assert os_string in template['operating-systems']
    Template.remove_operatingsystem(
        {'id': template['id'], 'operatingsystem-id': module_os_with_minor.id}
    )
    template = Template.info({'id': template['id']})
    assert os_string not in template['operating-systems']
Esempio n. 39
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        @id: b5362565-6dce-4770-81e1-4fe3ec6f6cee

        @Assert: Operating system is removed from template

        @CaseLevel: Integration
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 40
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        :id: b5362565-6dce-4770-81e1-4fe3ec6f6cee

        :expectedresults: Operating system is removed from template

        :CaseLevel: Integration
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 41
0
    def test_remove_operating_system_1(self):
        """@Test: Check if OS can be removed Template

        @Feature: Template - Remove Operating System

        @Assert: Template no longer has an operating system

        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 42
0
    def test_dump_template_1(self):
        """
        @Test: Check if Template can be created with specific content
        @Feature: Template - Create
        @Assert: Template is created with specific content
        """

        content = generate_string("alpha", 10)
        name = generate_string("alpha", 10)

        new_obj = make_template({
            'name': name,
            'content': content,
        })

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])

        template_content = Template.dump({'id': new_obj['id']})
        self.assertIn(content, template_content.stdout[0])
Esempio n. 43
0
    def test_positive_create_with_content(self):
        """Check if Template can be created with specific content

        @Feature: Template - Create

        @Assert: Template is created with specific content
        """
        content = gen_string("alpha")
        name = gen_string("alpha")
        template = make_template({"content": content, "name": name})
        self.assertEqual(template["name"], name)
        template_content = Template.dump({"id": template["id"]})
        self.assertIn(content, template_content[0])
Esempio n. 44
0
    def setUpClass(cls):
        """Steps to Configure foreman discovery

        1. Build PXE default template
        2. Create Organization/Location
        3. Update Global parameters to set default org and location for
           discovered hosts.
        4. Enable auto_provision flag to perform discovery via discovery
           rules.
        """
        super(DiscoveredTestCase, cls).setUpClass()

        # Build PXE default template to get default PXE file
        Template.build_pxe_default()

        # Create Org and location
        cls.org = make_org()
        cls.loc = make_location()

        # Get default settings values
        cls.default_discovery_loc = Settings.list(
            {'search': 'name=%s' % 'discovery_location'})[0]
        cls.default_discovery_org = Settings.list(
            {'search': 'name=%s' % 'discovery_organization'})[0]
        cls.default_discovery_auto = Settings.list(
            {'search': 'name=%s' % 'discovery_auto'})[0]

        # Update default org and location params to place discovered host
        Settings.set({'name': 'discovery_location', 'value': cls.loc['name']})
        Settings.set(
            {'name': 'discovery_organization', 'value': cls.org['name']})

        # Enable flag to auto provision discovered hosts via discovery rules
        Settings.set({'name': 'discovery_auto', 'value': 'true'})

        # Flag which shows whether environment is fully configured for
        # discovered host provisioning.
        cls.configured_env = False
Esempio n. 45
0
def test_positive_create_with_content():
    """Check if Template can be created with specific content

    :id: 0fcfc46d-5e97-4451-936a-e8684acac275

    :expectedresults: Template is created with specific content

    :CaseImportance: Critical
    """
    content = gen_string('alpha')
    name = gen_string('alpha')
    template = make_template({'content': content, 'name': name})
    assert template['name'] == name
    template_content = Template.dump({'id': template['id']})
    assert content in template_content[0]
Esempio n. 46
0
    def test_positive_create_with_content(self):
        """Check if Template can be created with specific content

        @id: 0fcfc46d-5e97-4451-936a-e8684acac275

        @Assert: Template is created with specific content
        """
        content = gen_string('alpha')
        name = gen_string('alpha')
        template = make_template({
            'content': content,
            'name': name,
        })
        self.assertEqual(template['name'], name)
        template_content = Template.dump({'id': template['id']})
        self.assertIn(content, template_content[0])
Esempio n. 47
0
    def test_positive_create_with_content(self):
        """Check if Template can be created with specific content

        @Feature: Template - Create

        @Assert: Template is created with specific content
        """
        content = gen_string('alpha')
        name = gen_string('alpha')
        template = make_template({
            'content': content,
            'name': name,
        })
        self.assertEqual(template['name'], name)
        template_content = Template.dump({'id': template['id']})
        self.assertIn(content, template_content[0])
Esempio n. 48
0
    def test_positive_create_with_content(self):
        """Check if Template can be created with specific content

        @Feature: Template - Create

        @Assert: Template is created with specific content
        """
        content = gen_string('alpha')
        name = gen_string('alpha')
        template = make_template({
            'content': content,
            'name': name,
        })
        self.assertEqual(template['name'], name)
        template_content = Template.dump({'id': template['id']})
        self.assertIn(content, template_content[0])
Esempio n. 49
0
    def test_create_template_1(self):
        """
        @Test: Check if Template can be created
        @Feature: Template - Create
        @Assert: Template is created
        """

        content = generate_name()
        name = generate_name(6)

        new_obj = make_template(
            {
                'name': name,
                'content': content,
            }
        )

        result = Template.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertEqual(new_obj['name'], result.stdout['name'])
Esempio n. 50
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        @Feature: Template - Remove Operating System

        @Assert: Operating system is removed from template
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({"id": template["id"], "operatingsystem-id": new_os["id"]})
        template = Template.info({"id": template["id"]})
        os_string = "{0} {1}.{2}".format(new_os["name"], new_os["major-version"], new_os["minor-version"])
        self.assertIn(os_string, template["operating-systems"])
        Template.remove_operatingsystem({"id": template["id"], "operatingsystem-id": new_os["id"]})
        template = Template.info({"id": template["id"]})
        self.assertNotIn(os_string, template["operating-systems"])
Esempio n. 51
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        @Feature: Template - Remove Operating System

        @Assert: Operating system is removed from template
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(new_os['name'],
                                         new_os['major-version'],
                                         new_os['minor-version'])
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 52
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        @Feature: Template - Remove Operating System

        @Assert: Operating system is removed from template
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id'],
        })
        template = Template.info({'id': template['id']})
        os_string = '{0} {1}.{2}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({
            'id': template['id'],
            'operatingsystem-id': new_os['id']
        })
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 53
0
    def test_positive_remove_os_by_id(self):
        """Check if operating system can be removed from a template

        :id: b5362565-6dce-4770-81e1-4fe3ec6f6cee

        :expectedresults: Operating system is removed from template

        :CaseLevel: Integration

        :CaseImportance: Medium

        :BZ: 1395229
        """
        template = make_template()
        new_os = make_os()
        Template.add_operatingsystem({'id': template['id'], 'operatingsystem-id': new_os['id']})
        template = Template.info({'id': template['id']})
        os_string = '{} {}.{}'.format(
            new_os['name'], new_os['major-version'], new_os['minor-version']
        )
        self.assertIn(os_string, template['operating-systems'])
        Template.remove_operatingsystem({'id': template['id'], 'operatingsystem-id': new_os['id']})
        template = Template.info({'id': template['id']})
        self.assertNotIn(os_string, template['operating-systems'])
Esempio n. 54
0
 def _cleanup():
     if Template.exists(search=('name', template['name'])):
         Template.delete(options={'id': template['id']})