Exemple #1
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'])
Exemple #2
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'])
Exemple #3
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'])
Exemple #4
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'])
Exemple #5
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'])
    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'],
                )
    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 = entities.Host(organization=self.org['id']).create()
        Host.update({
            u'name': host.name,
            u'environment': self.env['name'],
            u'puppet-classes': self.puppet_class['name'],
        })
        host_sc_params_list = Host.sc_params({u'host-id': host.id})
        self.assertGreater(len(host_sc_params_list), 0)
Exemple #8
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'])
Exemple #9
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'])
    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'])
Exemple #11
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'])
    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_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'])
Exemple #14
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'],
                )
Exemple #15
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'])
Exemple #16
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'])
Exemple #17
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'])
Exemple #18
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'])
    def test_positive_list_parameters_by_host_name(self):
        """List all the parameters included in specific Host by its name.

        @id: a8165746-3480-4875-8931-b20ebec241dc

        @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': self.puppet_class['name'],
            'id': sc_param_id,
        })
        self.assertEqual(sc_param['override'], True)
        host = entities.Host(organization=self.org['id']).create()
        Host.update({
            u'name': host.name,
            u'environment': self.env['name'],
            u'puppet-classes': self.puppet_class['name'],
        })
        host_sc_params_list = Host.sc_params({u'host': host.name})
        self.assertGreater(len(host_sc_params_list), 0)
Exemple #20
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'])
Exemple #21
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'])
    def test_positive_run_custom_job_template(self):
        """Run a job template against a single host

        :id: 89b75feb-afff-44f2-a2bd-2ffe74b63ec7

        :Setup: Create a working job template.

        :Steps:

            1. Navigate to an individual host and click Run Job
            2. Select the job and appropriate template
            3. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: System
        """
        jobs_template_name = gen_string('alpha')
        with VirtualMachine(
                distro=DISTRO_RHEL7,
                bridge=settings.vlan_networking.bridge
                ) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                u'name': client.hostname,
                u'subnet-id': self.new_sub['id'],
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                make_job_template(
                    session,
                    name=jobs_template_name,
                    template_type='input',
                    template_content='<%= input("command") %>',
                    provider_type='SSH',
                )
                self.assertIsNotNone(
                    self.jobtemplate.search(jobs_template_name))
                self.jobtemplate.add_input(
                    jobs_template_name, 'command', required=True)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(
                    job_category='Miscellaneous',
                    job_template=jobs_template_name,
                    options_list=[{'name': 'command', 'value': 'ls'}]
                )
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                self.assertTrue(
                        status,
                        'host output: {0}'.format(
                            ' '.join(JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname})
                            )
                        )
                    )
Exemple #23
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'])
Exemple #24
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'])
Exemple #25
0
    def test_positive_chost_previous_env(self):
        """Check if the applicable errata are available from the content
        host's previous environment

        :id: 78110ba8-3942-46dd-8c14-bffa1dbd5195

        :Setup:

            1. Make sure multiple environments are present.
            2. Content host's previous environments have additional errata.

        :Steps: Go to Content Hosts -> Select content host -> Errata Tab ->
            Select Previous environments.

        :expectedresults: The errata from previous environments are displayed.

        :CaseLevel: System
        """
        with VirtualMachine(distro=DISTRO_RHEL7) as client:
                client.install_katello_ca()
                client.register_contenthost(
                    self.session_org.label,
                    self.activation_key.name,
                )
                self.assertTrue(client.subscribed)
                client.enable_repo(REPOS['rhst7']['id'])
                client.install_katello_agent()
                client.run(
                    'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
                last_env_id = max(
                    lce.id
                    for lce
                    in entities.LifecycleEnvironment(
                        organization=self.session_org).search()
                )
                new_env = entities.LifecycleEnvironment(
                    organization=self.session_org,
                    prior=last_env_id,
                ).create()
                cvv = ContentView.info({
                    'id': self.content_view.id})['versions'][-1]
                ContentView.version_promote({
                    'id': cvv['id'],
                    'organization-id': self.session_org.id,
                    'to-lifecycle-environment-id': new_env.id,
                })
                Host.update({
                    'name': client.hostname,
                    'lifecycle-environment-id': new_env.id,
                    'organization-id': self.session_org.id,
                })
                with Session(self):
                    self.assertIsNotNone(
                        self.contenthost.errata_search(
                            client.hostname,
                            CUSTOM_REPO_ERRATA_ID,
                            environment_name=self.env.name,
                        )
                    )
Exemple #26
0
    def test_positive_chost_previous_env(self):
        """Check if the applicable errata are available from the content
        host's previous environment

        :id: 78110ba8-3942-46dd-8c14-bffa1dbd5195

        :Setup:

            1. Make sure multiple environments are present.
            2. Content host's previous environments have additional errata.

        :Steps: Go to Content Hosts -> Select content host -> Errata Tab ->
            Select Previous environments.

        :expectedresults: The errata from previous environments are displayed.

        :CaseLevel: System
        """
        with VirtualMachine(distro=DISTRO_RHEL7) as client:
                client.install_katello_ca()
                client.register_contenthost(
                    self.session_org.label,
                    self.activation_key.name,
                )
                self.assertTrue(client.subscribed)
                client.enable_repo(REPOS['rhst7']['id'])
                client.install_katello_agent()
                client.run(
                    'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
                last_env_id = max(
                    lce.id
                    for lce
                    in entities.LifecycleEnvironment(
                        organization=self.session_org).search()
                )
                new_env = entities.LifecycleEnvironment(
                    organization=self.session_org,
                    prior=last_env_id,
                ).create()
                cvv = ContentView.info({
                    'id': self.content_view.id})['versions'][-1]
                ContentView.version_promote({
                    'id': cvv['id'],
                    'organization-id': self.session_org.id,
                    'to-lifecycle-environment-id': new_env.id,
                })
                Host.update({
                    'name': client.hostname,
                    'lifecycle-environment-id': new_env.id,
                    'organization-id': self.session_org.id,
                })
                with Session(self):
                    self.assertIsNotNone(
                        self.contenthost.errata_search(
                            client.hostname,
                            CUSTOM_REPO_ERRATA_ID,
                            environment_name=self.env.name,
                        )
                    )
    def test_positive_run_default_job_template_by_ip(self):
        """Run a job template on a host connected by ip

        :id: 9a90aa9a-00b4-460e-b7e6-250360ee8e4d

        :Setup: Use pre-defined job template.

        :Steps:

            1. Set remote_execution_connect_by_ip on host to true
            2. Navigate to an individual host and click Run Job
            3. Select the job and appropriate template
            4. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: Integration
        """
        with VirtualMachine(
              distro=DISTRO_RHEL7,
              provisioning_server=settings.compute_resources.libvirt_hostname,
              bridge=settings.vlan_networking.bridge,
              ) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                'name': client.hostname,
                'subnet-id': self.new_sub.id,
            })
            # connect to host by ip
            Host.set_parameter({
                'host': client.hostname,
                'name': 'remote_execution_connect_by_ip',
                'value': 'True',
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(
                    job_category='Commands',
                    job_template='Run Command - SSH Default',
                    options_list=[{'name': 'command', 'value': 'ls'}]
                )
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                try:
                    self.assertTrue(status)
                except AssertionError:
                    result = 'host output: {0}'.format(
                            ' '.join(JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname})
                            )
                        )
                    raise AssertionError(result)
Exemple #28
0
def test_positive_run_default_job_template_by_ip(session, module_org,
                                                 module_subnet):
    """Run a job template on a host connected by ip

    :id: 9a90aa9a-00b4-460e-b7e6-250360ee8e4d

    :Setup: Use pre-defined job template.

    :Steps:

        1. Set remote_execution_connect_by_ip on host to true
        2. Navigate to an individual host and click Run Job
        3. Select the job and appropriate template
        4. Run the job

    :expectedresults: Verify the job was successfully ran against the host

    :CaseLevel: System
    """
    with VirtualMachine(
            distro=DISTRO_RHEL6,
            provisioning_server=settings.compute_resources.libvirt_hostname,
            bridge=settings.vlan_networking.bridge,
    ) as client:
        client.install_katello_ca()
        client.register_contenthost(module_org.label, lce='Library')
        assert client.subscribed
        add_remote_execution_ssh_key(client.ip_addr)
        Host.update({
            'name': client.hostname,
            'subnet-id': module_subnet.id,
        })
        # connect to host by ip
        Host.set_parameter({
            'host': client.hostname,
            'name': 'remote_execution_connect_by_ip',
            'value': 'True',
        })
        hostname = client.hostname
        with session:
            session.organization.select(module_org.name)
            assert session.host.search(hostname)[0]['Name'] == hostname
            session.jobinvocation.run({
                'job_category':
                'Commands',
                'job_template':
                'Run Command - SSH Default',
                'search_query':
                'name ^ {}'.format(hostname),
                'template_content.command':
                'ls',
            })
            session.jobinvocation.wait_job_invocation_state(
                entity_name='Run ls', host_name=hostname)
            status = session.jobinvocation.read(entity_name='Run ls',
                                                host_name=hostname)
            assert status['overview']['hosts_table'][0]['Status'] == 'success'
Exemple #29
0
    def test_positive_list(self):
        """List all smart variables associated to host, hostgroup, puppetlass

        :id: ee0da54c-ab60-4dde-8e1f-d548b52bac73

        :expectedresults: Smart Variables listed based on selected filter

        :CaseLevel: Integration
        """
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet_class['name']})

        # List by host name and id
        host = entities.Host(organization=self.org['id'],
                             location=self.loc['id']).create()
        Host.update({
            'name': host.name,
            'environment-id': self.env['id'],
            'puppet-classes': self.puppet_class['name'],
            'organization-id': self.org['id'],
        })
        host_variables = SmartVariable.list({'host': host.name})
        self.assertGreater(len(host_variables), 0)
        self.assertIn(smart_variable['variable'],
                      [sv['variable'] for sv in host_variables])
        host_variables = SmartVariable.list({'host-id': host.id})
        self.assertGreater(len(host_variables), 0)
        self.assertIn(smart_variable['id'],
                      [sv['id'] for sv in host_variables])

        # List by hostgroup name and id
        hostgroup = make_hostgroup({
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        hostgroup_variables = SmartVariable.list(
            {'hostgroup': hostgroup['name']})
        self.assertGreater(len(hostgroup_variables), 0)
        self.assertIn(smart_variable['variable'],
                      [sv['variable'] for sv in hostgroup_variables])
        hostgroup_variables = SmartVariable.list(
            {'hostgroup-id': hostgroup['id']})
        self.assertGreater(len(hostgroup_variables), 0)
        self.assertIn(smart_variable['id'],
                      [sv['id'] for sv in hostgroup_variables])

        # List by puppetclass name and id
        sc_params_list = SmartVariable.list(
            {'puppet-class': self.puppet_class['name']})
        self.assertGreater(len(sc_params_list), 0)
        self.assertIn(smart_variable['variable'],
                      [sv['variable'] for sv in sc_params_list])
        sc_params_list = SmartVariable.list(
            {'puppet-class-id': self.puppet_class['id']})
        self.assertGreater(len(sc_params_list), 0)
        self.assertIn(smart_variable['id'],
                      [sv['id'] for sv in sc_params_list])
    def test_positive_run_custom_job_template(self):
        """Run a job template against a single host

        :id: 89b75feb-afff-44f2-a2bd-2ffe74b63ec7

        :Setup: Create a working job template.

        :Steps:

            1. Navigate to an individual host and click Run Job
            2. Select the job and appropriate template
            3. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: System
        """
        jobs_template_name = gen_string('alpha')
        with VirtualMachine(distro=DISTRO_RHEL7,
                            bridge=settings.vlan_networking.bridge) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                u'name': client.hostname,
                u'subnet-id': self.new_sub['id'],
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                make_job_template(
                    session,
                    name=jobs_template_name,
                    template_type='input',
                    template_content='<%= input("command") %>',
                    provider_type='SSH',
                )
                self.assertIsNotNone(
                    self.jobtemplate.search(jobs_template_name))
                self.jobtemplate.add_input(jobs_template_name,
                                           'command',
                                           required=True)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(job_category='Miscellaneous',
                                      job_template=jobs_template_name,
                                      options_list=[{
                                          'name': 'command',
                                          'value': 'ls'
                                      }])
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                self.assertTrue(
                    status, 'host output: {0}'.format(' '.join(
                        JobInvocation.get_output({
                            'id': invocation_id,
                            'host': client.hostname
                        }))))
    def test_positive_run_job_template_multiple_hosts(self):
        """Run a job template against multiple hosts

        :id: 7f1981cb-afcc-49b7-a565-7fef9aa8ddde

        :Setup: Create a working job template.

        :Steps:

            1. Navigate to the hosts page and select at least two hosts
            2. Click the "Select Action"
            3. Select the job and appropriate template
            4. Run the job

        :expectedresults: Verify the job was successfully ran against the hosts

        :CaseLevel: System
        """
        with VirtualMachine(
                distro=DISTRO_RHEL7,
                bridge=settings.vlan_networking.bridge
                ) as client:
            with VirtualMachine(
                    distro=DISTRO_RHEL7,
                    bridge=settings.vlan_networking.bridge
                    ) as client2:
                for vm in client, client2:
                    vm.install_katello_ca()
                    vm.register_contenthost(
                        self.organization.label, lce='Library')
                    self.assertTrue(vm.subscribed)
                    add_remote_execution_ssh_key(vm.ip_addr)
                    Host.update({
                        u'name': vm.hostname,
                        u'subnet-id': self.new_sub['id'],
                    })
                with Session(self) as session:
                    set_context(session, org=self.organization.name)
                    self.hosts.update_host_bulkactions(
                        [client.hostname, client2.hostname],
                        action='Run Job',
                        parameters_list=[{'command': 'ls'}],
                    )
                    strategy, value = locators['job_invocation.status']
                    if self.job.wait_until_element(
                            (strategy, value % 'succeeded'), 240) is not None:
                        status = True
                    else:
                        status = False
                    # get job invocation id from the current url
                    invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                    self.assertTrue(status, 'host output: {0}'.format(
                        ' '.join(JobInvocation.get_output({
                             'id': invocation_id,
                             'host': client.hostname
                         }))))
    def test_positive_run_job_template_multiple_hosts(self):
        """Run a job template against multiple hosts

        :id: 7f1981cb-afcc-49b7-a565-7fef9aa8ddde

        :Setup: Create a working job template.

        :Steps:

            1. Navigate to the hosts page and select at least two hosts
            2. Click the "Select Action"
            3. Select the job and appropriate template
            4. Run the job

        :expectedresults: Verify the job was successfully ran against the hosts

        :CaseLevel: System
        """
        with VirtualMachine(distro=DISTRO_RHEL7,
                            bridge=settings.vlan_networking.bridge) as client:
            with VirtualMachine(
                    distro=DISTRO_RHEL7,
                    bridge=settings.vlan_networking.bridge) as client2:
                for vm in client, client2:
                    vm.install_katello_ca()
                    vm.register_contenthost(self.organization.label,
                                            lce='Library')
                    self.assertTrue(vm.subscribed)
                    add_remote_execution_ssh_key(vm.ip_addr)
                    Host.update({
                        u'name': vm.hostname,
                        u'subnet-id': self.new_sub['id'],
                    })
                with Session(self) as session:
                    set_context(session, org=self.organization.name)
                    self.hosts.update_host_bulkactions(
                        [client.hostname, client2.hostname],
                        action='Run Job',
                        parameters_list=[{
                            'command': 'ls'
                        }],
                    )
                    strategy, value = locators['job_invocation.status']
                    if self.job.wait_until_element(
                        (strategy, value % 'succeeded'), 240) is not None:
                        status = True
                    else:
                        status = False
                    # get job invocation id from the current url
                    invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                    self.assertTrue(
                        status, 'host output: {0}'.format(' '.join(
                            JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname
                            }))))
def test_positive_run_default_job_template_by_ip(
        session, module_org, module_subnet):
    """Run a job template on a host connected by ip

    :id: 9a90aa9a-00b4-460e-b7e6-250360ee8e4d

    :Setup: Use pre-defined job template.

    :Steps:

        1. Set remote_execution_connect_by_ip on host to true
        2. Navigate to an individual host and click Run Job
        3. Select the job and appropriate template
        4. Run the job

    :expectedresults: Verify the job was successfully ran against the host

    :CaseLevel: Integration
    """
    with VirtualMachine(
        distro=DISTRO_RHEL6,
        provisioning_server=settings.compute_resources.libvirt_hostname,
        bridge=settings.vlan_networking.bridge,
    ) as client:
        client.install_katello_ca()
        client.register_contenthost(module_org.label, lce='Library')
        assert client.subscribed
        add_remote_execution_ssh_key(client.ip_addr)
        Host.update({
            'name': client.hostname,
            'subnet-id': module_subnet.id,
        })
        # connect to host by ip
        Host.set_parameter({
            'host': client.hostname,
            'name': 'remote_execution_connect_by_ip',
            'value': 'True',
        })
        hostname = client.hostname
        with session:
            session.organization.select(module_org.name)
            assert session.host.search(hostname)[0]['Name'] == hostname
            session.jobinvocation.run({
                'job_category': 'Commands',
                'job_template': 'Run Command - SSH Default',
                'search_query': 'name ^ {}'.format(hostname),
                'template_content.command': 'ls',
            })
            session.jobinvocation.wait_job_invocation_state(
                entity_name='Run ls', host_name=hostname)
            status = session.jobinvocation.read(
                entity_name='Run ls', host_name=hostname)
            assert status['overview']['hosts_table'][0]['Status'] == 'success'
Exemple #34
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)
Exemple #35
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)
Exemple #36
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)
Exemple #37
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)
Exemple #38
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)
    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)
    def test_positive_run_default_job_template(self):
        """Run a job template against a single host

        :id: 7f0cdd1a-c87c-4324-ae9c-dbc30abad217

        :Setup: Use pre-defined job template.

        :Steps:

            1. Navigate to an individual host and click Run Job
            2. Select the job and appropriate template
            3. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: Integration
        """
        with VirtualMachine(
                distro=DISTRO_RHEL7,
                bridge=settings.vlan_networking.bridge
                ) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                u'name': client.hostname,
                u'subnet-id': self.new_sub['id'],
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(
                    job_category='Commands',
                    job_template='Run Command - SSH Default',
                    options_list=[{'name': 'command', 'value': 'ls'}]
                )
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                self.assertTrue(
                        status,
                        'host output: {0}'.format(
                            ' '.join(JobInvocation.get_output({
                                'id': invocation_id,
                                'host': client.hostname})
                            )
                        )
                    )
Exemple #41
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)
Exemple #42
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)
    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)
Exemple #44
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)
    def test_positive_list_parameters_by_host_name(self):
        """List all the parameters included in specific Host by its name.

        @id: a8165746-3480-4875-8931-b20ebec241dc

        @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_sc_params_list = Host.sc_params({u"host": self.host_name})
        self.assertGreater(len(host_sc_params_list), 0)
    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)
Exemple #47
0
    def test_positive_list_variables_by_host_id(self):
        """List all smart variables associated to host by host id.

        @id: ee2e994b-2a6d-4069-a2f7-e244a3134772

        @assert: Smart Variables listed for specific Host by host id.

        @CaseLevel: Integration
        """
        make_smart_variable({'puppet-class': self.puppet['name']})
        Host.update({
            u'name': self.host_name,
            u'puppet-classes': self.puppet['name']
        })
        host_id = Host.info({u'name': self.host_name})['id']
        host_smart_variables_list = Host.smart_variables({u'host-id': host_id})
        self.assertGreater(len(host_smart_variables_list), 0)
Exemple #48
0
    def test_positive_list_variables_by_host_name(self):
        """List all smart variables associated to host by hostname.

        @id: ee0da54c-ab60-4dde-8e1f-d548b52bac73

        @assert: Smart Variables listed for specific Host by hostname.

        @CaseLevel: Integration
        """
        make_smart_variable({'puppet-class': self.puppet['name']})
        Host.update({
            u'name': self.host_name,
            u'puppet-classes': self.puppet['name']
        })
        host_smart_variables_list = Host.smart_variables(
            {u'host': self.host_name})
        self.assertGreater(len(host_smart_variables_list), 0)
Exemple #49
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'])
Exemple #50
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'])
    def test_positive_run_default_job_template(self):
        """Run a job template against a single host

        :id: 7f0cdd1a-c87c-4324-ae9c-dbc30abad217

        :Setup: Use pre-defined job template.

        :Steps:

            1. Navigate to an individual host and click Run Job
            2. Select the job and appropriate template
            3. Run the job

        :expectedresults: Verify the job was successfully ran against the host

        :CaseLevel: Integration
        """
        with VirtualMachine(distro=DISTRO_RHEL7,
                            bridge=settings.vlan_networking.bridge) as client:
            client.install_katello_ca()
            client.register_contenthost(self.organization.label, lce='Library')
            self.assertTrue(client.subscribed)
            add_remote_execution_ssh_key(client.ip_addr)
            Host.update({
                u'name': client.hostname,
                u'subnet-id': self.new_sub['id'],
            })
            with Session(self) as session:
                set_context(session, org=self.organization.name)
                self.hosts.click(self.hosts.search(client.hostname))
                status = self.job.run(job_category='Commands',
                                      job_template='Run Command - SSH Default',
                                      options_list=[{
                                          'name': 'command',
                                          'value': 'ls'
                                      }])
                # get job invocation id from the current url
                invocation_id = self.browser.current_url.rsplit('/', 1)[-1]
                self.assertTrue(
                    status, 'host output: {0}'.format(' '.join(
                        JobInvocation.get_output({
                            'id': invocation_id,
                            'host': client.hostname
                        }))))
    def test_positive_list_variables_by_host_id(self):
        """List all smart variables associated to host by host id.

        @id: ee2e994b-2a6d-4069-a2f7-e244a3134772

        @assert: Smart Variables listed for specific Host by host id.

        @CaseLevel: Integration
        """
        make_smart_variable({'puppet-class': self.puppet_class['name']})
        host = entities.Host(organization=self.org['id']).create()
        Host.update({
            u'name': host.name,
            u'environment': self.env['name'],
            u'puppet-classes': self.puppet_class['name'],
        })
        host_smart_variables_list = Host.smart_variables({
            u'host-id': host.id})
        self.assertGreater(len(host_smart_variables_list), 0)
Exemple #53
0
    def test_positive_update_name_by_id(self):
        """A host can be updated with a new random name. Use id to
        access the host

        @id: 058dbcbf-d543-483d-b755-be0602588464

        @assert: A host is updated and the name matches
        """
        for new_name in valid_hosts_list():
            with self.subTest(new_name):
                Host.update({
                    'id': self.host['id'],
                    'new-name': new_name,
                })
                self.host = Host.info({'id': self.host['id']})
                self.assertEqual(
                    u'{0}.{1}'.format(new_name,
                                      self.host['network']['domain']),
                    self.host['name'])
Exemple #54
0
def _setup_vm_client_host(vm_client, org_label, subnet_id=None, by_ip=True):
    """Setup a VM host for remote execution.

    :param VMBroker vm_client: where vm_client is VMBroker instance.
    :param str org_label: The organization label.
    :param int subnet: (Optional) Nailgun subnet entity id, to be used by the vm_client host.
    :param bool by_ip: Whether remote execution will use ip or host name to access server.
    """
    vm_client.install_katello_ca()
    vm_client.register_contenthost(org_label, lce='Library')
    assert vm_client.subscribed
    add_remote_execution_ssh_key(vm_client.ip_addr)
    if subnet_id is not None:
        Host.update({'name': vm_client.hostname, 'subnet-id': subnet_id})
    if by_ip:
        # connect to host by ip
        Host.set_parameter(
            {'host': vm_client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True'}
        )
    def test_positive_list_variables_by_host_name(self):
        """List all smart variables associated to host by hostname.

        @id: ee0da54c-ab60-4dde-8e1f-d548b52bac73

        @assert: Smart Variables listed for specific Host by hostname.

        @CaseLevel: Integration
        """
        make_smart_variable({'puppet-class': self.puppet_class['name']})
        host = entities.Host(organization=self.org['id']).create()
        Host.update({
            u'name': host.name,
            u'environment': self.env['name'],
            u'puppet-classes': self.puppet_class['name'],
        })
        host_smart_variables_list = Host.smart_variables({
            u'host': host.name})
        self.assertGreater(len(host_smart_variables_list), 0)
Exemple #56
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'])
Exemple #57
0
    def test_positive_update_env_by_name(self):
        """A host can be updated with a new environment. Use entities
        names for association

        @id: f0ec469a-7550-4f05-b39c-e68b9267247d

        @assert: A host is updated and the environment matches

        @CaseLevel: Integration
        """
        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'])
Exemple #58
0
    def test_positive_update_env_by_id(self):
        """A host can be updated with a new environment. Use entities
        ids for association

        @id: 4e1d1e31-fa84-43e4-9e66-7fb953767ee5

        @assert: A host is updated and the environment matches

        @CaseLevel: Integration
        """
        new_env = make_environment({
            'location-id': self.host_args.location.id,
            'organization-id': self.host_args.organization.id,
        })
        Host.update({
            'environment-id': new_env['id'],
            'id': self.host['id'],
        })
        self.host = Host.info({'id': self.host['id']})
        self.assertEqual(self.host['environment'], new_env['name'])
Exemple #59
0
    def test_positive_update_env_by_name(self):
        """A host can be updated with a new environment. Use entities
        names for association

        @id: f0ec469a-7550-4f05-b39c-e68b9267247d

        @assert: A host is updated and the environment matches

        @CaseLevel: Integration
        """
        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'])