Example #1
0
    def test_bugzilla_1203457(self):
        """@test: Create an OS pointing to an arch, medium and partition table.

        @feature: Operating System - Create

        @assert: An operating system is created.

        @bz: 1203457, 1200116

        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(
            operating_system['architectures'][0], architecture['name'])
        self.assertEqual(
            operating_system['installation-media'][0], medium['name'])
        self.assertEqual(
            operating_system['partition-tables'][0], ptable['name'])
    def test_positive_create_with_arch_medium_ptable(self):
        """Create an OS pointing to an arch, medium and partition table.

        @id: 05bdb2c6-0d2e-4141-9e07-3ada3933b577

        @assert: An operating system is created.
        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(
            operating_system['architectures'][0], architecture['name'])
        self.assertEqual(
            operating_system['installation-media'][0], medium['name'])
        self.assertEqual(
            operating_system['partition-tables'][0], ptable['name'])
Example #3
0
    def test_add_architecture(self):
        """@test: Add Architecture to os

        @feature: Operating System - Add architecture

        @assert: Operating System is updated with architecture

        """

        a_ob = make_architecture()

        result = Architecture.info({'id': a_ob['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(
            len(result.stderr), 0, "There should not be an exception here")

        new_obj = make_os()
        result = OperatingSys.add_architecture({'id': new_obj['id'],
                                                'architecture-id': a_ob['id']})
        self.assertEqual(result.return_code, 0, "Failed to add architecture")
        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['architectures']), 1)
        self.assertEqual(a_ob['name'], result.stdout['architectures'][0])
Example #4
0
    def test_negative_update_os(self):
        """A host can not be updated with a operating system, which is
        not associated with host's medium

        @id: ff13d2af-e54a-4daf-a24d-7ec930b4fbbe

        @assert: A host is not updated

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        new_os = make_os({
            'architectures':
            new_arch['name'],
            'partition-tables':
            self.host['operating-system']['partition-table'],
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
                'operatingsystem': new_os['title'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(self.host['operating-system']['operating-system'],
                            new_os['title'])
Example #5
0
    def test_positive_update_arch_by_id(self):
        """A host can be updated with a new architecture. Use entities
        ids for association

        @id: a4546fd6-997a-44e4-853a-eac235ea87b0

        @assert: A host is updated and the architecture matches

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location-id':
            self.host_args.location.id,
            'organization-id':
            self.host_args.organization.id,
        })
        OperatingSys.add_architecture({
            'architecture-id': new_arch['id'],
            'id': self.host_args.operatingsystem.id,
        })
        Host.update({
            'architecture-id': new_arch['id'],
            'id': self.host['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['operating-system']['architecture'],
                         new_arch['name'])
Example #6
0
    def test_positive_update_arch_by_id(self):
        """A host can be updated with a new architecture. Use entities
        ids for association

        @id: a4546fd6-997a-44e4-853a-eac235ea87b0

        @assert: A host is updated and the architecture matches

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location-id': self.host_args.location.id,
            'organization-id': self.host_args.organization.id,
        })
        OperatingSys.add_architecture({
            'architecture-id': new_arch['id'],
            'id': self.host_args.operatingsystem.id,
        })
        Host.update({
            'architecture-id': new_arch['id'],
            'id': self.host['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(
            self.host['operating-system']['architecture'], new_arch['name'])
Example #7
0
    def test_bugzilla_1203457(self):
        """@test: Create an OS pointing to an arch, medium and partition table.

        @feature: Operating System - Create

        @assert: An operating system is created.

        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        result = OperatingSys.info({'id': operating_system['id']})
        self.assertEqual(result.return_code, 0)
        stdout = result.stdout
        for attr in (
                'architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(stdout[attr]), 1)
        self.assertEqual(stdout['architectures'][0], architecture['name'])
        self.assertEqual(stdout['installation-media'][0], medium['name'])
        self.assertEqual(stdout['partition-tables'][0], ptable['name'])
Example #8
0
    def test_positive_create_with_arch_medium_ptable(self):
        """Create an OS pointing to an arch, medium and partition table.

        @feature: Operating System

        @assert: An operating system is created.
        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os({
            u'architecture-ids': architecture['id'],
            u'medium-ids': medium['id'],
            u'partition-table-ids': ptable['id'],
        })

        for attr in ('architectures', 'installation-media',
                     'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(operating_system['architectures'][0],
                         architecture['name'])
        self.assertEqual(operating_system['installation-media'][0],
                         medium['name'])
        self.assertEqual(operating_system['partition-tables'][0],
                         ptable['name'])
Example #9
0
    def test_positive_update_arch_by_name(self):
        """A host can be updated with a new architecture. Use entities
        names for association

        @id: 92da3782-47db-4701-aaab-3ea974043d20

        @assert: A host is updated and the architecture matches

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        OperatingSys.add_architecture({
            'architecture': new_arch['name'],
            'title': self.host_args.operatingsystem.title,
        })
        Host.update({
            'architecture': new_arch['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(
            self.host['operating-system']['architecture'], new_arch['name'])
Example #10
0
    def test_negative_update_os(self):
        """A host can not be updated with a operating system, which is
        not associated with host's medium

        @id: ff13d2af-e54a-4daf-a24d-7ec930b4fbbe

        @assert: A host is not updated

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        new_os = make_os({
            'architectures': new_arch['name'],
            'partition-tables': self.host[
                'operating-system']['partition-table'],
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
                'operatingsystem': new_os['title'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Example #11
0
    def test_positive_update_arch_by_name(self):
        """A host can be updated with a new architecture. Use entities
        names for association

        @feature: Hosts

        @assert: A host is updated and the architecture matches
        """
        new_arch = make_architecture({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        OperatingSys.add_architecture({
            'architecture':
            new_arch['name'],
            'title':
            self.host_args.operatingsystem.title,
        })
        Host.update({
            'architecture': new_arch['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['architecture'], new_arch['name'])
    def test_positive_create_with_arch_medium_ptable(self):
        """Create an OS pointing to an arch, medium and partition table.

        :id: 05bdb2c6-0d2e-4141-9e07-3ada3933b577

        :expectedresults: An operating system is created.

        :CaseImportance: Critical
        """
        architecture = make_architecture()
        medium = make_medium()
        ptable = make_partition_table()
        operating_system = make_os(
            {
                'architecture-ids': architecture['id'],
                'medium-ids': medium['id'],
                'partition-table-ids': ptable['id'],
            }
        )

        for attr in ('architectures', 'installation-media', 'partition-tables'):
            self.assertEqual(len(operating_system[attr]), 1)
        self.assertEqual(operating_system['architectures'][0], architecture['name'])
        self.assertEqual(operating_system['installation-media'][0], medium['name'])
        self.assertEqual(operating_system['partition-tables'][0], ptable['name'])
Example #13
0
    def test_add_architecture(self):
        """@test: Add Architecture to os

        @feature: Operating System - Add architecture

        @assert: Operating System is updated with architecture

        """

        a_ob = make_architecture()

        result = Architecture.info({'id': a_ob['id']})
        self.assertEqual(result.return_code, 0, "Failed to create object")
        self.assertEqual(len(result.stderr), 0,
                         "There should not be an exception here")

        new_obj = make_os()
        result = OperatingSys.add_architecture({
            'id': new_obj['id'],
            'architecture-id': a_ob['id']
        })
        self.assertEqual(result.return_code, 0, "Failed to add architecture")
        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['architectures']), 1)
        self.assertEqual(a_ob['name'], result.stdout['architectures'][0])
Example #14
0
    def test_positive_update_arch_by_name(self):
        """A host can be updated with a new architecture. Use entities
        names for association

        @id: 92da3782-47db-4701-aaab-3ea974043d20

        @assert: A host is updated and the architecture matches

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        OperatingSys.add_architecture({
            'architecture':
            new_arch['name'],
            'title':
            self.host_args.operatingsystem.title,
        })
        Host.update({
            'architecture': new_arch['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['operating-system']['architecture'],
                         new_arch['name'])
Example #15
0
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        @Feature: Architecture

        @Assert: Architecture is created.
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        @id: a3955346-cfc0-428d-8871-a10386fe7c59

        @Assert: Architecture is created.
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        @id: a3955346-cfc0-428d-8871-a10386fe7c59

        @Assert: Architecture is created.
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
Example #18
0
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        @Feature: Architecture

        @Assert: Architecture is created.
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
Example #19
0
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        :id: a3955346-cfc0-428d-8871-a10386fe7c59

        :expectedresults: Architecture is created.

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
Example #20
0
    def test_positive_create_with_name(self):
        """Successfully creates an Architecture.

        :id: a3955346-cfc0-428d-8871-a10386fe7c59

        :expectedresults: Architecture is created.

        :CaseImportance: Critical
        """
        for name in valid_data_list().values():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                self.assertEqual(architecture['name'], name)
    def test_positive_delete_by_id(self):
        """Create Architecture with valid values then delete it
        by ID

        @id: df699e29-29a3-417a-a6ee-81e74b7211a4

        @assert: Architecture is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                Architecture.delete({'id': architecture['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Architecture.info({'id': architecture['id']})
Example #22
0
    def test_positive_generate_report_sanitized(self):
        """Generate report template where there are values in comma outputted
        which might brake CSV format

        :id: 84b577db-144e-4961-a42e-e93887464986

        :setup: User with reporting access rights, Host Statuses report,
                a host with OS that has comma in its name

        :steps:

            1. hammer report-template generate ...

        :expectedresults: Report is generated in proper CSV format (value with comma is quoted)

        :CaseImportance: Medium
        """
        os_name = gen_string('alpha') + "," + gen_string('alpha')
        architecture = make_architecture()
        partition_table = make_partition_table()
        medium = make_medium()
        os = make_os({
            'name': os_name,
            'architecture-ids': architecture['id'],
            'medium-ids': medium['id'],
            'partition-table-ids': partition_table['id'],
        })

        host_name = gen_string('alpha')
        host = make_fake_host({
            'name': host_name,
            'architecture-id': architecture['id'],
            'medium-id': medium['id'],
            'operatingsystem-id': os['id'],
            'partition-table-id': partition_table['id']
        })

        report_template = make_report_template({
            'content': REPORT_TEMPLATE_FILE,
        })

        result = ReportTemplate.generate({
            'name': report_template['name'],
        })
        self.assertIn('Name,Operating System',
                      result)  # verify header of custom template
        self.assertIn(
            '{0},"{1}"'.format(host['name'],
                               host['operating-system']['operating-system']),
            result)
Example #23
0
    def test_positive_delete_by_id(self):
        """Create Architecture with valid values then delete it
        by ID

        @feature: Architecture

        @assert: Architecture is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                Architecture.delete({'id': architecture['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Architecture.info({'id': architecture['id']})
Example #24
0
    def test_positive_create_1(self):
        """@test: A host can be created with a random name

        @feature: Hosts

        @assert: A host is created and the name matches

        """
        # Use the default installation smart proxy
        result = Proxy.list()
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(len(result.stdout), 0)
        puppet_proxy = result.stdout[0]

        host_name = gen_string(str_type='alpha', length=gen_integer(1, 10))

        try:
            # Creating dependent objects
            architecture = make_architecture()
            domain = make_domain()
            environment = make_environment()
            location = make_location()
            medium = make_medium()
            ptable = make_partition_table()
            organization = make_org(cached=True)
            os = make_os({
                u'architecture-ids': architecture['id'],
                u'medium-ids': medium['id'],
                u'ptable-ids': ptable['id'],
            })

            host = make_host({
                u'architecture-id': architecture['id'],
                u'domain-id': domain['id'],
                u'environment-id': environment['id'],
                u'location-id': location['id'],
                u'medium-id': medium['id'],
                u'name': host_name,
                u'operatingsystem-id': os['id'],
                u'organization-id': organization['id'],
                u'partition-table-id': ptable['id'],
                u'puppet-proxy-id': puppet_proxy['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)

        name = '{0}.{1}'.format(host_name, domain['name']).lower()
        self.assertEqual(host['name'], name)
Example #25
0
    def test_positive_create_1(self):
        """@test: A host can be created with a random name

        @feature: Hosts

        @assert: A host is created and the name matches

        """
        # Use the default installation smart proxy
        result = Proxy.list()
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertGreater(len(result.stdout), 0)
        puppet_proxy = result.stdout[0]

        host_name = gen_string(str_type='alpha', length=gen_integer(1, 10))

        try:
            # Creating dependent objects
            architecture = make_architecture()
            domain = make_domain()
            environment = make_environment()
            location = make_location()
            medium = make_medium()
            ptable = make_partition_table()
            organization = make_org(cached=True)
            os = make_os({
                u'architecture-ids': architecture['id'],
                u'medium-ids': medium['id'],
                u'partition-table-ids': ptable['id'],
            })

            host = make_host({
                u'architecture-id': architecture['id'],
                u'domain-id': domain['id'],
                u'environment-id': environment['id'],
                u'location-id': location['id'],
                u'medium-id': medium['id'],
                u'name': host_name,
                u'operatingsystem-id': os['id'],
                u'organization-id': organization['id'],
                u'partition-table-id': ptable['id'],
                u'puppet-proxy-id': puppet_proxy['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)

        name = '{0}.{1}'.format(host_name, domain['name']).lower()
        self.assertEqual(host['name'], name)
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        :id: 99add22d-d936-4232-9441-beff85867040

        :expectedresults: Architecture is added to Operating System

        :CaseLevel: Integration
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({'architecture-id': architecture['id'], 'id': os['id']})
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
Example #27
0
    def test_positive_delete_by_id(self):
        """Create Architecture with valid values then delete it
        by ID

        :id: df699e29-29a3-417a-a6ee-81e74b7211a4

        :expectedresults: Architecture is deleted

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                architecture = make_architecture({'name': name})
                Architecture.delete({'id': architecture['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Architecture.info({'id': architecture['id']})
Example #28
0
    def test_positive_add_arch(self):
        """@test: Add Architecture to operating system

        @feature: Operating System

        @assert: Architecture is added to Operating System
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
Example #29
0
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        @feature: Operating System

        @assert: Architecture is added to Operating System
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
    def test_positive_update_name(self):
        """Successfully update an Architecture.

        @id: 67f1e60b-29e2-44a4-8019-498e5ad0e201

        @Assert: Architecture is updated.
        """
        architecture = make_architecture()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Architecture.update({
                    'id': architecture['id'],
                    'new-name': new_name,
                })
                architecture = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], new_name)
Example #31
0
    def test_positive_update_name(self):
        """Successfully update an Architecture.

        @Feature: Architecture

        @Assert: Architecture is updated.
        """
        architecture = make_architecture()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Architecture.update({
                    'id': architecture['id'],
                    'new-name': new_name,
                })
                architecture = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], new_name)
Example #32
0
    def test_positive_update_name(self):
        """Successfully update an Architecture.

        @Feature: Architecture

        @Assert: Architecture is updated.
        """
        architecture = make_architecture()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Architecture.update({
                    'id': architecture['id'],
                    'new-name': new_name,
                })
                architecture = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], new_name)
    def test_positive_update_name(self):
        """Successfully update an Architecture.

        @id: 67f1e60b-29e2-44a4-8019-498e5ad0e201

        @Assert: Architecture is updated.
        """
        architecture = make_architecture()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Architecture.update({
                    'id': architecture['id'],
                    'new-name': new_name,
                })
                architecture = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], new_name)
Example #34
0
    def test_add_architecture(self):
        """@test: Add Architecture to os

        @feature: Operating System - Add architecture

        @assert: Operating System is updated with architecture

        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
Example #35
0
    def test_negative_update_name(self):
        """Create Architecture then fail to update its name

        @feature: Architecture

        @assert: Architecture name is not updated
        """
        architecture = make_architecture()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Architecture.update({
                        'id': architecture['id'],
                        'new-name': new_name,
                    })
                result = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], result['name'])
Example #36
0
    def test_negative_update_name(self):
        """Create Architecture then fail to update its name

        @feature: Architecture

        @assert: Architecture name is not updated
        """
        architecture = make_architecture()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError):
                    Architecture.update({
                        'id': architecture['id'],
                        'new-name': new_name,
                    })
                result = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], result['name'])
    def test_positive_add_arch(self):
        """Add Architecture to operating system

        @id: 99add22d-d936-4232-9441-beff85867040

        @assert: Architecture is added to Operating System

        @CaseLevel: Integration
        """
        architecture = make_architecture()
        os = make_os()
        OperatingSys.add_architecture({
            'architecture-id': architecture['id'],
            'id': os['id'],
        })
        os = OperatingSys.info({'id': os['id']})
        self.assertEqual(len(os['architectures']), 1)
        self.assertEqual(architecture['name'], os['architectures'][0])
Example #38
0
    def test_positive_update_name(self):
        """Successfully update an Architecture.

        :id: 67f1e60b-29e2-44a4-8019-498e5ad0e201

        :expectedresults: Architecture is updated.

        :CaseImportance: Critical
        """
        architecture = make_architecture()
        for new_name in valid_data_list().values():
            with self.subTest(new_name):
                Architecture.update({
                    'id': architecture['id'],
                    'new-name': new_name
                })
                architecture = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], new_name)
    def test_negative_update_name(self):
        """Create Architecture then fail to update its name

        @id: 037c4892-5e62-46dd-a2ed-92243e870e40

        @assert: Architecture name is not updated
        """
        architecture = make_architecture()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError) as raise_ctx:
                    Architecture.update({
                        'id': architecture['id'],
                        'new-name': new_name,
                    })
                self.assert_error_msg(raise_ctx,
                                      u'Could not update the architecture:')
                result = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], result['name'])
Example #40
0
    def test_negative_update_arch(self):
        """A host can not be updated with a architecture, which does not
        belong to host's operating system

        @feature: Hosts

        @assert: A host is not updated
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(self.host['architecture'], new_arch['name'])
    def test_negative_update_name(self):
        """Create Architecture then fail to update its name

        @id: 037c4892-5e62-46dd-a2ed-92243e870e40

        @assert: Architecture name is not updated
        """
        architecture = make_architecture()
        for new_name in invalid_values_list():
            with self.subTest(new_name):
                with self.assertRaises(CLIReturnCodeError) as raise_ctx:
                    Architecture.update({
                        'id': architecture['id'],
                        'new-name': new_name,
                    })
                self.assert_error_msg(raise_ctx,
                                      u'Could not update the architecture:')
                result = Architecture.info({'id': architecture['id']})
                self.assertEqual(architecture['name'], result['name'])
Example #42
0
def test_positive_generate_report_sanitized():
    """Generate report template where there are values in comma outputted
    which might brake CSV format

    :id: 84b577db-144e-4961-a42e-e93887464986

    :setup: User with reporting access rights, Host Statuses report,
            a host with OS that has comma in its name

    :steps:

        1. hammer report-template generate ...

    :expectedresults: Report is generated in proper CSV format (value with comma is quoted)

    :CaseImportance: Medium
    """
    # create a name that has a comma in it, some randomized text, and no spaces.
    os_name = gen_alpha(start='test', separator=',').replace(' ', '')
    architecture = make_architecture()
    partition_table = make_partition_table()
    medium = make_medium()
    os = make_os({
        'name': os_name,
        'architecture-ids': architecture['id'],
        'medium-ids': medium['id'],
        'partition-table-ids': partition_table['id'],
    })

    host_name = gen_alpha()
    host = make_fake_host({
        'name': host_name,
        'architecture-id': architecture['id'],
        'medium-id': medium['id'],
        'operatingsystem-id': os['id'],
        'partition-table-id': partition_table['id'],
    })

    report_template = make_report_template({'content': REPORT_TEMPLATE_FILE})

    result = ReportTemplate.generate({'name': report_template['name']})
    assert 'Name,Operating System' in result  # verify header of custom template
    assert f'{host["name"]},"{host["operating-system"]["operating-system"]}"' in result
Example #43
0
    def test_negative_update(self, data):
        """@test: Create architecture then fail to update
        its name

        @feature: Architecture

        @assert: architecture name is not updated

        """
        try:
            new_obj = make_architecture()
        except CLIFactoryError as err:
            self.fail(err)

        # Update the architecture name
        result = Architecture.update({
            'id': new_obj['id'],
            'new-name': data,
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Example #44
0
    def test_positive_CRUD(self):
        """Create a new Architecture, update the name and delete the Architecture itself.

        :id: cd8654b8-e603-11ea-adc1-0242ac120002

        :expectedresults: Architecture is created, modified and deleted successfully

        :CaseImportance: Critical
        """

        name = gen_choice(list(valid_data_list().values()))
        new_name = gen_choice(list(valid_data_list().values()))

        architecture = make_architecture({'name': name})
        assert architecture['name'] == name
        Architecture.update({'id': architecture['id'], 'new-name': new_name})
        architecture = Architecture.info({'id': architecture['id']})
        assert architecture['name'] == new_name
        Architecture.delete({'id': architecture['id']})
        with pytest.raises(CLIReturnCodeError):
            Architecture.info({'id': architecture['id']})
Example #45
0
    def test_negative_update_arch(self):
        """A host can not be updated with a architecture, which does not
        belong to host's operating system

        @feature: Hosts

        @assert: A host is not updated
        """
        new_arch = make_architecture({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(self.host['architecture'], new_arch['name'])
Example #46
0
    def test_negative_update(self, data):
        """@test: Create architecture then fail to update
        its name

        @feature: Architecture

        @assert: architecture name is not updated

        """
        try:
            new_obj = make_architecture()
        except CLIFactoryError as err:
            self.fail(err)

        # Update the architecture name
        result = Architecture.update({
            'id': new_obj['id'],
            'new-name': data,
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Example #47
0
    def test_negative_update_arch(self):
        """A host can not be updated with a architecture, which does not
        belong to host's operating system

        @id: a86524da-8caf-472b-9a3d-17a4385c3a18

        @assert: A host is not updated

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(
            self.host['operating-system']['architecture'], new_arch['name'])
Example #48
0
    def test_positive_update_arch_by_name(self):
        """A host can be updated with a new architecture. Use entities
        names for association

        @feature: Hosts

        @assert: A host is updated and the architecture matches
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        OperatingSys.add_architecture({
            'architecture': new_arch['name'],
            'title': self.host_args.operatingsystem.title,
        })
        Host.update({
            'architecture': new_arch['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['architecture'], new_arch['name'])
Example #49
0
    def test_negative_update_arch(self):
        """A host can not be updated with a architecture, which does not
        belong to host's operating system

        @id: a86524da-8caf-472b-9a3d-17a4385c3a18

        @assert: A host is not updated

        @CaseLevel: Integration
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(
            self.host['operating-system']['architecture'], new_arch['name'])
Example #50
0
    def test_add_architecture(self):
        """@test: Add Architecture to os

        @feature: Operating System - Add architecture

        @assert: Operating System is updated with architecture

        """
        architecture = make_architecture()
        new_obj = make_os()

        result = OperatingSys.add_architecture({
            'id': new_obj['id'],
            'architecture-id': architecture['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = OperatingSys.info({'id': new_obj['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stdout['architectures']), 1)
        self.assertEqual(
            architecture['name'], result.stdout['architectures'][0])
Example #51
0
    def test_positive_delete(self, data):
        """@test: Create architecture with valid values then delete it
        by ID

        @feature: Architecture

        @assert: architecture is deleted

        """
        try:
            new_obj = make_architecture({'name': data})
        except CLIFactoryError as err:
            self.fail(err)

        return_value = Architecture.delete({'id': new_obj['id']})
        self.assertEqual(return_value.return_code, 0)
        self.assertEqual(len(return_value.stderr), 0)

        # Can we find the object?
        result = Architecture.info({'id': new_obj['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
        self.assertEqual(len(result.stdout), 0)
Example #52
0
    def test_positive_delete(self, data):
        """@test: Create architecture with valid values then delete it
        by ID

        @feature: Architecture

        @assert: architecture is deleted

        """
        try:
            new_obj = make_architecture({'name': data})
        except CLIFactoryError as err:
            self.fail(err)

        return_value = Architecture.delete({'id': new_obj['id']})
        self.assertEqual(return_value.return_code, 0)
        self.assertEqual(len(return_value.stderr), 0)

        # Can we find the object?
        result = Architecture.info({'id': new_obj['id']})
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
        self.assertEqual(len(result.stdout), 0)
Example #53
0
    def test_negative_update_os(self):
        """@test: A host can not be updated with a operating system, which is
        not associated with host's medium

        @feature: Hosts

        @assert: A host is not updated
        """
        new_arch = make_architecture({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        new_os = make_os({
            'architectures': new_arch['name'],
            'partition-tables': self.host['partition-table'],
        })
        with self.assertRaises(CLIReturnCodeError):
            Host.update({
                'architecture': new_arch['name'],
                'id': self.host['id'],
                'operatingsystem': new_os['title'],
            })
        self.host = Host.info({'id': self.host['id']})
        self.assertNotEqual(self.host['operating-system'], new_os['title'])
Example #54
0
    def test_positive_create_with_multiple_entities(self):
        """Check if hostgroup with multiple options can be created

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        puppet_proxy = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })

        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy-id': puppet_proxy['id'],
            'puppet-ca-proxy-id': puppet_proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        # If bug is open provide LCE id as parameter
        # because LCE name cause errors
        if bz_bug_is_open(1395254):
            make_hostgroup_params.pop('lifecycle-environment')
            make_hostgroup_params['lifecycle-environment-id'] = lce['id']

        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['environment'])
        self.assertEqual(
            puppet_proxy['id'], hostgroup['puppet-master-proxy-id']
        )
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
        self.assertEqual(domain['name'], hostgroup['domain'])
        self.assertEqual(subnet['name'], hostgroup['subnet'])
        self.assertEqual(arch['name'], hostgroup['architecture'])
        self.assertEqual(ptable['name'], hostgroup['partition-table'])
        self.assertEqual(media['name'], hostgroup['medium'])
        self.assertEqual(
            "{0} {1}.{2}".format(
                os['name'],
                os['major-version'],
                os['minor-version']
            ),
            hostgroup['operating-system']
        )
        if not bz_bug_is_open('1313056'):
            self.assertEqual(cv['name'], hostgroup['content-view'])
            self.assertEqual(
                lce['name'], hostgroup['lifecycle-environment']
            )
Example #55
0
    def test_positive_create_with_multiple_entities_and_delete(self):
        """Check if hostgroup with multiple options can be created and deleted

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created, has all defined
            entities assigned and deleted

        :BZ: 1395254, 1313056

        :CaseLevel: Integration

        :CaseImportance: Critical
        """
        # Common entities
        name = valid_hostgroups_list()[0]
        loc = make_location()
        org = make_org()
        orgs = [org, self.org]
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id']
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id']
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id']
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'name': name,
            'organization-ids': [org['id'] for org in orgs],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': self.content_source['name'],
            'puppet-ca-proxy': self.content_source['name'],
            'content-source-id': self.content_source['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'puppet-classes': self.puppet_classes[0]['name'],
            'query-organization': org['name'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(hostgroup['name'], name)
        self.assertEqual(set(org['name'] for org in orgs),
                         set(hostgroup['organizations']))
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-master-proxy'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['content-source']['name'])
        self.assertIn(self.puppet_classes[0]['name'],
                      hostgroup['puppetclasses'])
        # delete hostgroup
        HostGroup.delete({'id': hostgroup['id']})
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.info({'id': hostgroup['id']})
    def test_positive_create_with_multiple_entities_name(self):
        """Check if hostgroup with multiple options name can be created

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        os_full_name = "{0} {1}.{2}".format(
            os['name'],
            os['major-version'],
            os['minor-version']
        )
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'organizations': org['name'],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': proxy['name'],
            'puppet-ca-proxy': proxy['name'],
            'content-source-id': proxy['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem':  os_full_name,
            'query-organization': org['name']
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy-id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy-id'])
        self.assertEqual(domain['name'], hostgroup['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'], hostgroup['architecture'])
        self.assertEqual(ptable['name'], hostgroup['partition-table'])
        self.assertEqual(media['name'], hostgroup['medium'])
        self.assertEqual(os_full_name, hostgroup['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(
            lce['name'], hostgroup['lifecycle-environment']['name'])
        self.assertEqual(proxy['name'], hostgroup['content-source']['name'])
Example #57
0
 def class_architecture(self):
     """Shared architecture for tests"""
     return make_architecture()
Example #58
0
    def test_positive_create_with_multiple_entities_ids(self):
        """Check if hostgroup with multiple options ids can be created

        :id: 6277613b-0ece-4dee-b9d8-504f8299ac38

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy-id': proxy['id'],
            'puppet-ca-proxy-id': proxy['id'],
            'content-source-id': proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(cv['id'], hostgroup['content-view']['id'])
        self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['content-source']['id'])
        # get the json output format
        hostgroup = HostGroup.info({'id': hostgroup['id']},
                                   output_format='json')
        self.assertIn(org['id'], hostgroup['organizations'][0]['id'])
        self.assertIn(loc['id'], hostgroup['locations'][0]['id'])
        self.assertEqual(env['id'], hostgroup['puppet-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy']['id'])
        self.assertEqual(domain['id'], hostgroup['network']['domain']['id'])
        self.assertEqual(subnet['id'],
                         hostgroup['network']['subnet-ipv4']['id'])
        self.assertEqual(arch['id'],
                         hostgroup['operating-system']['architecture']['id'])
        self.assertEqual(
            ptable['id'],
            hostgroup['operating-system']['partition-table']['id'])
        self.assertEqual(media['id'],
                         hostgroup['operating-system']['medium']['id'])
        self.assertEqual(
            os['id'], hostgroup['operating-system']['operating-system']['id'])
Example #59
0
    def test_positive_create_with_multiple_entities_name(self):
        """Check if hostgroup with multiple options name can be created

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'organizations': org['name'],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': proxy['name'],
            'puppet-ca-proxy': proxy['name'],
            'content-source-id': proxy['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'query-organization': org['name']
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(proxy['name'], hostgroup['puppet-master-proxy'])
        self.assertEqual(proxy['name'], hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(proxy['name'], hostgroup['content-source']['name'])
    def test_positive_create_with_multiple_entities_ids(self):
        """Check if hostgroup with multiple options ids can be created

        :id: 6277613b-0ece-4dee-b9d8-504f8299ac38

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search': 'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy-id': proxy['id'],
            'puppet-ca-proxy-id': proxy['id'],
            'content-source-id': proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(cv['id'], hostgroup['content-view']['id'])
        self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['content-source']['id'])
        # get the json output format
        hostgroup = HostGroup.info(
            {'id': hostgroup['id']}, output_format='json')
        self.assertIn(org['id'], hostgroup['organizations'][0]['id'])
        self.assertIn(loc['id'], hostgroup['locations'][0]['id'])
        self.assertEqual(
            env['id'], hostgroup['puppet-environment']['environment_id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy-id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy-id'])
        self.assertEqual(domain['id'], hostgroup['domain']['domain_id'])
        self.assertEqual(
                subnet['id'],
                hostgroup['network']['subnet-ipv4']['id'])
        self.assertEqual(
            arch['id'], hostgroup['architecture']['architecture_id'])
        self.assertEqual(
            ptable['id'], hostgroup['partition-table']['ptable_id'])
        self.assertEqual(media['id'], hostgroup['medium']['medium_id'])
        self.assertEqual(
            os['id'], hostgroup['operating-system']['operatingsystem_id'])