コード例 #1
0
    def test_pre_scenario_yum_plugins_count(self):
        """Create content host and register with Satellite.

        :id: preupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:

            1. Before Satellite upgrade.
            2. Create LifecycleEnvironment.
            3. Enable/sync 'base os RHEL7' and tools repos.
            4. Create 'Content View' and activation key.
            5. Create a content host, register and install katello-agent on it.

        :expectedresults:

            1. The content host is created.
            2. katello-agent install and goferd run.
        """
        environment = entities.LifecycleEnvironment(
            organization=self.org).search(query={'search': 'name=Library'})[0]
        repos = self._get_rh_rhel_tools_repos()
        content_view = publish_content_view(org=self.org, repolist=repos)
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=self.org.id,
                                    environment=environment).create()

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=self.org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        wait_for(
            lambda: self.org.label in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=self.docker_vm,
            )[self.docker_vm],
            timeout=800,
            delay=2,
            logger=self.logger,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=self.docker_vm,
        )[self.docker_vm]
        self.assertIn(self.org.label, status)

        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'cv_id': content_view.id
            }
        }
        create_dict(scenario_dict)
コード例 #2
0
    def test_pre_scenario_preclient_package_installation(
            default_org, pre_upgrade_cv, pre_upgrade_repo, module_ak):
        """Create product and repo, from which a package will be installed
        post upgrade. Create a content host and register it.

        :id: preupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :setup:

            1. Create and sync repo from which a package can be
                installed on content host
            2. Add repo to CV and then to Activation key


        :steps:

            1. Create a container as content host and register with Activation key

        :expectedresults:

            1. The "pre-upgrade" content host is created and registered.
            2. The new repo is enabled on the content host.

        """
        rhel7_client = dockerize(ak_name=module_ak.name,
                                 distro='rhel7',
                                 org_label=default_org.label)
        client_container_id = list(rhel7_client.values())[0]
        # Wait 60 seconds as script in /tmp takes up to 2 min inc the repo sync time
        time.sleep(60)
        # Use yum install again in case script was not yet finished
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'yum -y install katello-agent',
            host=docker_vm,
        )[docker_vm]
        # Assert gofer was installed after yum completes
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'rpm -q gofer',
            host=docker_vm,
        )[docker_vm]
        assert 'package gofer is not installed' not in installed_package
        # Run goferd on client as its docker container
        kwargs = {'async': True, 'host': docker_vm}
        execute(docker_execute_command, client_container_id, 'goferd -f',
                **kwargs)
        # Holding on for 30 seconds while goferd starts
        time.sleep(30)
        status = execute(docker_execute_command,
                         client_container_id,
                         'ps -aux',
                         host=docker_vm)[docker_vm]
        assert 'goferd' in status
        # Save client info to disk for post-upgrade test
        create_dict({__name__: rhel7_client})
コード例 #3
0
    def test_pre_subscription_scenario_autoattach(self):
        """Create content host and register with Satellite

        :id: preupgrade-940fc78c-ffa6-4d9a-9c4b-efa1b9480a22

        :steps:
            1. Before Satellite upgrade.
            2. Create new Organization and Location
            3. Upload a manifest in it.
            4. Create a AK with 'auto-attach False' and without Subscription add in it.
            5. Create a content host.
            6. Update content host location.

        :expectedresults:
            1. Content host should be created.
            2. Content host location should be updated.
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        manifests.upload_manifest_locked(org.id,
                                         interface=manifests.INTERFACE_API)
        act_key = entities.ActivationKey(auto_attach=False,
                                         organization=org.id,
                                         environment=org.library.id).create()
        rhel7_client = dockerize(ak_name=act_key.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        host_location_update(client_container_name=client_container_name,
                             logger_obj=self.logger,
                             loc=loc)

        wait_for(
            lambda: org.name in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=self.docker_vm,
            )[self.docker_vm],
            timeout=100,
            delay=2,
            logger=self.logger,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=self.docker_vm,
        )[self.docker_vm]
        self.assertIn(org.name, status)

        global_dict = {
            self.__class__.__name__: {
                'client_container_id': client_container_id
            }
        }
        create_dict(global_dict)
コード例 #4
0
    def test_pre_subscription_scenario_autoattach(self, request, default_sat):
        """Create content host and register with Satellite

        :id: preupgrade-940fc78c-ffa6-4d9a-9c4b-efa1b9480a22

        :steps:
            1. Before Satellite upgrade.
            2. Create new Organization and Location.
            3. Upload a manifest in it.
            4. Create a AK with 'auto-attach False' and without Subscription add in it.
            5. Create a content host.
            6. Update content host location.

        :expectedresults:
            1. Content host should be created.
            2. Content host location should be updated.
        """
        docker_vm = settings.upgrade.docker_vm
        container_name = f"{request.node.name}_docker_client"
        org = entities.Organization(name=request.node.name + "_org").create()
        loc = entities.Location(name=request.node.name + "_loc",
                                organization=[org]).create()
        manifests.upload_manifest_locked(org.id,
                                         interface=manifests.INTERFACE_API)
        act_key = entities.ActivationKey(
            auto_attach=False,
            organization=org.id,
            environment=org.library.id,
            name=request.node.name + "_ak",
        ).create()
        rhel7_client = dockerize(ak_name=act_key.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        ssh.command(f"docker rename {client_container_id} {container_name}",
                    hostname=f'{docker_vm}')
        client_container_hostname = [key for key in rhel7_client.keys()][0]
        host_location_update(
            client_container_name=f"{client_container_hostname}", loc=loc)
        wait_for(
            lambda: org.name in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=docker_vm,
            )[docker_vm],
            timeout=300,
            delay=30,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=docker_vm,
        )[docker_vm]
        assert org.name in status
コード例 #5
0
ファイル: test_yum_plugins.py プロジェクト: jhutar/robottelo
    def test_pre_scenario_yum_plugins_count(self):
        """Create content host and register with Satellite.

        :id: preupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:

            1. Before Satellite upgrade.
            2. Create new Organization and Location.
            3. Create Product, custom tools, rhel repos and sync them.
            4. Create activation key and add subscription.
            5. Create a content host, register and install katello-agent on it.

        :expectedresults:

            1. The content host is created.
            2. katello-agent install and goferd run.
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()

        environment = entities.LifecycleEnvironment(organization=org
                                                    ).search(query={'search': 'name=Library'})[0]
        product = entities.Product(organization=org).create()
        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        repolist = [tools_repo, rhel_repo]
        content_view = self._publish_content_view(org=org, repolist=repolist)

        ak = entities.ActivationKey(content_view=content_view, organization=org.id,
                                    environment=environment).create()
        subscription = entities.Subscription(organization=org).search(query={
            'search': 'name={}'.format(product.name)})[0]

        ak.add_subscriptions(data={'subscription_id': subscription.id})
        rhel7_client = dockerize(ak_name=ak.name, distro='rhel7', org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        self._host_location_update(client_container_name=client_container_name, loc=loc)

        status = execute(docker_execute_command, client_container_id,
                         'subscription-manager identity', host=self.docker_vm)[self.docker_vm]
        self.assertIn(org.name, status)

        self._install_or_update_package(client_container_id, 'katello-agent')
        self._run_goferd(client_container_id)

        scenario_dict = {self.__class__.__name__: {
            'rhel_client': rhel7_client,
            'product_id': product.id,
            'conten_view_id': content_view.id
        }}
        create_dict(scenario_dict)
コード例 #6
0
    def test_pre_scenario_preclient_package_installation(self):
        """Create product and repo from which the package will be installed
        post upgrade

        :id: preupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created

        """
        rhel7_client = dockerize(distro='rhel7')
        product = entities.Product(
            name='preclient_scenario_product',
            organization=1,
        ).create()
        yum_repo = entities.Repository(
            name='preclient_scenario_repo', product=product
        ).create()
        yum_repo.sync()
        self.cv.repository = [yum_repo]
        cv = self.cv.update(['repository'])
        cv.publish()
        cv = cv.read()  # Published CV with new version
        # Promote CV
        environment = entities.ActivationKey().search(
            query={'search': 'name={}'.format(self.ak)}
        )[0].environment
        cvv = entities.ContentViewVersion(
            id=max([cvv.id for cvv in cv.version])
        ).read()
        cvv.promote(
            data={
                u'environment_id': environment.id,
                u'force': False
            }
        )
        create_dict(
            {self.__class__.__name__: rhel7_client}
        )
コード例 #7
0
    def test_pre_user_scenario_bug_1429201(self):
        """This is pre-upgrade scenario test to verify if we can create a
         custom repository and consume it via client

         :id: 8fb8ec87-efa5-43ed-8cb3-960ef9cd6df2

         :steps:
             1. Create repository RepoFoo that you will later add to your
                Satellite. This repository should contain PackageFoo-1.0.rpm
             2. Install satellite 6.1
             3. Create custom product ProductFoo pointing to repository RepoFoo
             4. Sync RepoFoo
             5. Create content view CVFoo
             6. Add RepoFoo to CVFoo
             7. Publish version 1 of CVFoo

         :expectedresults: The client and product is created successfully

         :BZ: 1429201
         """
        self.create_repo()
        # End to End product + ak association
        print(hammer.hammer_product_create(self.prd_name, self.org_id))
        print(
            hammer.hammer_repository_create(self.repo_name, self.org_id,
                                            self.prd_name, self.custom_repo))
        print(
            hammer.hammer('lifecycle-environment create --name "{0}" '
                          '--organization-id {1} --prior-id "{2}"'.format(
                              self.lc_name, self.org_id, 1)))
        print(
            hammer.hammer_repository_synchronize(self.repo_name, self.org_id,
                                                 self.prd_name))
        print(hammer.hammer_content_view_create(self.cv_name, self.org_id))
        print(
            hammer.hammer_content_view_add_repository(self.cv_name,
                                                      self.org_id,
                                                      self.prd_name,
                                                      self.repo_name))
        print(hammer.hammer_content_view_publish(self.cv_name, self.org_id))
        latest_repo_version = hammer.get_latest_cv_version(self.cv_name)
        lc_result = hammer.hammer('"{0}" info --name "{1}" --organization-id '
                                  '{2}'.format('lifecycle-environment',
                                               self.lc_name, self.org_id))
        lifecycle_id = hammer.get_attribute_value(lc_result, self.lc_name,
                                                  'id')
        print(
            hammer.hammer_content_view_promote_version(self.cv_name,
                                                       latest_repo_version,
                                                       lifecycle_id,
                                                       self.org_id))
        print(
            hammer.hammer_activation_key_create(self.ak_name, self.org_id,
                                                self.cv_name, self.lc_name))
        print(
            hammer.hammer_activation_key_add_subscription(
                self.ak_name, self.org_id, self.prd_name))
        time.sleep(5)
        # Creating a rhel7 vm and subscribing to AK
        container_ids = dockerize(self.ak_name, 'rhel7')
        # Subscription manager needs time to register
        execute(docker_wait_until_repo_list,
                list(container_ids.values())[0],
                host=self.docker_vm)
        result = execute(docker_execute_command,
                         list(container_ids.values())[0],
                         'yum list {0} | grep {0}'.format(
                             self.rpm1_name.split('-')[0]),
                         host=self.docker_vm)
        # Info on created entities to assert the test case using hammer info
        prd_info = hammer.hammer('"{0}" info --name "{1}" --organization-id '
                                 '{2}'.format('product', self.prd_name,
                                              self.org_id))
        self.assertEqual(
            self.prd_name,
            hammer.get_attribute_value(prd_info, self.prd_name, 'name'))
        self.assertIsNotNone(container_ids)
        self.assertIn(self.repo_name, list(result.values())[0])
        global_dict = {
            self.__class__.__name__: {
                'prd_name': self.prd_name,
                'ak_name': self.ak_name,
                'repo_name': self.repo_name,
                'container_ids': container_ids
            }
        }
        create_dict(global_dict)
コード例 #8
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    def test_pre_scenario_generate_errata_with_previous_version_katello_agent_client(
            self, default_org):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

        :id: preupgrade-4e515f84-2582-4b8b-a625-9f6c6966aa59

        :steps:

            1. Create Life Cycle Environment, Product and Custom Yum Repo.
            2. Enable/sync 'base os RHEL7' and tools repos.
            3. Create a content view and publish it.
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7.
            6. Install and check katello agent and goferd service running on host.
            7. Generate Errata by Installing Outdated/Older Packages.
            8. Collect the Erratum list.

        :expectedresults:

            1. The content host is created.
            2. errata count, erratum list will be generated to satellite client/content host.

        """
        environment = entities.LifecycleEnvironment(
            organization=default_org).search(
                query={'search': 'name=Library'})[0]

        product = entities.Product(organization=default_org).create()
        custom_yum_repo = entities.Repository(
            product=product, content_type='yum',
            url=settings.repos.yum_9.url).create()
        call_entity_method_with_timeout(product.sync, timeout=1400)

        repos = self._get_rh_rhel_tools_repos(default_org)
        repos.append(custom_yum_repo)
        content_view = publish_content_view(org=default_org, repolist=repos)
        custom_sub = entities.Subscription(organization=default_org).search(
            query={'search': f'name={product.name}'})[0]
        rh_sub = entities.Subscription(organization=1).search(
            query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'})[0]

        ak = entities.ActivationKey(
            content_view=content_view,
            organization=default_org.id,
            environment=environment,
            auto_attach=False,
        ).create()
        ak.add_subscriptions(data={'subscription_id': custom_sub.id})
        ak.add_subscriptions(data={'subscription_id': rh_sub.id})

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=default_org.label)
        client_container_id = list(rhel7_client.values())[0]

        docker_vm = settings.upgrade.docker_vm
        wait_for(
            lambda: default_org.label in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=docker_vm,
            )[docker_vm],
            timeout=800,
            delay=2,
            logger=logger,
        )
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=docker_vm,
        )[docker_vm]

        assert default_org.label in status

        # Update OS to make errata count 0
        execute(docker_execute_command,
                client_container_id,
                'yum update -y',
                host=docker_vm)[docker_vm]
        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            install_or_update_package(client_hostname=client_container_id,
                                      package=package)
        host = entities.Host().search(
            query={'search': f'activation_key={ak.name}'})[0]

        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        assert installable_errata_count > 1

        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        assert sorted(errata_ids) == sorted(settings.repos.yum_9.errata)
        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'activation_key': ak.name,
                'custom_repo_id': custom_yum_repo.id,
                'product_id': product.id,
            }
        }
        create_dict(scenario_dict)
コード例 #9
0
ファイル: test_errata.py プロジェクト: lpramuk/robottelo
    def test_pre_scenario_generate_errata_for_client(self):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Create  Life Cycle Environment, Product and Custom Yum Repo
            2. Create custom tools, rhel repos and sync them
            3. Create content view and publish it
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7
            6. Check katello agent and goferd service running on host
            7. Generate Errata by Installing Outdated/Older Packages
            8. Collect the Erratum list

        :expectedresults:

            1. The content host is created
            2. errata count, erratum list will be generated to satellite client/content
                host

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        environment = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'})[0]

        product = entities.Product(organization=org).create()
        custom_yum_repo = entities.Repository(
            product=product, content_type='yum',
            url=settings.repos.yum_9.url).create()
        product.sync()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        repolist = [custom_yum_repo, tools_repo, rhel_repo]
        content_view = publish_content_view(org=org, repolist=repolist)
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=environment).create()
        subscription = entities.Subscription(organization=org).search(
            query={'search': f'name={product.name}'})[0]

        ak.add_subscriptions(data={'subscription_id': subscription.id})
        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        host_location_update(client_container_name=client_container_name,
                             logger_obj=logger,
                             loc=loc)

        docker_vm = settings.upgrade.docker_vm
        wait_for(
            lambda: org.name in execute(
                docker_execute_command,
                client_container_id,
                'subscription-manager identity',
                host=docker_vm,
            )[docker_vm],
            timeout=800,
            delay=2,
            logger=logger,
        )
        install_or_update_package(client_hostname=client_container_id,
                                  package="katello-agent")
        run_goferd(client_hostname=client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            install_or_update_package(client_hostname=client_container_id,
                                      package=package)

        host = entities.Host().search(
            query={'search': f'activation_key={ak.name}'})[0]
        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        assert installable_errata_count > 1
        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        assert sorted(errata_ids) == sorted(settings.repos.yum_9.errata)
        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'activation_key': ak.name,
                'custom_repo_id': custom_yum_repo.id,
                'product_id': product.id,
                'conten_view_id': content_view.id,
            }
        }
        create_dict(scenario_dict)
コード例 #10
0
    def test_post_scenario_postclient_package_installation(self):
        """Post-upgrade scenario that creates and installs the package on
        post-upgrade client remotely and then verifies if the package installed

        :id: postupgrade-1a881c07-595f-425f-aca9-df2337824a8e

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key
            4. Install package on a pre-upgrade client

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created
            3. The package is installed on post-upgrade client
        """
        org = entities.Organization(name=self.org_name).create()
        prior_env = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'}
        )[0]
        environment = entities.LifecycleEnvironment(
            organization=org,
            prior=prior_env.id,
            label=self.le_name,
            name=self.le_name
        ).create()
        ak = create_activation_key_for_client_registration(
            ak_name=self.ak_name,
            client_os='rhel7',
            org=org,
            environment=environment,
            sat_state='post'
        )
        rhel7_client = dockerize(
            ak_name=ak.name, distro='rhel7', org_label=org.label)
        client_container_id = rhel7_client.values()[0]
        client_name = rhel7_client.keys()[0].lower()
        product, yum_repo = create_yum_test_repo(
            product_name=self.prod_name, repo_url=FAKE_REPO_ZOO3, org=org)
        update_product_subscription_in_ak(
            product=product, yum_repo=yum_repo, ak=ak, org=org)
        time.sleep(10)
        execute(
            attach_subscription_to_host_from_satellite,
            org.id,
            product.name,
            client_name,
            host=get_satellite_host()
        )
        # Refresh subscriptions on client
        execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager refresh',
            host=self.docker_vm
        )
        # Run goferd on client as its docker container
        execute(
            docker_execute_command,
            client_container_id,
            'goferd -f',
            async=True,
            host=self.docker_vm
        )
        # Holding on for 30 seconds wihle goferd starts
        time.sleep(30)
        client_id = entities.Host().search(
            query={'search': 'name={}'.format(client_name)}
        )[0].id
        entities.Host().install_content(data={
            'organization_id': org.id,
            'included': {'ids': [client_id]},
            'content_type': 'package',
            'content': [self.package_name],
        })
        time.sleep(20)
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'rpm -q {}'.format(self.package_name),
            host=self.docker_vm
        )[self.docker_vm]
        self.assertIn(self.package_name, installed_package)
コード例 #11
0
    def test_pre_scenario_preclient_package_installation(self):
        """Create product and repo from which the package will be installed
        post upgrade

        :id: preupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created

        """
        prior_env = entities.LifecycleEnvironment(
            organization=self.org
        ).search(query={'search': 'name=Library'})[0]
        environment = entities.LifecycleEnvironment(
            organization=self.org,
            prior=prior_env.id,
            label=self.le_lable,
            name=self.le_name
        ).create()
        ak = create_activation_key_for_client_registration(
            ak_name=self.ak_name,
            client_os='rhel7',
            org=self.org,
            environment=environment,
            sat_state='pre'
        )
        rhel7_client = dockerize(
            ak_name=ak.name, distro='rhel7', org_label=self.org.label)
        client_container_id = rhel7_client.values()[0]
        client_name = rhel7_client.keys()[0]
        product, yum_repo = create_yum_test_repo(
            product_name=self.prod_name, repo_url=FAKE_REPO_ZOO3, org=self.org)
        update_product_subscription_in_ak(
            product=product, yum_repo=yum_repo, ak=ak, org=self.org)
        time.sleep(30)
        execute(
            attach_subscription_to_host_from_satellite,
            self.org.id,
            product.name,
            client_name,
            host=get_satellite_host()
        )
        # Refresh subscriptions on client
        execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager refresh',
            host=self.docker_vm
        )
        # Run goferd on client as its docker container
        execute(
            docker_execute_command,
            client_container_id,
            'goferd -f',
            async=True,
            host=self.docker_vm
        )
        create_dict(
            {self.__class__.__name__: rhel7_client}
        )
コード例 #12
0
ファイル: test_errata.py プロジェクト: pondrejk/robottelo
    def test_pre_scenario_generate_errata_for_client(self):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Create  Life Cycle Environment, Product and Custom Yum Repo
            2. Create custom tools, rhel repos and sync them
            3. Create content view and publish it
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7
            6. Check katello agent and goferd service running on host
            7. Generate Errata by Installing Outdated/Older Packages
            8. Collect the Erratum list


        :expectedresults:

            1. The content host is created
            2. errata count, erratum list will be generated to satellite client/content host

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()

        environment = entities.LifecycleEnvironment(
            organization=org
        ).search(query={'search': 'name=Library'})[0]

        product = entities.Product(organization=org).create()
        custom_yum_repo = entities.Repository(product=product,
                                              content_type='yum',
                                              url=FAKE_9_YUM_REPO
                                              ).create()
        product.sync()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        repolist = [custom_yum_repo, tools_repo, rhel_repo]
        content_view = self._publish_content_view(org=org, repolist=repolist)
        ak = entities.ActivationKey(
            content_view=content_view,
            organization=org.id,
            environment=environment
        ).create()
        subscription = entities.Subscription(organization=org).search(query={
            'search': 'name={}'.format(product.name)
        })[0]

        ak.add_subscriptions(data={
            'subscription_id': subscription.id})
        rhel7_client = dockerize(
            ak_name=ak.name, distro='rhel7', org_label=org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        self._host_location_update(client_container_name=client_container_name, loc=loc)
        self._install_or_update_package(client_container_id, 'katello-agent')
        self._run_goferd(client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            self._install_or_update_package(client_container_id, package)
        host = entities.Host().search(query={
            'search': 'activation_key={0}'.format(ak.name)})[0]
        installable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        self.assertGreater(installable_errata_count, 1)
        erratum_list = entities.Errata(repository=custom_yum_repo).search(query={
            'order': 'updated ASC',
            'per_page': 1000,
        })
        errata_ids = [errata.errata_id for errata in erratum_list]
        self.assertEqual(sorted(errata_ids), sorted(FAKE_9_YUM_ERRATUM))
        scenario_dict = {self.__class__.__name__: {
            'rhel_client': rhel7_client,
            'activation_key': ak.name,
            'custom_repo_id': custom_yum_repo.id,
            'product_id': product.id,
            'conten_view_id': content_view.id
        }}
        create_dict(scenario_dict)
コード例 #13
0
    def test_pre_scenario_yum_plugins_count(self):
        """Create content host and register with Satellite.

        :id: preupgrade-45241ada-c2c4-409e-a6e2-92c2cf0ac16c

        :steps:

            1. Before Satellite upgrade.
            2. Create new Organization and Location.
            3. Create Product, custom tools, rhel repos and sync them.
            4. Create activation key and add subscription.
            5. Create a content host, register and install katello-agent on it.

        :expectedresults:

            1. The content host is created.
            2. katello-agent install and goferd run.
        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()

        environment = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'})[0]
        product = entities.Product(organization=org).create()
        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        product.sync()
        repolist = [tools_repo, rhel_repo]
        content_view = self._publish_content_view(org=org, repolist=repolist)

        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=environment).create()
        subscription = entities.Subscription(organization=org).search(
            query={'search': 'name={}'.format(product.name)})[0]

        ak.add_subscriptions(data={'subscription_id': subscription.id})
        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        self._host_location_update(client_container_name=client_container_name,
                                   loc=loc)

        status = execute(docker_execute_command,
                         client_container_id,
                         'subscription-manager identity',
                         host=self.docker_vm)[self.docker_vm]
        self.assertIn(org.name, status)

        self._install_or_update_package(client_container_id, 'katello-agent')
        self._run_goferd(client_container_id)

        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'product_id': product.id,
                'conten_view_id': content_view.id
            }
        }
        create_dict(scenario_dict)
コード例 #14
0
ファイル: test_errata.py プロジェクト: jhutar/robottelo
    def test_pre_scenario_generate_errata_for_client(self):
        """Create product and repo from which the errata will be generated for the
        Satellite client or content host.

        :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21

        :steps:

            1. Create  Life Cycle Environment, Product and Custom Yum Repo
            2. Create custom tools, rhel repos and sync them
            3. Create content view and publish it
            4. Create activation key and add subscription.
            5. Registering Docker Content Host RHEL7
            6. Check katello agent and goferd service running on host
            7. Generate Errata by Installing Outdated/Older Packages
            8. Collect the Erratum list


        :expectedresults:

            1. The content host is created
            2. errata count, erratum list will be generated to satellite client/content host

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()

        environment = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'})[0]

        product = entities.Product(organization=org).create()
        custom_yum_repo = entities.Repository(product=product,
                                              content_type='yum',
                                              url=FAKE_9_YUM_REPO).create()
        product.sync()

        tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product)
        repolist = [custom_yum_repo, tools_repo, rhel_repo]
        content_view = self._publish_content_view(org=org, repolist=repolist)
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=environment).create()
        subscription = entities.Subscription(organization=org).search(
            query={'search': 'name={}'.format(product.name)})[0]

        ak.add_subscriptions(data={'subscription_id': subscription.id})
        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_container_name = [key for key in rhel7_client.keys()][0]
        self._host_location_update(client_container_name=client_container_name,
                                   loc=loc)
        self._install_or_update_package(client_container_id, 'katello-agent')
        self._run_goferd(client_container_id)

        for package in FAKE_9_YUM_OUTDATED_PACKAGES:
            self._install_or_update_package(client_container_id, package)
        host = entities.Host().search(
            query={'search': 'activation_key={0}'.format(ak.name)})[0]
        applicable_errata_count = host.content_facet_attributes[
            'errata_counts']['total']
        self.assertGreater(applicable_errata_count, 1)
        erratum_list = entities.Errata(repository=custom_yum_repo).search(
            query={
                'order': 'updated ASC',
                'per_page': 1000,
            })
        errata_ids = [errata.errata_id for errata in erratum_list]
        self.assertEqual(sorted(errata_ids), sorted(FAKE_9_YUM_ERRATUM))
        scenario_dict = {
            self.__class__.__name__: {
                'rhel_client': rhel7_client,
                'activation_key': ak.name,
                'custom_repo_id': custom_yum_repo.id,
                'product_id': product.id,
                'conten_view_id': content_view.id
            }
        }
        create_dict(scenario_dict)
コード例 #15
0
ファイル: test_client.py プロジェクト: jhutar/robottelo
    def test_pre_scenario_preclient_package_installation(self):
        """Create product and repo from which the package will be installed
        post upgrade

        :id: preupgrade-eedab638-fdc9-41fa-bc81-75dd2790f7be

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created

        """
        prior_env = entities.LifecycleEnvironment(
            organization=self.org
        ).search(query={'search': 'name=Library'})[0]
        environment = entities.LifecycleEnvironment(
            organization=self.org,
            prior=prior_env.id,
            label=self.le_lable,
            name=self.le_name
        ).create()
        ak = create_activation_key_for_client_registration(
            ak_name=self.ak_name,
            client_os='rhel7',
            org=self.org,
            environment=environment,
            sat_state='pre'
        )
        rhel7_client = dockerize(
            ak_name=ak.name, distro='rhel7', org_label=self.org.label)
        client_container_id = list(rhel7_client.values())[0]
        product, yum_repo = create_yum_test_repo(
            product_name=self.prod_name, repo_url=FAKE_REPO_ZOO3, org=self.org)
        update_product_subscription_in_ak(
            product=product, yum_repo=yum_repo, ak=ak, org=self.org)
        attach_custom_product_subscription(
            prod_name=product.name, host_name=str(list(rhel7_client.keys())[0]).lower())
        # Refresh subscriptions on client
        execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager refresh',
            host=self.docker_vm
        )
        # Run goferd on client as its docker container
        kwargs = {'async': True, 'host': self.docker_vm}
        execute(
            docker_execute_command,
            client_container_id,
            'goferd -f',
            **kwargs
        )
        status = execute(docker_execute_command, client_container_id, 'ps -aux',
                         host=self.docker_vm)[self.docker_vm]
        self.assertIn('goferd', status)

        create_dict(
            {self.__class__.__name__: rhel7_client}
        )
コード例 #16
0
ファイル: test_repository.py プロジェクト: lpramuk/robottelo
    def test_pre_scenario_custom_repo_check(self, default_sat):
        """This is pre-upgrade scenario test to verify if we can create a
         custom repository and consume it via content host.

        :id: preupgrade-eb6831b1-c5b6-4941-a325-994a09467478

        :steps:
            1. Before Satellite upgrade.
            2. Create new Organization, Location.
            3. Create Product, custom repo, cv.
            4. Create activation key and add subscription.
            5. Create a content host, register and install package on it.

        :expectedresults:

            1. Custom repo is created.
            2. Package is installed on Content host.

        """
        org = default_sat.api.Organization().create()
        loc = default_sat.api.Location(organization=[org]).create()
        lce = default_sat.api.LifecycleEnvironment(organization=org).create()

        product = default_sat.api.Product(organization=org).create()
        create_repo(rpm1, FILE_PATH)
        repo = default_sat.api.Repository(
            product=product.id,
            url=f'{default_sat.url}/pub/custom_repo').create()
        repo.sync()

        content_view = publish_content_view(org=org, repolist=repo)
        promote(content_view.version[0], lce.id)

        result = default_sat.execute(
            f'ls /var/lib/pulp/published/yum/https/repos/{org.label}/{lce.name}/'
            f'{content_view.label}/custom/{product.label}/{repo.label}/Packages/b/'
            f'|grep {RPM1_NAME}')

        assert result.status == 0
        assert len(result.stdout) >= 1

        subscription = default_sat.api.Subscription(organization=org).search(
            query={'search': f'name={product.name}'})[0]
        ak = default_sat.api.ActivationKey(content_view=content_view,
                                           organization=org.id,
                                           environment=lce).create()
        ak.add_subscriptions(data={'subscription_id': subscription.id})

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]

        host_location_update(client_container_name=client_container_name,
                             logger_obj=logger,
                             loc=loc)
        status = execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager identity',
            host=DOCKER_VM,
        )[DOCKER_VM]
        assert org.name in status
        install_or_update_package(client_hostname=client_container_id,
                                  package=RPM1_NAME)

        scenario_dict = {
            self.__class__.__name__: {
                'content_view_name': content_view.name,
                'lce_id': lce.id,
                'lce_name': lce.name,
                'org_label': org.label,
                'prod_label': product.label,
                'rhel_client': rhel7_client,
                'repo_name': repo.name,
            }
        }
        create_dict(scenario_dict)
コード例 #17
0
    def test_post_scenario_postclient_package_installation(self):
        """Post-upgrade scenario that creates and installs the package on
        post-upgrade client remotely and then verifies if the package installed

        :id: postupgrade-1a881c07-595f-425f-aca9-df2337824a8e

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key
            4. Install package on a pre-upgrade client

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created
            3. The package is installed on post-upgrade client
        """
        rhel7_client = dockerize(distro='rhel7')
        product = entities.Product(
            name='postclient_scenario_product',
            organization=1,
        ).create()
        yum_repo = entities.Repository(
            name='postclient_scenario_repo', product=product
        ).create()
        yum_repo.sync()
        self.cv.repository = [yum_repo]
        cv = self.cv.update(['repository'])
        cv.publish()
        cv = cv.read()  # Published CV with new version
        # Promote CV
        environment = entities.ActivationKey().search(
            query={'search': 'name={}'.format(self.ak)}
        )[0].environment
        cvv = entities.ContentViewVersion(
            id=max([cvv.id for cvv in cv.version])
        ).read()
        cvv.promote(
            data={
                u'environment_id': environment.id,
                u'force': False
            }
        )
        client_id = entities.Host().search(
            query={'search': 'name={}'.format(rhel7_client.keys()[0])}
        )[0].id
        entities.Host().install_content(data={
            'organization_id': 1,
            'included': {'ids': [client_id]},
            'content_type': 'package',
            'content': [self.package_name],
        })
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            rhel7_client.values()[0],
            'rpm -q {}'.format(self.package_name),
            host=self.docker_vm
        )[self.docker_vm]
        time.sleep(10)
        self.assertIn(self.package_name, installed_package)
コード例 #18
0
ファイル: test_client.py プロジェクト: jhutar/robottelo
    def test_post_scenario_postclient_package_installation(self):
        """Post-upgrade scenario that creates and installs the package on
        post-upgrade client remotely and then verifies if the package installed

        :id: postupgrade-1a881c07-595f-425f-aca9-df2337824a8e

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync repo from which the package will be
                installed on content host
            3. Add repo to CV and then in Activation key
            4. Install package on a pre-upgrade client

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created
            3. The package is installed on post-upgrade client
        """
        org = entities.Organization(name=self.org_name).create()
        prior_env = entities.LifecycleEnvironment(organization=org).search(
            query={'search': 'name=Library'}
        )[0]
        environment = entities.LifecycleEnvironment(
            organization=org,
            prior=prior_env.id,
            label=self.le_name,
            name=self.le_name
        ).create()
        ak = create_activation_key_for_client_registration(
            ak_name=self.ak_name,
            client_os='rhel7',
            org=org,
            environment=environment,
            sat_state='post'
        )
        rhel7_client = dockerize(
            ak_name=ak.name, distro='rhel7', org_label=org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_name = list(rhel7_client.keys())[0].lower()
        product, yum_repo = create_yum_test_repo(
            product_name=self.prod_name, repo_url=FAKE_REPO_ZOO3, org=org)
        update_product_subscription_in_ak(
            product=product, yum_repo=yum_repo, ak=ak, org=org)
        attach_custom_product_subscription(
            prod_name=product.name, host_name=client_name)
        # Refresh subscriptions on client
        execute(
            docker_execute_command,
            client_container_id,
            'subscription-manager refresh',
            host=self.docker_vm
        )
        # Run goferd on client as its docker container
        kwargs = {'async': True, 'host': self.docker_vm}
        execute(
            docker_execute_command,
            client_container_id,
            'goferd -f',
            **kwargs
        )
        status = execute(docker_execute_command, client_container_id, 'ps -aux',
                         host=self.docker_vm)[self.docker_vm]
        self.assertIn('goferd', status)
        # Holding on for 30 seconds wihle goferd starts
        time.sleep(30)
        client_id = entities.Host().search(
            query={'search': 'name={}'.format(client_name)}
        )[0].id
        entities.Host().install_content(data={
            'organization_id': org.id,
            'included': {'ids': [client_id]},
            'content_type': 'package',
            'content': [self.package_name],
        })
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'rpm -q {}'.format(self.package_name),
            host=self.docker_vm
        )[self.docker_vm]
        self.assertIn(self.package_name, installed_package)
コード例 #19
0
    def test_pre_scenario_custom_repo_check(self):
        """This is pre-upgrade scenario test to verify if we can create a
         custom repository and consume it via content host.

        :id: preupgrade-eb6831b1-c5b6-4941-a325-994a09467478

        :steps:
            1. Before Satellite upgrade.
            2. Create new Organization, Location.
            3. Create Product, custom repo, cv.
            4. Create activation key and add subscription.
            5. Create a content host, register and install package on it.

        :expectedresults:

            1. Custom repo is created.
            2. Package is installed on Content host.

        """
        org = entities.Organization().create()
        loc = entities.Location(organization=[org]).create()
        lce = entities.LifecycleEnvironment(organization=org).create()

        product = entities.Product(organization=org).create()

        self._create_repo()
        repo = entities.Repository(product=product.id,
                                   url=self.custom_repo).create()
        repo.sync()

        content_view = self._create_publish_content_view(org=org, repo=repo)
        promote(content_view.version[0], lce.id)

        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/'
            'Packages/b/|grep {}'.format(org.label, lce.name,
                                         content_view.label, product.label,
                                         repo.label, self.rpm1_name))

        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)

        subscription = entities.Subscription(organization=org).search(
            query={'search': 'name={}'.format(product.name)})[0]
        ak = entities.ActivationKey(content_view=content_view,
                                    organization=org.id,
                                    environment=lce).create()
        ak.add_subscriptions(data={'subscription_id': subscription.id})

        rhel7_client = dockerize(ak_name=ak.name,
                                 distro='rhel7',
                                 org_label=org.label)
        client_container_id = [value for value in rhel7_client.values()][0]
        client_container_name = [key for key in rhel7_client.keys()][0]

        self._host_location_update(client_container_name=client_container_name,
                                   loc=loc)
        status = execute(docker_execute_command,
                         client_container_id,
                         'subscription-manager identity',
                         host=self.docker_vm)[self.docker_vm]
        self.assertIn(org.name, status)
        self._install_package(client_container_id, self.rpm1_name)

        scenario_dict = {
            self.__class__.__name__: {
                'content_view_name': content_view.name,
                'lce_id': lce.id,
                'lce_name': lce.name,
                'org_label': org.label,
                'prod_label': product.label,
                'rhel_client': rhel7_client,
                'repo_name': repo.name,
            }
        }
        create_dict(scenario_dict)
コード例 #20
0
    def test_post_scenario_postclient_package_installation(
            default_org, post_upgrade_repo, module_ak, module_lce):
        """Post-upgrade test that creates a client, installs a package on
        the post-upgrade created client and then verifies the package is installed.

        :id: postupgrade-1a881c07-595f-425f-aca9-df2337824a8e

        :steps:

            1. Create a content host with existing client ak
            2. Create and sync new post-upgrade repo from which a package will be
                installed on content host
            3. Add repo to CV and then in Activation key
            4. Install package on the pre-upgrade client

        :expectedresults:

            1. The content host is created
            2. The new repo and its product has been added to ak using which
                the content host is created
            3. The package is installed on post-upgrade client
        """
        rhel7_client = dockerize(ak_name=module_ak.name,
                                 distro='rhel7',
                                 org_label=default_org.label)
        client_container_id = list(rhel7_client.values())[0]
        client_name = list(rhel7_client.keys())[0].lower()
        # Wait 60 seconds as script in /tmp takes up to 2 min inc the repo sync time
        time.sleep(60)
        # Use yum install again in case script was not yet finished
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'yum -y install katello-agent',
            host=docker_vm,
        )[docker_vm]
        # Assert gofer was installed after yum completes
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            'rpm -q gofer',
            host=docker_vm,
        )[docker_vm]
        assert 'package gofer is not installed' not in installed_package
        # Run goferd on client as its docker container
        kwargs = {'async': True, 'host': docker_vm}
        execute(docker_execute_command, client_container_id, 'goferd -f',
                **kwargs)
        # Holding on for 30 seconds while goferd starts
        time.sleep(30)
        status = execute(docker_execute_command,
                         client_container_id,
                         'ps -aux',
                         host=docker_vm)[docker_vm]
        assert 'goferd' in status
        client_id = entities.Host().search(
            query={'search': f'name={client_name}'})[0].id
        entities.Host().install_content(
            data={
                'organization_id': default_org.id,
                'included': {
                    'ids': [client_id]
                },
                'content_type': 'package',
                'content': [FAKE_4_CUSTOM_PACKAGE],
            })
        # Validate if that package is really installed
        installed_package = execute(
            docker_execute_command,
            client_container_id,
            f'rpm -q {FAKE_4_CUSTOM_PACKAGE}',
            host=docker_vm,
        )[docker_vm]
        assert FAKE_4_CUSTOM_PACKAGE in installed_package
コード例 #21
0
ファイル: test_contentview.py プロジェクト: jhutar/robottelo
    def test_pre_user_scenario_bug_1429201(self):
        """This is pre-upgrade scenario test to verify if we can create a
         custom repository and consume it via client

         :id: 8fb8ec87-efa5-43ed-8cb3-960ef9cd6df2

         :steps:
             1. Create repository RepoFoo that you will later add to your
                Satellite. This repository should contain PackageFoo-1.0.rpm
             2. Install satellite 6.1
             3. Create custom product ProductFoo pointing to repository RepoFoo
             4. Sync RepoFoo
             5. Create content view CVFoo
             6. Add RepoFoo to CVFoo
             7. Publish version 1 of CVFoo

         :expectedresults: The client and product is created successfully

         :BZ: 1429201
         """
        self.create_repo()
        # End to End product + ak association
        print(hammer.hammer_product_create(self.prd_name, self.org_id))
        print(hammer.hammer_repository_create(
            self.repo_name,
            self.org_id,
            self.prd_name,
            self.custom_repo))
        print(hammer.hammer(
            'lifecycle-environment create --name "{0}" '
            '--organization-id {1} --prior-id "{2}"'.format(
                self.lc_name, self.org_id, 1)))
        print(hammer.hammer_repository_synchronize(
            self.repo_name,
            self.org_id,
            self.prd_name))
        print(hammer.hammer_content_view_create(self.cv_name, self.org_id))
        print(hammer.hammer_content_view_add_repository(
            self.cv_name,
            self.org_id,
            self.prd_name,
            self.repo_name))
        print(hammer.hammer_content_view_publish(self.cv_name, self.org_id))
        latest_repo_version = hammer.get_latest_cv_version(self.cv_name)
        lc_result = hammer.hammer(
            '"{0}" info --name "{1}" --organization-id '
            '{2}'.format('lifecycle-environment',
                         self.lc_name,
                         self.org_id
                         )
                                  )
        lifecycle_id = hammer.get_attribute_value(
            lc_result,
            self.lc_name,
            'id'
            )
        print(hammer.hammer_content_view_promote_version(
            self.cv_name,
            latest_repo_version,
            lifecycle_id,
            self.org_id
            ))
        print(hammer.hammer_activation_key_create(
            self.ak_name,
            self.org_id,
            self.cv_name,
            self.lc_name
            ))
        print(hammer.hammer_activation_key_add_subscription(
            self.ak_name,
            self.org_id,
            self.prd_name
            ))
        time.sleep(5)
        # Creating a rhel7 vm and subscribing to AK
        container_ids = dockerize(self.ak_name, 'rhel7')
        # Subscription manager needs time to register
        execute(docker_wait_until_repo_list,
                list(container_ids.values())[0],
                host=self.docker_vm)
        result = execute(
            docker_execute_command,
            list(container_ids.values())[0],
            'yum list {0} | grep {0}'.format(self.rpm1_name.split('-')[0]),
            host=self.docker_vm
            )
        # Info on created entities to assert the test case using hammer info
        prd_info = hammer.hammer(
            '"{0}" info --name "{1}" --organization-id '
            '{2}'.format('product', self.prd_name, self.org_id)
        )
        self.assertEqual(
            self.prd_name,
            hammer.get_attribute_value(prd_info, self.prd_name, 'name')
        )
        self.assertIsNotNone(container_ids)
        self.assertIn(self.repo_name, list(result.values())[0])
        global_dict = {self.__class__.__name__: {
            'prd_name': self.prd_name,
            'ak_name': self.ak_name,
            'repo_name': self.repo_name,
            'container_ids': container_ids
        }
        }
        create_dict(global_dict)