예제 #1
0
def setup_capsule_content(activation_key_name, content_view_name,
                          organization_id, product_name, rhel_repo_name,
                          rhel_repo_url, satellite_capsule_repo_name,
                          satellite_capsule_repo_url,
                          satellite_tools_repo_name, satellite_tools_repo_url):
    """Setup the content used to provision a capsule.


    :param activation_key_name: name of the activation key which will be
        created
    :param content_view_name: name of the content view which will be created
    :param organization_id: organization where all entities will be created
    :param product_name: name of the product which will be created
    :param rhel_repo_name: name of the RHEL repository which will be created
    :param rhel_repo_url: URL of the RHEL repository which will be created
    :param satellite_capsule_repo_name: name of the capsule repository which
        will be created
    :param satellite_capsule_repo_url: URL of the capsule repository which will
        be created
    :param satellite_tools_repo_name: name of the satellite tools repository
        which will be created
    :param satellite_tools_repo_url: URL of the satellite tools repository
        which will be created
    """
    hammer_product_create(product_name, organization_id)
    hammer_repository_create(rhel_repo_name, organization_id, product_name,
                             rhel_repo_url)
    hammer_repository_create(satellite_capsule_repo_name, organization_id,
                             product_name, satellite_capsule_repo_url)
    hammer_repository_create(satellite_tools_repo_name, organization_id,
                             product_name, satellite_tools_repo_url)
    hammer_repository_synchronize(rhel_repo_name, organization_id,
                                  product_name)
    hammer_repository_synchronize(satellite_capsule_repo_name, organization_id,
                                  product_name)
    hammer_repository_synchronize(satellite_tools_repo_name, organization_id,
                                  product_name)
    hammer_content_view_create(content_view_name, organization_id)
    hammer_content_view_add_repository(content_view_name, organization_id,
                                       product_name, rhel_repo_name)
    hammer_content_view_add_repository(content_view_name, organization_id,
                                       product_name,
                                       satellite_capsule_repo_name)
    hammer_content_view_add_repository(content_view_name, organization_id,
                                       product_name, satellite_tools_repo_name)
    hammer_content_view_publish(content_view_name, organization_id)
    product_id = run(
        "hammer --csv subscription list --organization-id='{0}' "
        "--search='name=\"{1}\"' | awk -F, 'NR>1{{print$8}}'".format(
            organization_id, product_name),
        quiet=True)
    hammer_activation_key_create(activation_key_name, organization_id,
                                 content_view_name)
    hammer_activation_key_add_subscription(activation_key_name,
                                           organization_id, product_id)
    def test_pre_user_scenario_capsule_sync(self):
        """Pre-upgrade scenario that creates and sync repository with
        rpm in satellite which will be synced in post upgrade scenario.


        :id: preupgrade-eb8970fa-98cc-4a99-99fb-1c12c4e319c9

        :steps:
            1. Before Satellite upgrade, Sync a repo/rpm in satellite.

        :expectedresults: The repo/rpm should be synced to satellite

         """
        _, env_name = hammer.hammer_determine_cv_and_env_from_ak(
            self.activation_key, '1')
        self.create_repo()
        print hammer.hammer_product_create(self.prod_name, self.org_id)
        prod_list = hammer.hammer('product list --organization-id {}'.format(
            self.org_id))
        self.assertEqual(
            self.prod_name,
            hammer.get_attribute_value(prod_list, self.prod_name, 'name'))
        print hammer.hammer_repository_create(self.repo_name, self.org_id,
                                              self.prod_name, self.repo_url)
        repo_list = hammer.hammer(
            'repository list --product {0} --organization-id {1}'.format(
                self.prod_name, self.org_id))
        self.assertEqual(
            self.repo_name,
            hammer.get_attribute_value(repo_list, self.repo_name, 'name'))
        print hammer.hammer_repository_synchronize(self.repo_name, self.org_id,
                                                   self.prod_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.prod_name, self.repo_name)
        print hammer.hammer_content_view_publish(self.cv_name, self.org_id)
        cv_ver = hammer.get_latest_cv_version(self.cv_name)
        env_data = hammer.hammer(
            'lifecycle-environment list --organization-id {0} '
            '--name {1}'.format(self.org_id, env_name))
        env_id = hammer.get_attribute_value(env_data, env_name, 'id')
        print hammer.hammer_content_view_promote_version(
            self.cv_name, cv_ver, env_id, self.org_id)
        global_dict = {self.__class__.__name__: {'env_name': env_name}}
        create_dict(global_dict)
예제 #3
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)
예제 #4
0
def setup_capsule_content(
        activation_key_name,
        content_view_name,
        organization_id,
        product_name,
        rhel_repo_name,
        rhel_repo_url,
        satellite_capsule_repo_name,
        satellite_capsule_repo_url,
        satellite_tools_repo_name,
        satellite_tools_repo_url):
    """Setup the content used to provision a capsule.


    :param activation_key_name: name of the activation key which will be
        created
    :param content_view_name: name of the content view which will be created
    :param organization_id: organization where all entities will be created
    :param product_name: name of the product which will be created
    :param rhel_repo_name: name of the RHEL repository which will be created
    :param rhel_repo_url: URL of the RHEL repository which will be created
    :param satellite_capsule_repo_name: name of the capsule repository which
        will be created
    :param satellite_capsule_repo_url: URL of the capsule repository which will
        be created
    :param satellite_tools_repo_name: name of the satellite tools repository
        which will be created
    :param satellite_tools_repo_url: URL of the satellite tools repository
        which will be created
    """
    hammer_product_create(product_name, organization_id)
    hammer_repository_create(
        rhel_repo_name, organization_id, product_name, rhel_repo_url)
    hammer_repository_create(
        satellite_capsule_repo_name,
        organization_id,
        product_name,
        satellite_capsule_repo_url
    )
    hammer_repository_create(
        satellite_tools_repo_name,
        organization_id,
        product_name,
        satellite_tools_repo_url
    )
    hammer_repository_synchronize(
        rhel_repo_name, organization_id, product_name)
    hammer_repository_synchronize(
        satellite_capsule_repo_name, organization_id, product_name)
    hammer_repository_synchronize(
        satellite_tools_repo_name, organization_id, product_name)
    hammer_content_view_create(
        content_view_name, organization_id)
    hammer_content_view_add_repository(
        content_view_name, organization_id, product_name, rhel_repo_name)
    hammer_content_view_add_repository(
        content_view_name,
        organization_id,
        product_name,
        satellite_capsule_repo_name
    )
    hammer_content_view_add_repository(
        content_view_name,
        organization_id,
        product_name,
        satellite_tools_repo_name
    )
    hammer_content_view_publish(content_view_name, organization_id)
    product_id = run(
        "hammer --csv subscription list --organization-id='{0}' "
        "--search='name=\"{1}\"' | awk -F, 'NR>1{{print$8}}'"
        .format(organization_id, product_name),
        quiet=True
    )
    hammer_activation_key_create(
        activation_key_name, organization_id, content_view_name)
    hammer_activation_key_add_subscription(
        activation_key_name, organization_id, product_id)
    def test_post_user_scenario_capsule_sync_2(self):
        """Post-upgrade scenario that creates and sync repository with
        rpm, sync capsule with satellite and verifies if the repo/rpm in
        satellite is synced to capsule.


        :id: postupgrade-7c1d3441-3e8d-4ac2-8102-30e18274658c

        :steps:
            1. Post Upgrade , Sync a repo/rpm in satellite.
            2. Run capsule sync.
            3. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The repo/rpm should be synced to satellite
            2. Capsule sync should be successful
            3. The repo/rpm from satellite should be synced to capsule

        """
        self.create_repo()
        print hammer.hammer_product_create(self.prod_name, self.org_id)
        prod_list = hammer.hammer('product list --organization-id {}'.format(
            self.org_id))
        self.assertEqual(
            self.prod_name,
            hammer.get_attribute_value(prod_list, self.prod_name, 'name'))
        print hammer.hammer_repository_create(self.repo_name, self.org_id,
                                              self.prod_name, self.repo_url)
        repo_list = hammer.hammer(
            'repository list --product {0} --organization-id {1}'.format(
                self.prod_name, self.org_id))
        self.assertEqual(
            self.repo_name,
            hammer.get_attribute_value(repo_list, self.repo_name, 'name'))
        print hammer.hammer_repository_synchronize(self.repo_name, self.org_id,
                                                   self.prod_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.prod_name, self.repo_name)
        print hammer.hammer_content_view_publish(self.cv_name, self.org_id)
        cv_ver = hammer.get_latest_cv_version(self.cv_name)
        env_data = hammer.hammer(
            'lifecycle-environment list --organization-id {0} '
            '--name {1}'.format(self.org_id, self.env_name))
        env_id = hammer.get_attribute_value(env_data, self.env_name, 'id')
        print hammer.hammer_content_view_promote_version(
            self.cv_name, cv_ver, env_id, self.org_id)
        cap_data = hammer.hammer('capsule list')
        cap_id = hammer.get_attribute_value(cap_data, self.cap_host, 'id')
        org_data = hammer.hammer('organization list')
        org_name = hammer.get_attribute_value(org_data, int(self.org_id),
                                              'name')
        print hammer.hammer(
            'capsule content synchronize --id {0}'.format(cap_id))
        result = execute(lambda: run(
            '[ -f /var/lib/pulp/published/yum/http/repos/'
            '{0}/{1}/{2}/custom/{3}/{4}/Packages/c/{5} ]; '
            'echo $?'.format(org_name, self.env_name, self.cv_name, self.
                             prod_name, self.repo_name, self.rpm_name)),
                         host=self.cap_host)[self.cap_host]
        self.assertEqual('0', result)
예제 #6
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)