def order_retire_service(request, context, appliance, catalog_item):
    """Common method to order and then retire a service."""
    with appliance:
        # Order the service
        provision_request = ServiceCatalogs(appliance,
                                            catalog=catalog_item.catalog,
                                            name=catalog_item.name).order()
        provision_request.wait_for_request(method='ui')
        assert provision_request.is_succeeded(method='ui')
        service = MyService(appliance, catalog_item.dialog.label)

        @request.addfinalizer
        def _clear_request_service():
            if provision_request.exists():
                provision_request.remove_request()
            if service.exists:
                service.delete()

        assert service.exists

        # Retire the service via UI or REST, depending on context
        with appliance.context.use(context):
            retire_request = service.retire()
            assert retire_request and retire_request.exists()

        @request.addfinalizer
        def _remove_retire_request():
            retire_request.remove_request()

        wait_for(lambda: service.is_retired,
                 delay=5,
                 num_sec=600,
                 fail_func=service.browser.refresh,
                 message="Waiting for service to retire")
예제 #2
0
def test_service_provision_retire_from_global_region(request, replicated_appliances, provider,
        context, catalog_item):
    """From the global appliance in a multi-region appliance configuration, order and then retire
    a VM provisioning sevice on the remote appliance.

    Polarion:
        assignee: tpapaioa
        caseimportance: high
        casecomponent: Services
        initialEstimate: 1/3h
    """
    remote_appliance, global_appliance = replicated_appliances

    with global_appliance:
        # Order the service
        provision_request = ServiceCatalogs(global_appliance, catalog_item.catalog,
            catalog_item.name).order()

        provision_request.wait_for_request(method='ui')
        assert provision_request.is_succeeded(method='ui')

        service = MyService(global_appliance, catalog_item.dialog.label)

        @request.addfinalizer
        def _clear_request_service():
            if provision_request.exists():
                provision_request.remove_request()
            if service.exists:
                service.delete()

        assert service.exists

        # Retire the service via UI or REST, depending on context
        if context.name == 'UI':
            retire_request = service.retire()
            assert retire_request and retire_request.exists()
        else:
            # TODO: implement retire() via REST using sentaku context
            services = global_appliance.rest_api.collections.services
            api_service = services.get(name=service.name)
            api_retire_requests = services.action.request_retire(api_service)
            assert len(api_retire_requests) == 1
            api_retire_request = api_retire_requests[0]
            assert api_retire_request and api_retire_request.exists
            retire_request = global_appliance.collections.requests.instantiate(
                f'Service Retire for: {service.name}')

        @request.addfinalizer
        def _remove_retire_request():
            retire_request.remove_request()

        wait_for(lambda: service.is_retired, delay=5, num_sec=300,
            fail_func=service.browser.refresh, message="Waiting for service to retire")

        vm_name = f"{catalog_item.prov_data['catalog']['vm_name']}0001"
        vm = global_appliance.provider_based_collection(provider).instantiate(vm_name, provider)
        assert vm.wait_for_vm_state_change(from_any_provider=True, desired_state='archived')
예제 #3
0
def test_retire_service_and_bundle_vms(provider, request, appliance,
                                       catalog_item_setups):
    """
    Bugzilla:
        1654165
    Polarion:
        assignee: nansari
        casecomponent: Services
        initialEstimate: 1/6h
        startsin: 5.10
        testSteps:
            1. Create catalog and create two catalog items
            2. Create bundle with above two catalog items
            3. Order the catalog bundle
            4. Go to My services
            5. Check the Both VMs
            6. Retire the services
        expectedResults:
            1.
            2.
            3.
            4.
            5. Both VMs should be present
            6. Services should retire and vms as well
    """
    cat_list, catalog_item = catalog_item_setups

    collection = provider.appliance.provider_based_collection(provider)
    vm_name1 = f'{cat_list[0].prov_data["catalog"]["vm_name"]}0001'
    vm_name2 = f'{cat_list[1].prov_data["catalog"]["vm_name"]}0002'

    vm1 = collection.instantiate(vm_name1, provider)
    vm2 = collection.instantiate(vm_name2, provider)

    # Creating catalog bundle of two catalog items
    catalog_bundle = appliance.collections.catalog_bundles.create(
        name=fauxfactory.gen_alphanumeric(),
        description="catalog_bundle",
        display_in=True,
        catalog=catalog_item.catalog,
        dialog=catalog_item.dialog,
        catalog_items=[cat_item.name for cat_item in cat_list],
    )
    request.addfinalizer(catalog_bundle.delete_if_exists)

    # Ordering service catalog bundle
    provision_request = ServiceCatalogs(appliance, catalog_bundle.catalog,
                                        catalog_bundle.name).order()

    provision_request.wait_for_request(method='ui')
    assert provision_request.is_succeeded(method="ui")

    service = MyService(appliance, catalog_item.dialog.label)

    @request.addfinalizer
    def _clear_request_service():
        if provision_request.exists():
            provision_request.remove_request(method="rest")
        if service.exists:
            service.delete()

    assert service.exists

    # Retire service
    retire_request = service.retire()
    assert retire_request.exists()

    @request.addfinalizer
    def _clear_retire_request():
        if retire_request.exists():
            retire_request.remove_request()

    wait_for(lambda: service.is_retired,
             delay=5,
             num_sec=120,
             fail_func=service.browser.refresh,
             message="waiting for service retire")
    assert vm1.wait_for_vm_state_change(from_any_provider=True,
                                        desired_state='archived')
    assert vm2.wait_for_vm_state_change(from_any_provider=True,
                                        desired_state='archived')