示例#1
0
def test_positive_view_vdc_subscription_products(session):
    """Ensure that Virtual Datacenters subscription provided products is
    not empty and that a consumed product exist in content products.

    :id: cc4593f0-66ab-4bf6-87d1-d4bd9c89eba5

    :customerscenario: true

    :steps:
        1. Upload a manifest with Virtual Datacenters subscription
        2. Enable a products provided by Virtual Datacenters subscription,
           and synchronize the auto created repository
        3. Create content view with the product repository, and publish it
        4. Create a lifecycle environment and promote the content view to
           it.
        5. Create an activation key with the content view and lifecycle
           environment
        6. Subscribe a host to the activation key
        7. Goto Hosts -> Content hosts and select the created content host
        8. Attach VDC subscription to content host
        9. Goto Content -> Red Hat Subscription
        10. Select Virtual Datacenters subscription

    :expectedresults:
        1. assert that the provided products is not empty
        2. assert that the enabled product is in subscription Product Content

    :BZ: 1366327

    :CaseLevel: System
    """
    org = entities.Organization().create()
    lce = entities.LifecycleEnvironment(organization=org).create()
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7, repositories=[RHELAnsibleEngineRepository(cdn=True)]
    )
    product_name = repos_collection.rh_repos[0].data['product']
    repos_collection.setup_content(
        org.id, lce.id, upload_manifest=True, rh_subscriptions=[DEFAULT_SUBSCRIPTION_NAME]
    )
    with VirtualMachine() as vm:
        setup_virtual_machine(
            vm,
            org.label,
            activation_key=repos_collection.setup_content_data['activation_key']['name'],
            install_katello_agent=False,
        )
        with session:
            session.organization.select(org.name)
            session.contenthost.add_subscription(vm.hostname, VDC_SUBSCRIPTION_NAME)
            provided_products = session.subscription.provided_products(VDC_SUBSCRIPTION_NAME)
            # ensure that subscription provided products list is not empty and that the product is
            # in the provided products.
            assert provided_products and product_name in provided_products
            content_products = session.subscription.content_products(VDC_SUBSCRIPTION_NAME)
            # ensure that subscription enabled products list is not empty and that product is in
            # content products.
            assert content_products and product_name in content_products
示例#2
0
def module_repos_col(module_org, module_lce):
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7,
        repositories=[
            SatelliteToolsRepository(),
            # As Satellite Tools may be added as custom repo and to have a "Fully entitled" host,
            # force the host to consume an RH product with adding a cdn repo.
            RHELAnsibleEngineRepository(cdn=True),
            YumRepository(url=CUSTOM_REPO_URL),
        ])
    repos_collection.setup_content(module_org.id, module_lce.id)
    return repos_collection
示例#3
0
def repos_collection(module_org):
    """Adds required repositories, AK, LCE and CV for content host testing"""
    lce = entities.LifecycleEnvironment(organization=module_org).create()
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7,
        repositories=[
            RHELAnsibleEngineRepository(cdn=True),
            SatelliteToolsRepository(),
            YumRepository(url=FAKE_1_YUM_REPO),
            YumRepository(url=FAKE_6_YUM_REPO)
        ])
    repos_collection.setup_content(module_org.id, lce.id, upload_manifest=True)
    return repos_collection
示例#4
0
def module_erratatype_repos_col(module_org, module_lce):
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7,
        repositories=[
            SatelliteToolsRepository(),
            # As Satellite Tools may be added as custom repo and to have a "Fully entitled" host,
            # force the host to consume an RH product with adding a cdn repo.
            RHELAnsibleEngineRepository(cdn=True),
            # add a repo with errata of different types (security, advisory, etc)
            YumRepository(url=FAKE_9_YUM_REPO),
        ],
    )
    repos_collection.setup_content(module_org.id, module_lce.id)
    return repos_collection
示例#5
0
def test_positive_filtered_errata_status_installable_param(
        session, errata_status_installable):
    """Filter errata for specific content view and verify that host that
    was registered using that content view has different states in
    correspondence to filtered errata and `errata status installable`
    settings flag value

    :id: ed94cf34-b8b9-4411-8edc-5e210ea6af4f

    :Steps:

        1. Prepare setup: Create Lifecycle Environment, Content View,
            Activation Key and all necessary repos
        2. Register Content Host using created data
        3. Create necessary Content View Filter and Rule for repository errata
        4. Publish and Promote Content View to a new version.
        5. Go to created Host page and check its properties
        6. Change 'errata status installable' flag in the settings and
            check host properties once more

    :expectedresults: Check that 'errata status installable' flag works as intended

    :BZ: 1368254

    :CaseLevel: System
    """
    org = entities.Organization().create()
    lce = entities.LifecycleEnvironment(organization=org).create()
    repos_collection = RepositoryCollection(
        distro=DISTRO_RHEL7,
        repositories=[
            SatelliteToolsRepository(),
            # As Satellite Tools may be added as custom repo and to have a "Fully entitled" host,
            # force the host to consume an RH product with adding a cdn repo.
            RHELAnsibleEngineRepository(cdn=True),
            YumRepository(url=CUSTOM_REPO_URL),
        ],
    )
    repos_collection.setup_content(org.id, lce.id, upload_manifest=True)
    with VirtualMachine(distro=repos_collection.distro) as client:
        repos_collection.setup_virtual_machine(client)
        assert _install_client_package(client,
                                       FAKE_1_CUSTOM_PACKAGE,
                                       errata_applicability=True)
        # Adding content view filter and content view filter rule to exclude errata for the
        # installed package.
        content_view = entities.ContentView(
            id=repos_collection.setup_content_data['content_view']
            ['id']).read()
        cv_filter = entities.ErratumContentViewFilter(
            content_view=content_view, inclusion=False).create()
        errata = entities.Errata(
            content_view_version=content_view.version[-1]).search(query=dict(
                search=f'errata_id="{CUSTOM_REPO_ERRATA_ID}"'))[0]
        entities.ContentViewFilterRule(content_view_filter=cv_filter,
                                       errata=errata).create()
        content_view.publish()
        content_view = content_view.read()
        content_view_version = content_view.version[-1]
        promote(content_view_version, lce.id)
        with session:
            session.organization.select(org_name=org.name)
            _set_setting_value(errata_status_installable, True)
            expected_values = {
                'Status': 'OK',
                'Errata': 'All errata applied',
                'Subscription': 'Fully entitled',
            }
            host_details_values = session.host.get_details(client.hostname)
            actual_values = {
                key: value
                for key, value in host_details_values['properties']
                ['properties_table'].items() if key in expected_values
            }
            for key in actual_values:
                assert expected_values[key] in actual_values[
                    key], 'Expected text not found'
            _set_setting_value(errata_status_installable, False)
            expected_values = {
                'Status': 'Error',
                'Errata': 'Security errata applicable',
                'Subscription': 'Fully entitled',
            }
            # navigate to host main page by making a search, to refresh the host details page
            session.host.search(client.hostname)
            host_details_values = session.host.get_details(client.hostname)
            actual_values = {
                key: value
                for key, value in host_details_values['properties']
                ['properties_table'].items() if key in expected_values
            }
            for key in actual_values:
                assert expected_values[key] in actual_values[
                    key], 'Expected text not found'
示例#6
0
def test_positive_view_vdc_guest_subscription_products(session,
                                                       rhel7_contenthost):
    """Ensure that Virtual Data Centers guest subscription Provided
    Products and Content Products are not empty.

    :id: 4a6f6933-8e26-4c47-b544-a300e11a8454

    :customerscenario: true

    :steps:
        1. Upload a manifest with Virtual Datacenters subscription
        2. Config a virtual machine virt-who service for a hypervisor
        3. Ensure virt-who hypervisor host exist
        4. Attach Virtual Datacenters subscription to the virt-who
           hypervisor
        5. Go to Content -> Red Hat Subscription
        6. Select Virtual Datacenters subscription with type Guests of
           virt-who hypervisor

    :expectedresults:
        1. The Virtual Data Centers guests subscription Provided Products
           is not empty and one of the provided products exist
        2. The Virtual Data Centers guests subscription Product Content is
           not empty and one of the consumed products exist

    :BZ: 1395788, 1506636, 1487317

    :CaseLevel: System
    """
    org = entities.Organization().create()
    lce = entities.LifecycleEnvironment(organization=org).create()
    provisioning_server = settings.compute_resources.libvirt_hostname
    rh_product_repository = RHELAnsibleEngineRepository(cdn=True)
    product_name = rh_product_repository.data['product']
    # Create a new virt-who config
    virt_who_config = make_virt_who_config({
        'organization-id':
        org.id,
        'hypervisor-type':
        VIRT_WHO_HYPERVISOR_TYPES['libvirt'],
        'hypervisor-server':
        f'qemu+ssh://{provisioning_server}/system',
        'hypervisor-username':
        '******',
    })
    # configure virtual machine and setup virt-who service
    virt_who_data = rhel7_contenthost.virt_who_hypervisor_config(
        virt_who_config['general-information']['id'],
        org_id=org.id,
        lce_id=lce.id,
        hypervisor_hostname=provisioning_server,
        configure_ssh=True,
        subscription_name=VDC_SUBSCRIPTION_NAME,
        extra_repos=[rh_product_repository.data],
    )
    virt_who_hypervisor_host = virt_who_data['virt_who_hypervisor_host']
    with session:
        session.organization.select(org.name)
        # ensure that VDS subscription is assigned to virt-who hypervisor
        content_hosts = session.contenthost.search(
            f'subscription_name = "{VDC_SUBSCRIPTION_NAME}" '
            f'and name = "{virt_who_hypervisor_host["name"]}"')
        assert content_hosts and content_hosts[0][
            'Name'] == virt_who_hypervisor_host['name']
        # ensure that hypervisor guests subscription provided products list is not empty and
        # that the product is in provided products.
        provided_products = session.subscription.provided_products(
            VDC_SUBSCRIPTION_NAME, virt_who=True)
        assert product_name in provided_products
        # ensure that hypervisor guests subscription content products list is not empty and
        # that product is in content products.
        content_products = session.subscription.content_products(
            VDC_SUBSCRIPTION_NAME, virt_who=True)
        assert product_name in content_products