Esempio n. 1
0
    def test_positive_rename_content_host_cli(self):
        """Content Hosts renamed in UI affects entity in the application
        entirely, so name looks different through CLI too

        :id: a64c7815-269b-45d0-9032-38df550d6cd9

        :steps:
            1.  Rename a host from 'Content-hosts' page
            2.  View host under content-hosts
            3.  View host using command line interface

        :expectedresults: Host changed its name both in UI and CLI

        :BZ: 1417953

        :CaseLevel: System
        """
        new_name = gen_string('alphanumeric').lower()
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(self.org_.label, lce='Library')
            self.assertTrue(vm.subscribed)
            host = Host.info({'name': vm.hostname})
            with Session(self) as session:
                session.nav.go_to_select_org(self.org_.name)
                self.contenthost.update(
                    vm.hostname,
                    new_name=new_name,
                )
                self.assertIsNotNone(self.contenthost.search(new_name))
            self.assertEqual(Host.info({'id': host['id']})['name'], new_name)
    def test_positive_rename_content_host_cli(self):
        """Content Hosts renamed in UI affects entity in the application
        entirely, so name looks different through CLI too

        :id: a64c7815-269b-45d0-9032-38df550d6cd9

        :steps:
            1.  Rename a host from 'Content-hosts' page
            2.  View host under content-hosts
            3.  View host using command line interface

        :expectedresults: Host changed its name both in UI and CLI

        :BZ: 1417953, 1495271

        :CaseLevel: System
        """
        new_name = gen_string('alphanumeric').lower()
        with VirtualMachine(distro=DISTRO_RHEL7) as vm:
            vm.install_katello_ca()
            vm.register_contenthost(self.org_.label, lce='Library')
            self.assertTrue(vm.subscribed)
            host = Host.info({'name': vm.hostname})
            with Session(self) as session:
                session.nav.go_to_select_org(self.org_.name)
                self.contenthost.update(
                    vm.hostname,
                    new_name=new_name,
                )
                if bz_bug_is_open(1495271):
                    session.dashboard.navigate_to_entity()
                self.assertIsNotNone(self.contenthost.search(new_name))
            self.assertEqual(Host.info({'id': host['id']})['name'], new_name)
Esempio n. 3
0
    def test_positive_delete_by_name(self):
        """Create a host and then delete it by name.

        @id: 93f7504d-9a63-491f-8fdb-ed8017aefab9

        @Assert: Host is deleted
        """
        Host.delete({'name': self.host['name']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'name': self.host['name']})
Esempio n. 4
0
    def test_positive_delete_by_name(self):
        """Create a host and then delete it by name.

        @id: 93f7504d-9a63-491f-8fdb-ed8017aefab9

        @Assert: Host is deleted
        """
        Host.delete({'name': self.host['name']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'name': self.host['name']})
Esempio n. 5
0
    def test_positive_delete_by_id(self):
        """Create a host and then delete it by id.

        @id: e687a685-ab8b-4c5f-97f9-e14d3ab52f29

        @Assert: Host is deleted
        """
        Host.delete({'id': self.host['id']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'id': self.host['id']})
Esempio n. 6
0
    def test_positive_delete_by_name(self):
        """Create a host and then delete it by name.

        @Feature: Hosts

        @Assert: Host is deleted
        """
        Host.delete({'name': self.host['name']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'name': self.host['name']})
Esempio n. 7
0
    def test_positive_delete_by_id(self):
        """Create a host and then delete it by id.

        @id: e687a685-ab8b-4c5f-97f9-e14d3ab52f29

        @Assert: Host is deleted
        """
        Host.delete({'id': self.host['id']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'id': self.host['id']})
Esempio n. 8
0
    def test_positive_delete_by_id(self):
        """@Test: Create a host and then delete it by id.

        @Feature: Hosts

        @Assert: Host is deleted
        """
        Host.delete({'id': self.host['id']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'id': self.host['id']})
Esempio n. 9
0
    def test_positive_delete_by_name(self):
        """Create a host and then delete it by name.

        @Feature: Hosts

        @Assert: Host is deleted
        """
        Host.delete({'name': self.host['name']})
        with self.assertRaises(CLIReturnCodeError):
            Host.info({'name': self.host['name']})
Esempio n. 10
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'])
Esempio n. 11
0
    def test_positive_update_os_by_name(self):
        """A host can be updated with a new operating system. Use
        entities names for association

        @id: bd48887f-3db3-47b0-8231-de58884efe57

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architectures': self.host_args.architecture.name,
            'partition-tables': self.host[
                'operating-system']['partition-table'],
        })
        Medium.add_operating_system({
            'name': self.host_args.medium.name,
            'operatingsystem': new_os['title'],
        })
        Host.update({
            'name': self.host['name'],
            'operatingsystem': new_os['title'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Esempio n. 12
0
    def test_positive_update_domain_by_name(self):
        """A host can be updated with a new domain. Use entities names
        for association

        @id: 9b4fb1b9-a226-4b8a-bfaf-1121de7df5bc

        @assert: A host is updated and the domain matches

        @CaseLevel: Integration
        """
        new_domain = make_domain({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        Host.update({
            'domain': new_domain['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({
            'name': '{0}.{1}'.format(
                self.host['name'].split('.')[0],
                new_domain['name'],
            )
        })
        self.assertEqual(self.host['network']['domain'], new_domain['name'])
Esempio n. 13
0
    def test_positive_update_parameter_by_host_name(self):
        """Update existing host parameter by specifying host name.

        @Feature: Hosts

        @Assert: Host parameter was successfully updated with new value.

        """
        name = gen_string('alphanumeric').lower()
        old_value = gen_string('alphanumeric')
        Host.set_parameter({
            'host': self.host['name'],
            'name': name,
            'value': old_value,
        })
        for new_value in valid_data_list():
            with self.subTest(new_value):
                Host.set_parameter({
                    'host': self.host['name'],
                    'name': name,
                    'value': new_value,
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertIn(name, self.host['parameters'].keys())
                self.assertEqual(new_value, self.host['parameters'][name])
Esempio n. 14
0
    def test_positive_update_os_by_name(self):
        """A host can be updated with a new operating system. Use
        entities names for association

        @id: bd48887f-3db3-47b0-8231-de58884efe57

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architectures':
            self.host_args.architecture.name,
            'partition-tables':
            self.host['operating-system']['partition-table'],
        })
        Medium.add_operating_system({
            'name': self.host_args.medium.name,
            'operatingsystem': new_os['title'],
        })
        Host.update({
            'name': self.host['name'],
            'operatingsystem': new_os['title'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['operating-system']['operating-system'],
                         new_os['title'])
Esempio n. 15
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'])
Esempio n. 16
0
    def test_positive_update_medium_by_name(self):
        """A host can be updated with a new medium. Use entities names
        for association

        @id: f47edb02-d649-4ca8-94b2-0637ebdac2e8

        @assert: A host is updated and the medium matches

        @CaseLevel: Integration
        """
        new_medium = make_medium({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        Medium.add_operating_system({
            'name': new_medium['name'],
            'operatingsystem': self.host_args.operatingsystem.title,
        })
        new_medium = Medium.info({'name': new_medium['name']})
        Host.update({
            'medium': new_medium['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(
            self.host['operating-system']['medium'], new_medium['name'])
Esempio n. 17
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'])
Esempio n. 18
0
    def test_positive_update_parameter_by_host_id(self):
        """Update existing host parameter by specifying host ID.

        @id: 56c43ab4-7fb0-44f5-9d54-107d3c1011bf

        @Assert: Host parameter was successfully updated with new value.

        """
        name = gen_string('alphanumeric').lower()
        old_value = gen_string('alphanumeric')
        Host.set_parameter({
            'host-id': self.host['id'],
            'name': name,
            'value': old_value,
        })
        for new_value in valid_data_list():
            with self.subTest(new_value):
                Host.set_parameter({
                    'host-id': self.host['id'],
                    'name': name,
                    'value': new_value,
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertIn(name, self.host['parameters'].keys())
                self.assertEqual(new_value, self.host['parameters'][name])
Esempio n. 19
0
    def test_positive_update_name_by_name(self):
        """A host can be updated with a new random name. Use name to
        access the host

        @feature: Hosts

        @assert: A host is updated and the name matches
        """
        for new_name in valid_hosts_list():
            with self.subTest(new_name):
                Host.update({
                    'name': self.host['name'],
                    'new-name': new_name,
                })
                self.host = Host.info({
                    'name': u'{0}.{1}'
                            .format(new_name, self.host['domain']).lower()
                })
                self.assertEqual(
                    u'{0}.{1}'.format(
                        new_name,
                        self.host['domain'],
                    ).lower(),
                    self.host['name'],
                )
Esempio n. 20
0
    def test_positive_update_domain_by_name(self):
        """A host can be updated with a new domain. Use entities names
        for association

        @id: 9b4fb1b9-a226-4b8a-bfaf-1121de7df5bc

        @assert: A host is updated and the domain matches

        @CaseLevel: Integration
        """
        new_domain = make_domain({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        Host.update({
            'domain': new_domain['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({
            'name':
            '{0}.{1}'.format(
                self.host['name'].split('.')[0],
                new_domain['name'],
            )
        })
        self.assertEqual(self.host['network']['domain'], new_domain['name'])
Esempio n. 21
0
    def test_positive_update_medium_by_id(self):
        """A host can be updated with a new medium. Use entities ids for
        association

        @id: 899f1eef-07a9-4227-848a-92e377a8d55c

        @assert: A host is updated and the medium matches

        @CaseLevel: Integration
        """
        new_medium = make_medium({
            'location-id': self.host_args.location.id,
            'organization-id': self.host_args.organization.id,
        })
        Medium.add_operating_system({
            'id': new_medium['id'],
            'operatingsystem-id': self.host_args.operatingsystem.id,
        })
        new_medium = Medium.info({'id': new_medium['id']})
        Host.update({
            'id': self.host['id'],
            'medium-id': new_medium['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(
            self.host['operating-system']['medium'], new_medium['name'])
Esempio n. 22
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'])
Esempio n. 23
0
    def test_positive_update_medium_by_name(self):
        """A host can be updated with a new medium. Use entities names
        for association

        @id: f47edb02-d649-4ca8-94b2-0637ebdac2e8

        @assert: A host is updated and the medium matches

        @CaseLevel: Integration
        """
        new_medium = make_medium({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        Medium.add_operating_system({
            'name':
            new_medium['name'],
            'operatingsystem':
            self.host_args.operatingsystem.title,
        })
        new_medium = Medium.info({'name': new_medium['name']})
        Host.update({
            'medium': new_medium['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['operating-system']['medium'],
                         new_medium['name'])
Esempio n. 24
0
    def test_positive_update_os_by_id(self):
        """A host can be updated with a new operating system. Use
        entities ids for association

        @id: 9ea88634-9c14-4519-be6e-fb163897efb7

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architecture-ids': self.host_args.architecture.id,
            'partition-table-ids': self.host_args.ptable.id,
        })
        Medium.add_operating_system({
            'id': self.host_args.medium.id,
            'operatingsystem-id': new_os['id'],
        })
        Host.update({
            'id': self.host['id'],
            'operatingsystem-id': new_os['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['operating-system']['operating-system'],
                         new_os['title'])
Esempio n. 25
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'])
Esempio n. 26
0
    def test_positive_update_medium_by_id(self):
        """A host can be updated with a new medium. Use entities ids for
        association

        @id: 899f1eef-07a9-4227-848a-92e377a8d55c

        @assert: A host is updated and the medium matches

        @CaseLevel: Integration
        """
        new_medium = make_medium({
            'location-id':
            self.host_args.location.id,
            'organization-id':
            self.host_args.organization.id,
        })
        Medium.add_operating_system({
            'id':
            new_medium['id'],
            'operatingsystem-id':
            self.host_args.operatingsystem.id,
        })
        new_medium = Medium.info({'id': new_medium['id']})
        Host.update({
            'id': self.host['id'],
            'medium-id': new_medium['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['operating-system']['medium'],
                         new_medium['name'])
Esempio n. 27
0
    def test_positive_update_medium_by_name(self):
        """A host can be updated with a new medium. Use entities names
        for association

        @feature: Hosts

        @assert: A host is updated and the medium matches
        """
        new_medium = make_medium({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        Medium.add_operating_system({
            'name':
            new_medium['name'],
            'operatingsystem':
            self.host_args.operatingsystem.title,
        })
        new_medium = Medium.info({'name': new_medium['name']})
        Host.update({
            'medium': new_medium['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['medium'], new_medium['name'])
Esempio n. 28
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'])
Esempio n. 29
0
    def test_positive_update_os_by_id(self):
        """A host can be updated with a new operating system. Use
        entities ids for association

        @id: 9ea88634-9c14-4519-be6e-fb163897efb7

        @assert: A host is updated and the operating system matches

        @CaseLevel: Integration
        """
        new_os = make_os({
            'architecture-ids': self.host_args.architecture.id,
            'partition-table-ids': self.host_args.ptable.id,
        })
        Medium.add_operating_system({
            'id': self.host_args.medium.id,
            'operatingsystem-id': new_os['id'],
        })
        Host.update({
            'id': self.host['id'],
            'operatingsystem-id': new_os['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(
            self.host['operating-system']['operating-system'], new_os['title'])
Esempio n. 30
0
    def test_positive_update_parameter_by_host_id(self):
        """Update existing host parameter by specifying host ID.

        @id: 56c43ab4-7fb0-44f5-9d54-107d3c1011bf

        @Assert: Host parameter was successfully updated with new value.

        """
        name = gen_string('alphanumeric').lower()
        old_value = gen_string('alphanumeric')
        Host.set_parameter({
            'host-id': self.host['id'],
            'name': name,
            'value': old_value,
        })
        for new_value in valid_data_list():
            with self.subTest(new_value):
                Host.set_parameter({
                    'host-id': self.host['id'],
                    'name': name,
                    'value': new_value,
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertIn(name, self.host['parameters'].keys())
                self.assertEqual(new_value, self.host['parameters'][name])
Esempio n. 31
0
    def test_positive_update_domain_by_name(self):
        """A host can be updated with a new domain. Use entities names
        for association

        @feature: Hosts

        @assert: A host is updated and the domain matches
        """
        new_domain = make_domain({
            'location':
            self.host_args.location.name,
            'organization':
            self.host_args.organization.name,
        })
        Host.update({
            'domain': new_domain['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({
            'name':
            '{0}.{1}'.format(
                self.host['name'].split('.')[0],
                new_domain['name'],
            )
        })
        self.assertEqual(self.host['domain'], new_domain['name'])
Esempio n. 32
0
    def test_positive_update_name_by_name(self):
        """A host can be updated with a new random name. Use name to
        access the host

        @feature: Hosts

        @assert: A host is updated and the name matches
        """
        for new_name in valid_hosts_list():
            with self.subTest(new_name):
                Host.update({
                    'name': self.host['name'],
                    'new-name': new_name,
                })
                self.host = Host.info({
                    'name':
                    u'{0}.{1}'.format(new_name, self.host['domain']).lower()
                })
                self.assertEqual(
                    u'{0}.{1}'.format(
                        new_name,
                        self.host['domain'],
                    ).lower(),
                    self.host['name'],
                )
Esempio n. 33
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'])
Esempio n. 34
0
    def test_positive_update_parameter_by_host_name(self):
        """Update existing host parameter by specifying host name.

        @id: 24bcc8a4-7787-4fa8-9bf8-dfc5e697684f

        @Assert: Host parameter was successfully updated with new value.

        """
        name = gen_string('alphanumeric').lower()
        old_value = gen_string('alphanumeric')
        Host.set_parameter({
            'host': self.host['name'],
            'name': name,
            'value': old_value,
        })
        for new_value in valid_data_list():
            with self.subTest(new_value):
                Host.set_parameter({
                    'host': self.host['name'],
                    'name': name,
                    'value': new_value,
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertIn(name, self.host['parameters'].keys())
                self.assertEqual(new_value, self.host['parameters'][name])
Esempio n. 35
0
    def test_positive_run_receptor_installer(self):
        """Run Receptor installer ("Configure Cloud Connector")

        :CaseComponent: RHCloud-CloudConnector

        :Assignee: lhellebr

        :id: 811c7747-bec6-1a2d-8e5c-b5045d3fbc0d

        :expectedresults: The job passes, installs Receptor that peers with c.r.c

        :BZ: 1818076
        """
        # Set Host parameter source_display_name to something random.
        # To avoid 'name has already been taken' error when run multiple times
        # on a machine with the same hostname.
        host_id = Host.info({'name': settings.server.hostname})['id']
        Host.set_parameter({
            'host-id': host_id,
            'name': 'source_display_name',
            'value': gen_string('alpha')
        })

        template_name = 'Configure Cloud Connector'
        invocation = make_job_invocation({
            'async':
            True,
            'job-template':
            template_name,
            'inputs':
            f'satellite_user="******",\
                        satellite_password="******"',
            'search-query':
            f'name ~ {settings.server.hostname}',
        })
        invocation_id = invocation['id']

        wait_for(
            lambda: entities.JobInvocation(id=invocation_id).read().
            status_label in ["succeeded", "failed"],
            timeout="1500s",
        )
        assert entities.JobInvocation(id=invocation_id).read().status == 0

        result = ' '.join(
            JobInvocation.get_output({
                'id': invocation_id,
                'host': settings.server.hostname
            }))
        assert 'project-receptor.satellite_receptor_installer' in result
        assert 'Exit status: 0' in result
        # check that there is one receptor conf file and it's only readable
        # by the receptor user and root
        result = ssh.command(
            'stat /etc/receptor/*/receptor.conf --format "%a:%U"')
        assert result.stdout[0] == '400:foreman-proxy'
        result = ssh.command('ls -l /etc/receptor/*/receptor.conf | wc -l')
        assert result.stdout[0] == '1'
Esempio n. 36
0
 def delete(cls, options=None):
     """Work around host unification not being completed in order to delete
     a content host which is now a host subscription.
     """
     # Replace content host id with host id if passed
     if 'host-id' in options:
         name = ContentHost.info({'id': options['host-id']})['name'].lower()
         options['host-id'] = Host.info({'name': name})['id']
     return Host.subscription_unregister(options)
Esempio n. 37
0
 def delete(cls, options=None):
     """Work around host unification not being completed in order to delete
     a content host which is now a host subscription.
     """
     # Replace content host id with host id if passed
     if 'host-id' in options:
         name = ContentHost.info({'id': options['host-id']})['name'].lower()
         options['host-id'] = Host.info({'name': name})['id']
     return Host.subscription_unregister(options)
    def test_positive_provision_pxe_host_with_parameters(self):
        """Provision the pxe-based BIOS discovered host with host parameters from cli using
        SYSLINUX loader

        :id: 4b315fe1-2eba-4e59-bd0a-9d16ce319ce2

        :Setup:
            1. Create a BIOS VM and set it to boot from a network

        :steps:
            1. Build a default PXE template
            2. Configure HostGroup to be used for provisioning the discovered host
               after discovery
            3. PXE Boot the VM (from Network)
            4. Wait for Host to be discovered by Satellite
            5. Provision the discovered host with host parameters

        :expectedresults:
            1. Ensure host appeared in Discovered Hosts on satellite
            2. Ensure the host is provisioned with correct and all the host parameters
               given during provisioning
            3. Ensure the discovered host is no more available to provision

        :CaseImportance: High

        :BZ: 1572947
        """
        param1_key, param1_value = gen_string('alpha'), gen_string('alphanumeric')
        param2_key, param2_value = gen_string('alpha'), gen_string('alphanumeric')
        host_params = [f'{param1_key}={param1_value}, {param2_key}={param2_value}']
        if not self.configured_env:
            self.__class__.configured_env = configure_env_for_provision(org=self.org, loc=self.loc)
        with LibvirtGuest() as pxe_host:
            hostname = pxe_host.guest_name
            discovered_host = self._assertdiscoveredhost(hostname)
            self.assertIsNotNone(discovered_host)
            DiscoveredHost.provision(
                {
                    'name': discovered_host['name'],
                    'hostgroup': self.configured_env['hostgroup']['name'],
                    'root-password': gen_string('alphanumeric'),
                    'parameters': host_params,
                }
            )
            provisioned_host = Host.info(
                {
                    'name': '{}.{}'.format(
                        discovered_host['name'], self.configured_env['domain']['name']
                    )
                }
            )
            self.assertEqual(provisioned_host['parameters'][str(param1_key).lower()], param1_value)
            self.assertEqual(provisioned_host['parameters'][str(param2_key).lower()], param2_value)
            with self.assertRaises(CLIReturnCodeError):
                DiscoveredHost.info({'id': discovered_host['id']})
Esempio n. 39
0
def test_positive_register_host_ak_with_host_collection(
        katello_agent_client, module_cv, module_lce, module_org,
        rhel7_contenthost, default_sat):
    """Attempt to register a host using activation key with host collection

    :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb

    :BZ: 1385814

    :expectedresults: Host successfully registered and listed in host
        collection

    :CaseLevel: System
    """
    # client = katello_agent_client['client']
    host_info = katello_agent_client['host_info']
    # create a new activation key
    activation_key = make_activation_key({
        'lifecycle-environment-id':
        module_lce.id,
        'organization-id':
        module_org.id,
        'content-view-id':
        module_cv.id,
    })
    hc = make_host_collection({'organization-id': module_org.id})
    ActivationKey.add_host_collection({
        'id': activation_key['id'],
        'organization-id': module_org.id,
        'host-collection-id': hc['id'],
    })
    # add the registered instance host to collection
    HostCollection.add_host({
        'id': hc['id'],
        'organization-id': module_org.id,
        'host-ids': host_info['id']
    })

    with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as vm:
        vm.install_katello_ca(default_sat)
        # register the client host with the current activation key
        vm.register_contenthost(module_org.name,
                                activation_key=activation_key['name'])
        assert vm.subscribed
        # note: when registering the host, it should be automatically added to the host-collection
        client_host = Host.info({'name': vm.hostname})
        hosts = HostCollection.hosts({
            'id': hc['id'],
            'organization-id': module_org.id
        })
        assert len(hosts) == 2
        expected_hosts_ids = {host_info['id'], client_host['id']}
        hosts_ids = {host['id'] for host in hosts}
        assert hosts_ids == expected_hosts_ids
Esempio n. 40
0
def katello_agent_client(katello_agent_repos, rhel7_contenthost, default_sat):
    rhel7_contenthost.install_katello_ca(default_sat)
    # Register content host and install katello-agent
    rhel7_contenthost.register_contenthost(
        katello_agent_repos['org'].label,
        katello_agent_repos['ak'].name,
    )
    assert rhel7_contenthost.subscribed
    host_info = Host.info({'name': rhel7_contenthost.hostname})
    rhel7_contenthost.enable_repo(REPOS['rhst7']['id'])
    rhel7_contenthost.install_katello_agent()
    yield {'client': rhel7_contenthost, 'host_info': host_info}
Esempio n. 41
0
 def transform_ids(cls, options=None):
     """Workaround host unification feature not being completed to use host
     id instead content host uuid
     """
     if 'host-ids' in options:
         host_ids = [
             host_id if host_id.isdigit() else Host.info({
                 'name':
                 ContentHost.info({'id': host_id})['name'].lower()
             })['id'] for host_id in options.get('host-ids').split(',')
         ]
         if host_ids:
             options['host-ids'] = ','.join(host_ids)
Esempio n. 42
0
    def test_positive_register_host_ak_with_host_collection(self):
        """Attempt to register a host using activation key with host collection

        :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb

        :BZ: 1385814

        :expectedresults: Host successfully registered and listed in host
            collection

        :CaseLevel: System
        """
        # create a new activation key
        activation_key = make_activation_key({
            'lifecycle-environment-id':
            self.env['id'],
            'organization-id':
            self.org['id'],
            'content-view-id':
            self.content_view['id'],
        })
        hc = make_host_collection({'organization-id': self.org['id']})
        ActivationKey.add_host_collection({
            'id': activation_key['id'],
            'organization-id': self.org['id'],
            'host-collection-id': hc['id'],
        })
        # add the registered instance host to collection
        HostCollection.add_host({
            'id': hc['id'],
            'organization-id': self.org['id'],
            'host-ids': self.host['id']
        })
        with VirtualMachine() as client:
            client.create()
            client.install_katello_ca()
            # register the client host with the current activation key
            client.register_contenthost(self.org['name'],
                                        activation_key=activation_key['name'])
            assert client.subscribed
            # note: when registering the host, it should be automatically added
            # to the host collection
            client_host = Host.info({'name': client.hostname})
            hosts = HostCollection.hosts({
                'id': hc['id'],
                'organization-id': self.org['id']
            })
            assert len(hosts) == 2
            expected_hosts_ids = {self.host['id'], client_host['id']}
            hosts_ids = {host['id'] for host in hosts}
            assert hosts_ids == expected_hosts_ids
Esempio n. 43
0
 def transform_ids(cls, options=None):
     """Workaround host unification feature not being completed to use host
     id instead content host uuid
     """
     if 'host-ids' in options:
         host_ids = [
             host_id if host_id.isdigit() else
             Host.info({
                 'name': ContentHost.info({'id': host_id})['name'].lower()
             })['id']
             for host_id in options.get('host-ids').split(',')
         ]
         if host_ids:
             options['host-ids'] = ','.join(host_ids)
Esempio n. 44
0
    def test_positive_update_mac_by_id(self):
        """A host can be updated with a new random MAC address. Use id
        to access the host

        @id: 72ed9ae8-989a-46d1-8b7d-46f5db106e75

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'id': self.host['id'],
            'mac': new_mac,
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 45
0
    def test_positive_update_mac_by_name(self):
        """A host can be updated with a new random MAC address. Use name
        to access the host

        @id: a422788d-5473-4846-a86b-90d8f236285a

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'mac': new_mac,
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 46
0
    def test_positive_update_mac_by_name(self):
        """A host can be updated with a new random MAC address. Use name
        to access the host

        @id: a422788d-5473-4846-a86b-90d8f236285a

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'mac': new_mac,
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 47
0
    def test_positive_update_mac_by_id(self):
        """A host can be updated with a new random MAC address. Use id
        to access the host

        @id: 72ed9ae8-989a-46d1-8b7d-46f5db106e75

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'id': self.host['id'],
            'mac': new_mac,
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 48
0
    def test_positive_update_mac_by_name(self):
        """A host can be updated with a new random MAC address. Use name
        to access the host

        @feature: Hosts

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'mac': new_mac,
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['mac'], new_mac)
Esempio n. 49
0
    def test_positive_update_mac_by_name(self):
        """A host can be updated with a new random MAC address. Use name
        to access the host

        @feature: Hosts

        @assert: A host is updated and the MAC address matches
        """
        new_mac = gen_mac()
        Host.update({
            'mac': new_mac,
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['mac'], new_mac)
Esempio n. 50
0
    def test_negative_update_mac(self):
        """A host can not be updated with invalid or empty MAC address

        @feature: Hosts

        @assert: A host is not updated
        """
        for new_mac in invalid_values_list():
            with self.subTest(new_mac):
                with self.assertRaises(CLIReturnCodeError):
                    Host.update({
                        'id': self.host['id'],
                        'mac': new_mac,
                    })
                    self.host = Host.info({'id': self.host['id']})
                    self.assertEqual(self.host['mac'], new_mac)
Esempio n. 51
0
    def test_negative_update_mac(self):
        """A host can not be updated with invalid or empty MAC address

        @feature: Hosts

        @assert: A host is not updated
        """
        for new_mac in invalid_values_list():
            with self.subTest(new_mac):
                with self.assertRaises(CLIReturnCodeError):
                    Host.update({
                        'id': self.host['id'],
                        'mac': new_mac,
                    })
                    self.host = Host.info({'id': self.host['id']})
                    self.assertEqual(self.host['mac'], new_mac)
Esempio n. 52
0
    def test_negative_update_mac(self):
        """A host can not be updated with invalid or empty MAC address

        @id: 2f03032d-789d-419f-9ff2-a6f3561444da

        @assert: A host is not updated
        """
        for new_mac in invalid_values_list():
            with self.subTest(new_mac):
                with self.assertRaises(CLIReturnCodeError):
                    Host.update({
                        'id': self.host['id'],
                        'mac': new_mac,
                    })
                    self.host = Host.info({'id': self.host['id']})
                    self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 53
0
    def test_negative_update_mac(self):
        """A host can not be updated with invalid or empty MAC address

        @id: 2f03032d-789d-419f-9ff2-a6f3561444da

        @assert: A host is not updated
        """
        for new_mac in invalid_values_list():
            with self.subTest(new_mac):
                with self.assertRaises(CLIReturnCodeError):
                    Host.update({
                        'id': self.host['id'],
                        'mac': new_mac,
                    })
                    self.host = Host.info({'id': self.host['id']})
                    self.assertEqual(self.host['network']['mac'], new_mac)
Esempio n. 54
0
    def test_positive_provision_pxeless_host(self):
        """Provision the pxe-less discovered host from cli

        :id: ae7f3ce2-e66e-44dc-85cb-0c3c4782cbb1

        :Setup: Host should already be discovered

        :expectedresults: Host should be provisioned successfully and entry
            from discovered host list should be auto removed

        :CaseLevel: System
        """
        if not self.configured_env:
            self.configured_env = configure_env_for_provision(
                org=self.org, loc=self.loc)
        with LibvirtGuest(boot_iso=True) as pxe_host:
            hostname = pxe_host.guest_name
            discovered_host = self._assertdiscoveredhost(hostname)
            self.assertIsNotNone(discovered_host)
            # Provision just discovered host
            DiscoveredHost.provision({
                'name': discovered_host['name'],
                'hostgroup': self.configured_env['hostgroup']['name'],
                'root-password': gen_string('alphanumeric'),
            })
            provisioned_host = Host.info({
                'name': '{0}.{1}'.format(
                    discovered_host['name'],
                    self.configured_env['domain']['name']
                )
            })
            self.assertEqual(
                provisioned_host['network']['subnet'],
                self.configured_env['subnet']['name']
            )
            self.assertEqual(
                provisioned_host['operating-system']['partition-table'],
                self.configured_env['ptable']['name']
            )
            self.assertEqual(
                provisioned_host['operating-system']['operating-system'],
                self.configured_env['os']['title']
            )
            # Check that provisioned host is not in the list of discovered
            # hosts anymore
            with self.assertRaises(CLIReturnCodeError):
                DiscoveredHost.info({'id': discovered_host['id']})
Esempio n. 55
0
    def test_positive_provision_pxe_host(self):
        """Provision the pxe based discovered host from cli

        @id: b5385fe3-d532-4373-af64-5492275ff8d4

        @Setup: Host should already be discovered

        @Assert: Host should be provisioned successfully and entry from
        discovered host list should be automatically removed.

        @CaseLevel: System
        """
        if not self.configured_env:
            self.configured_env = configure_env_for_provision(
                org=self.org, loc=self.loc)
        with LibvirtGuest() as pxe_host:
            hostname = pxe_host.guest_name
            discovered_host = self._assertdiscoveredhost(hostname)
            self.assertIsNotNone(discovered_host)
            # Provision just discovered host
            DiscoveredHost.provision({
                'name': discovered_host['name'],
                'hostgroup': self.configured_env['hostgroup']['name'],
                'root-password': gen_string('alphanumeric'),
            })
            provisioned_host = Host.info({
                'name': '{0}.{1}'.format(
                    discovered_host['name'],
                    self.configured_env['domain']['name']
                )
            })
            self.assertEqual(
                provisioned_host['network']['subnet'],
                self.configured_env['subnet']['name']
            )
            self.assertEqual(
                provisioned_host['operating-system']['partition-table'],
                self.configured_env['ptable']['name']
            )
            self.assertEqual(
                provisioned_host['operating-system']['operating-system'],
                self.configured_env['os']['title']
            )
            # Check that provisioned host is not in the list of discovered
            # hosts anymore
            with self.assertRaises(CLIReturnCodeError):
                DiscoveredHost.info({'id': discovered_host['id']})
    def test_positive_list_parameters_by_host_id(self):
        """List all the parameters included in specific Host by its id.

        @id: 79050de6-b894-4a88-b155-32bf488b692c

        @assert: Parameters listed for specific Host.

        @CaseLevel: Integration
        """
        sc_param_id = self.sc_params_ids_list.pop()
        SmartClassParameter.update({"id": sc_param_id, "override": 1})
        sc_param = SmartClassParameter.info({"puppet-class": "ntp", "id": sc_param_id})
        self.assertEqual(sc_param["override"], True)
        Host.update({u"name": self.host_name, u"puppet-classes": "ntp"})
        host_id = Host.info({u"name": self.host_name})["id"]
        host_sc_params_list = Host.sc_params({u"host-id": host_id})
        self.assertGreater(len(host_sc_params_list), 0)
Esempio n. 57
0
    def setUp(self):
        """Create VM, subscribe it to satellite-tools repo, install katello-ca
        and katello-agent packages

        """
        super(KatelloAgentTestCase, self).setUp()
        # Create VM and register content host
        self.client = VirtualMachine(distro='rhel71')
        self.client.create()
        self.client.install_katello_ca()
        # Register content host, install katello-agent
        self.client.register_contenthost(
            KatelloAgentTestCase.activation_key['name'],
            KatelloAgentTestCase.org['label']
        )
        self.host = Host.info({'name': self.client.hostname})
        self.client.enable_repo(REPOS['rhst7']['id'])
        self.client.install_katello_agent()
Esempio n. 58
0
    def test_positive_add_parameter_with_name(self):
        """Add host parameter with different valid names.

        @Feature: Hosts

        @Assert: Host parameter was successfully added with correct name.

        """
        for name in valid_data_list():
            with self.subTest(name):
                name = name.lower()
                Host.set_parameter({
                    'host-id': self.host['id'],
                    'name': name,
                    'value': gen_string('alphanumeric'),
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertIn(name, self.host['parameters'].keys())
Esempio n. 59
0
    def test_positive_update_env_by_name(self):
        """A host can be updated with a new environment. Use entities
        names for association

        @feature: Hosts

        @assert: A host is updated and the environment matches
        """
        new_env = make_environment({
            'location': self.host_args.location.name,
            'organization': self.host_args.organization.name,
        })
        Host.update({
            'environment': new_env['name'],
            'name': self.host['name'],
        })
        self.host = Host.info({'name': self.host['name']})
        self.assertEqual(self.host['environment'], new_env['name'])
Esempio n. 60
0
    def test_positive_update_domain_by_id(self):
        """A host can be updated with a new domain. Use entities ids for
        association

        @feature: Hosts

        @assert: A host is updated and the domain matches
        """
        new_domain = make_domain({
            'location-id': self.host_args.location.id,
            'organization-id': self.host_args.organization.id,
        })
        Host.update({
            'domain-id': new_domain['id'],
            'id': self.host['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['domain'], new_domain['name'])