Esempio n. 1
0
def provisioned_instance(provider, testing_instance, appliance):
    """ Checks provisioning status for instance """
    instance, inst_args, image = testing_instance
    instance.create(**inst_args)
    logger.info('Waiting for cfme provision request for vm %s', instance.name)
    request_description = 'Provision from [{}] to [{}]'.format(
        image, instance.name)
    provision_request = RequestCollection(appliance).instantiate(
        request_description)
    try:
        provision_request.wait_for_request(method='ui')
    except Exception as e:
        logger.info("Provision failed {}: {}".format(
            e, provision_request.request_state))
        raise e
    assert provision_request.is_succeeded(
        method='ui'), ("Provisioning failed with the message {}".format(
            provision_request.row.last_message.text))
    instance.wait_to_appear(timeout=800)
    provider.refresh_provider_relationships()
    logger.info("Refreshing provider relationships and power states")
    refresh_timer = RefreshTimer(time_for_refresh=300)
    wait_for(provider.is_refreshed, [refresh_timer],
             message="is_refreshed",
             num_sec=1000,
             delay=60,
             handle_exception=True)
    return instance
def myservice(appliance, setup_provider, provider, catalog_item, request):
    """Tests my service

    Metadata:
        test_flag: provision
    """
    vm_name = version.pick({
        version.LOWEST:
        catalog_item.provisioning_data["vm_name"] + '_0001',
        '5.7':
        catalog_item.provisioning_data["vm_name"] + '0001'
    })
    catalog_item.create()
    service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog,
                                       catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s',
                catalog_item.name)
    request_description = catalog_item.name
    service_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    service_request.wait_for_request()
    assert service_request.is_succeeded()

    yield catalog_item.name, vm_name

    cleanup_vm(vm_name, provider)
def test_retire_stack(appliance, provider, provisioning, catalog, catalog_item, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    catalog_item, template = catalog_item
    DefaultView.set_default_view("Stacks", "Grid View")

    stack_data = prepare_stack_data(provider, provisioning)
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name, stack_data)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service {}'.format(catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(request_description,
                                                                 partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
    stack = StackCollection(appliance).instantiate(stack_data['stack_name'], provider=provider)
    stack.wait_for_exists()
    stack.retire_stack()

    @request.addfinalizer
    def _cleanup_vms():
        clean_up(stack_data, provider)
def test_provision_from_template(appliance, provider, testing_instance,
                                 soft_assert):
    """ Tests instance provision from template

    Metadata:
        test_flag: provision
    """
    instance, inst_args, image = testing_instance
    instance.create(**inst_args)
    logger.info('Waiting for cfme provision request for vm %s', instance.name)
    request_description = 'Provision from [{}] to [{}]'.format(
        image, instance.name)
    provision_request = RequestCollection(appliance).instantiate(
        request_description)
    try:
        provision_request.wait_for_request(method='ui')
    except Exception as e:
        logger.info("Provision failed {}: {}".format(
            e, provision_request.row.last_message.text()))
        raise e
    assert provision_request.is_succeeded(method='ui'), \
        "Provisioning failed with the message {}".format(provision_request.row.last_message.text)
    instance.wait_to_appear(timeout=800)
    provider.refresh_provider_relationships()
    logger.info("Refreshing provider relationships and power states")
    refresh_timer = RefreshTimer(time_for_refresh=300)
    wait_for(provider.is_refreshed, [refresh_timer],
             message="is_refreshed",
             num_sec=1000,
             delay=60,
             handle_exception=True)
    soft_assert(instance.does_vm_exist_on_provider(),
                "Instance wasn't provisioned")
Esempio n. 5
0
def test_order_catalog_bundle(appliance, provider, setup_provider,
                              catalog_item, request):
    """Tests ordering a catalog bundle
    Metadata:
        test_flag: provision
    """

    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()
    bundle_name = fauxfactory.gen_alphanumeric()
    catalog_bundle = CatalogBundle(name=bundle_name,
                                   description="catalog_bundle",
                                   display_in=True,
                                   catalog=catalog_item.catalog,
                                   dialog=catalog_item.dialog,
                                   catalog_items=[catalog_item.name])
    catalog_bundle.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog,
                                       catalog_bundle.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(
        bundle_name))
    request_description = bundle_name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
Esempio n. 6
0
def service_request(appliance, ansible_catalog_item):
    request_descr = "Provisioning Service [{0}] from [{0}]".format(ansible_catalog_item.name)
    service_request_ = RequestCollection(appliance).instantiate(description=request_descr)
    yield service_request_

    if service_request_.exists:
        service_request_.remove_request()
Esempio n. 7
0
    def publish_to_template(self, template_name, email=None, first_name=None, last_name=None):
        self.load_details()
        lcl_btn("Publish this VM to a Template")
        first_name = first_name or fauxfactory.gen_alphanumeric()
        last_name = last_name or fauxfactory.gen_alphanumeric()
        email = email or "{}@{}.test".format(first_name, last_name)
        try:
            prov_data = cfme_data["management_systems"][self.provider.key]["provisioning"]
        except (KeyError, IndexError):
            raise ValueError("You have to specify the correct options in cfme_data.yaml")

        provisioning_data = {
            "first_name": first_name,
            "last_name": last_name,
            "email": email,
            "vm_name": template_name,
            "host_name": {"name": prov_data.get("host")},
            "datastore_name": {"name": prov_data.get("datastore")},
        }
        from cfme.provisioning import provisioning_form
        fill(provisioning_form, provisioning_data, action=provisioning_form.submit_button)
        cells = {'Description': 'Publish from [{}] to [{}]'.format(self.name, template_name)}
        provision_request = RequestCollection(self.appliance).instantiate(cells=cells)
        provision_request.wait_for_request()
        return Template(template_name, self.provider)
Esempio n. 8
0
def test_action_cancel_clone(appliance, request, provider, vm_name, vm_big,
                             policy_for_testing):
    """This test checks if 'Cancel vCenter task' action works.
    For this test we need big template otherwise CFME won't have enough time
    to cancel the task https://bugzilla.redhat.com/show_bug.cgi?id=1383372#c9
    """
    with update(policy_for_testing):
        policy_for_testing.scope = (
            "fill_field(VM and Instance : Name, INCLUDES, {})".format(
                vm_big.name))
    policy_for_testing.assign_events("VM Clone Start")
    policy_for_testing.assign_actions_to_event("VM Clone Start",
                                               ["Cancel vCenter Task"])
    clone_vm_name = "{}-clone".format(vm_big.name)

    @request.addfinalizer
    def finalize():
        policy_for_testing.assign_events()
        with update(policy_for_testing):
            policy_for_testing.scope = (
                "fill_field(VM and Instance : Name, INCLUDES, {})".format(
                    vm_name))
        cleanup_vm(clone_vm_name, provider)

    vm_big.crud.clone_vm(fauxfactory.gen_email(), "first", "last",
                         clone_vm_name, "VMware")
    request_description = clone_vm_name
    clone_request = RequestCollection(appliance).instantiate(
        description=request_description, partial_check=True)
    clone_request.wait_for_request(method='ui')
    assert clone_request.status == "Error"
Esempio n. 9
0
def test_service_ansible_playbook_provision_in_requests(appliance, ansible_catalog_item,
                                                        service_catalog):
    """Tests if ansible playbook service provisioning is shown in service requests."""
    service_catalog.order()
    cat_item_name = ansible_catalog_item.name
    request_descr = "Provisioning Service [{0}] from [{0}]".format(cat_item_name)
    service_request = RequestCollection(appliance).instantiate(description=request_descr)
    assert service_request.exists()
Esempio n. 10
0
def do_vm_provisioning(appliance,
                       template_name,
                       provider,
                       vm_name,
                       provisioning_data,
                       request,
                       smtp_test,
                       num_sec=1500,
                       wait=True):
    # generate_tests makes sure these have values
    vm = Vm(name=vm_name, provider=provider, template_name=template_name)
    note = ('template {} to vm {} on provider {}'.format(
        template_name, vm_name, provider.key))
    provisioning_data.update({
        'request': {
            'email': '*****@*****.**',
            'first_name': 'Template',
            'last_name': 'Provisioner',
            'notes': note
        }
    })
    view = navigate_to(vm, 'Provision')
    view.form.fill_with(provisioning_data, on_change=view.form.submit_button)
    flash.assert_no_errors()
    if not wait:
        return

    # Provision Re important in this test
    logger.info('Waiting for cfme provision request for vm %s', vm_name)
    request_description = 'Provision from [{}] to [{}]'.format(
        template_name, vm_name)
    provision_request = RequestCollection(appliance).instantiate(
        request_description)
    provision_request.wait_for_request(method='ui')
    assert provision_request.is_succeeded(method='ui'), \
        "Provisioning failed with the message {}".format(provision_request.row.last_message.text)

    # Wait for the VM to appear on the provider backend before proceeding to ensure proper cleanup
    logger.info('Waiting for vm %s to appear on provider %s', vm_name,
                provider.key)
    wait_for(provider.mgmt.does_vm_exist, [vm_name],
             handle_exception=True,
             num_sec=600)

    if smtp_test:
        # Wait for e-mails to appear
        def verify():
            approval = dict(
                subject_like=
                "%%Your Virtual Machine configuration was Approved%%")
            expected_text = "Your virtual machine request has Completed - VM:%%{}".format(
                vm_name)
            return (len(smtp_test.get_emails(**approval)) > 0 and
                    len(smtp_test.get_emails(subject_like=expected_text)) > 0)

        wait_for(verify, message="email receive check", delay=30)
Esempio n. 11
0
def create_vm(appliance, provider, setup_provider, catalog_item, request):
    vm_name = catalog_item.provisioning_data["vm_name"]
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s', catalog_item.name)
    request_description = catalog_item.name
    request_row = RequestCollection(appliance).instantiate(request_description, partial_check=True)
    request_row.wait_for_request()
    assert request_row.is_succeeded()
    return vm_name
Esempio n. 12
0
def test_copy_request(appliance, setup_provider, provider, catalog_item,
                      request):
    """Automate BZ 1194479"""
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    request_description = catalog_item.name
    service_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    service_request.wait_for_request()
    assert navigate_to(service_request, 'Details')
Esempio n. 13
0
def test_vm_clone(appliance, provider, clone_vm_name, request, create_vm):
    vm_name = create_vm + "_0001"
    request.addfinalizer(lambda: cleanup_vm(vm_name, provider))
    request.addfinalizer(lambda: cleanup_vm(clone_vm_name, provider))
    vm = VM.factory(vm_name, provider)
    if provider.one_of(RHEVMProvider):
        provision_type = 'Native Clone'
    elif provider.one_of(VMwareProvider):
        provision_type = 'VMware'
    vm.clone_vm("*****@*****.**", "first", "last", clone_vm_name, provision_type)
    request_description = clone_vm_name
    request_row = RequestCollection(appliance).instantiate(request_description, partial_check=True)
    request_row.wait_for_request(method='ui')
    assert request_row.is_succeeded(method='ui')
def test_service_generic_catalog_bundle(appliance, catalog_item):
    bundle_name = "generic_" + fauxfactory.gen_alphanumeric()
    catalog_bundle = CatalogBundle(name=bundle_name, description="catalog_bundle",
                   display_in=True, catalog=catalog_item.catalog, dialog=catalog_item.dialog,
                   catalog_items=[catalog_item.name])
    catalog_bundle.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, bundle_name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s', bundle_name)
    request_description = bundle_name
    provision_request = RequestCollection(appliance).instantiate(request_description,
                                                                 partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
def test_cloud_catalog_item(appliance, setup_provider, provider, dialog,
                            catalog, request, provisioning):
    """Tests cloud catalog item

    Metadata:
        test_flag: provision
    """
    vm_name = 'test{}'.format(fauxfactory.gen_alphanumeric())
    # GCE accepts only lowercase letters in VM name
    vm_name = vm_name.lower()
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    image = provisioning['image']['name']
    item_name = fauxfactory.gen_alphanumeric()
    provisioning_data = dict(
        vm_name=vm_name,
        instance_type=provisioning['instance_type'],
        security_groups=[provisioning['security_group']],
    )
    if provider.type == "azure":
        updates = dict(
            virtual_private_cloud=provisioning['virtual_private_cloud'],
            cloud_subnet=provisioning['cloud_subnet'],
            resource_group=[provisioning['resource_group']],
        )
    else:
        updates = dict(availability_zone=provisioning['availability_zone'],
                       cloud_tenant=provisioning['cloud_tenant'],
                       cloud_network=provisioning['cloud_network'],
                       guest_keypair=provisioning['guest_keypair'],
                       boot_disk_size=provisioning['boot_disk_size'])
    provisioning_data.update(updates)
    catalog_item = CatalogItem(item_type=provisioning['item_type'],
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               catalog_name=image,
                               provider=provider,
                               prov_data=provisioning_data)
    catalog_item.create()
    service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog,
                                       catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s', item_name)
    request_description = item_name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
def test_retire_ansible_service(appliance, catalog_item, request):
    """Tests order catalog item
    Metadata:
        test_flag: provision
    """
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s',
                catalog_item.name)
    cells = {'Description': catalog_item.name}
    order_request = RequestCollection(appliance).instantiate(
        cells=cells, partial_check=True)
    order_request.wait_for_request(method='ui')
    assert order_request.is_succeeded(method='ui')
    myservice = MyService(appliance, catalog_item.name)
    myservice.retire()
def test_order_tower_catalog_item(appliance, catalog_item, request):
    """Tests order catalog item
    Metadata:
        test_flag: provision
    """
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s',
                catalog_item.name)
    cells = {'Description': catalog_item.name}
    order_request = RequestCollection(appliance).instantiate(
        cells=cells, partial_check=True)
    order_request.wait_for_request(method='ui')
    assert order_request.is_succeeded(method='ui')
    DefaultView.set_default_view("Configuration Management Providers",
                                 "List View")
Esempio n. 18
0
def test_service_manual_approval(appliance, provider, setup_provider, modify_instance,
                                 catalog_item, request):
    """Tests order catalog item
    Metadata:
        test_flag: provision
    """
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()

    service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(catalog_item.name))
    request_description = catalog_item.name
    service_request = RequestCollection(appliance).instantiate(description=request_description,
                                                               partial_check=True)
    service_request.update(method='ui')
    assert service_request.row.approval_state.text == 'Pending Approval'
Esempio n. 19
0
def test_request_with_orphaned_template(appliance, provider, setup_provider,
                                        catalog_item):
    """Tests edit catalog item after deleting provider
    Metadata:
        test_flag: provision
    """
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(
        catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provider.delete(cancel=False)
    provider.wait_for_delete()
    provision_request.wait_for_request(method='ui')
    assert provision_request.row.status.text == 'Error'
def test_remove_template_provisioning(appliance, provider, provisioning, catalog, catalog_item):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    catalog_item, template = catalog_item
    stack_data = prepare_stack_data(provider, provisioning)
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name, stack_data)
    service_catalogs.order()
    # This is part of test - remove template and see if provision fails , so not added as finalizer
    template.delete()
    request_description = 'Provisioning Service [{}] from [{}]'.format(catalog_item.name,
                                                                       catalog_item.name)
    provision_request = RequestCollection(appliance).instantiate(request_description)
    provision_request.wait_for_request(method='ui')
    assert (provision_request.row.last_message.text == 'Service_Template_Provisioning failed' or
            provision_request.row.status.text == "Error")
Esempio n. 21
0
def test_vm_migrate(appliance, new_vm, provider):
    """Tests migration of a vm

    Metadata:
        test_flag: migrate, provision
    """
    # auto_test_services should exist to test migrate VM
    vm_host = new_vm.get_detail(properties=('Relationships', 'Host'))
    migrate_to = [
        vds.name for vds in provider.hosts if vds.name not in vm_host
    ][0]
    new_vm.migrate_vm("*****@*****.**", "first", "last", host_name=migrate_to)
    request_description = new_vm.name
    cells = {'Description': request_description, 'Request Type': 'Migrate'}
    migrate_request = RequestCollection(appliance).instantiate(
        request_description, cells=cells, partial_check=True)
    migrate_request.wait_for_request(method='ui')
    assert migrate_request.is_succeeded(method='ui')
def order_catalog_item_in_ops_ui(appliance, provider, catalog_item, request):
    """
        Fixture for SSUI tests.
        Orders catalog item in OPS UI.
    """
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(
        lambda: cleanup_vm("{}_0001".format(vm_name), provider))
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(
        catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_finished()
    return catalog_item.name
def test_tenant_quota_max_cpu_check(appliance, provisioner, prov_data,
                                    template_name, provider, request, vm_name,
                                    set_tenant_cpu, bug):
    """Test Tenant Quota-Max CPU by UI.

    Prerequisities:
        * A provider set up, supporting provisioning in CFME

    Steps:
        * Set the tenant quota for cpu by UI enforcement
        * Open the provisioning dialog.
        * Apart from the usual provisioning settings, set CPU greater then tenant quota cpu.
        * Submit the provisioning request and wait for it to finish.
        * Visit the requests page. The last message should state quota validation message.

    Metadata:
        test_flag: provision
    """
    prov_data = {
        'catalog': {
            'vm_name': vm_name
        },
        'environment': {
            'automatic_placement': True
        },
        'hardware': {
            'num_sockets': '8'
        }
    }

    provisioner(appliance, template_name, prov_data, vm_name)

    # nav to requests page to check quota validation
    request_description = 'Provision from [{}] to [{}]'.format(
        template_name, vm_name)
    provision_request = RequestCollection(appliance).instantiate(
        request_description)
    provision_request.wait_for_request(method='ui')
    # BUG - https://bugzilla.redhat.com/show_bug.cgi?id=1364381
    # TODO: update assert message once the above bug is fixed.
    # assert row.last_message.text == 'Request exceeds maximum allowed for the following: \
    # (cpu - Used: 526 plus requested: 8 exceeds quota: 3))'
    assert provision_request.row.reason.text == "Quota Exceeded"
Esempio n. 24
0
def myservice(appliance, setup_provider, provider, catalog_item, request):
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service %s', catalog_item.name)
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(request_description,
                                                                 partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_finished()
    service = MyService(appliance, catalog_item.name, vm_name)
    yield service

    try:
        service.delete()
    except Exception as ex:
        logger.warning('Exception while deleting MyService, continuing: {}'.format(ex.message))
Esempio n. 25
0
def test_rhev_iso_servicecatalog(appliance, setup_provider, provider,
                                 catalog_item, request):
    """Tests RHEV ISO service catalog

    Metadata:
        test_flag: iso, provision
    """
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    # nav to requests page happens on successful provision
    logger.info('Waiting for cfme provision request for service %s',
                catalog_item.name)
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
def test_tagdialog_catalog_item(appliance, provider, setup_provider, catalog_item, request):
    """Tests tag dialog catalog item
    Metadata:
        test_flag: provision
    """
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()
    dialog_values = {
        'default_select_value': "Gold"
    }
    service_catalogs = ServiceCatalogs(catalog=catalog_item.catalog, name=catalog_item.name,
                                       dialog_values=dialog_values)
    service_catalogs.order()
    logger.info('Waiting for cfme provision request for service {}'.format(catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(request_description,
                                                                 partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
def test_tenant_quota_max_memory_check(appliance, provisioner, prov_data,
                                       template_name, provider, request,
                                       vm_name, set_tenant_memory, bug):
    """Test Tenant Quota-Max Memory by UI.

    Prerequisities:
        * A provider set up, supporting provisioning in CFME

    Steps:
        * Set the tenant quota for memory by UI enforcement
        * Open the provisioning dialog.
        * Apart from the usual provisioning settings, set memory greater then tenant quota memory.
        * Submit the provisioning request and wait for it to finish.
        * Visit the requests page. The last message should state quota validation message.

    Metadata:
        test_flag: provision
    """
    prov_data = {
        'catalog': {
            'vm_name': vm_name
        },
        'environment': {
            'automatic_placement': True
        },
        'hardware': {
            'memory': '4096'
        }
    }

    provisioner(appliance, template_name, prov_data, vm_name)

    # nav to requests page to check quota validation
    request_description = 'Provision from [{}] to [{}]'.format(
        template_name, vm_name)
    provision_request = RequestCollection(appliance).instantiate(
        request_description)
    provision_request.wait_for_request(method='ui')
    assert provision_request.row.reason.text == "Quota Exceeded"
    def _provisioner(template, provisioning_data, delayed=None):
        vm = Vm(name=vm_name, provider=provider, template_name=template)
        view = navigate_to(vm, 'Provision')
        view.form.before_fill(provisioning_data)

        fill(provisioning_form,
             provisioning_data,
             action=provisioning_form.submit_button)
        flash.assert_no_errors()

        request.addfinalizer(lambda: cleanup_vm(vm_name, provider))
        request_description = 'Provision from [{}] to [{}]'.format(
            template, vm_name)
        provision_request = RequestCollection(appliance).instantiate(
            description=request_description)
        if delayed is not None:
            total_seconds = (delayed - datetime.utcnow()).total_seconds()
            try:
                wait_for(provision_request.is_finished,
                         fail_func=provision_request.update,
                         num_sec=total_seconds,
                         delay=5)
                pytest.fail("The provisioning was not postponed")
            except TimedOutError:
                pass

        logger.info('Waiting for vm %s to appear on provider %s', vm_name,
                    provider.key)
        wait_for(provider.mgmt.does_vm_exist, [vm_name],
                 fail_func=provider.refresh_provider_relationships,
                 handle_exception=True,
                 num_sec=600)

        # nav to requests page happens on successful provision
        logger.info('Waiting for cfme provision request for vm %s', vm_name)
        provision_request.wait_for_request()
        assert provision_request.is_succeeded(method='ui')
        return vm
Esempio n. 29
0
def test_order_catalog_item(appliance, provider, setup_provider, catalog_item,
                            request, register_event):
    """Tests order catalog item
    Metadata:
        test_flag: provision
    """
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm(vm_name + "_0001", provider))
    catalog_item.create()

    register_event(target_type='Service',
                   target_name=catalog_item.name,
                   event_type='service_provisioned')

    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(
        catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(
        request_description, partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
Esempio n. 30
0
def order_catalog_item_in_ops_ui(appliance, provider, provisioning, vm_name, dialog, catalog,
        console_template, request):
    """
        Fixture for SSUI tests.
        Orders catalog item in OPS UI.
    """
    if hasattr(request, 'param'):
        catalog_item = create_catalog_item(provider, provisioning, vm_name, dialog, catalog,
            console_template if 'console_test' in request.param else None)
    else:
        catalog_item = create_catalog_item(provider, provisioning, vm_name, dialog, catalog)
    vm_name = catalog_item.provisioning_data["vm_name"]
    request.addfinalizer(lambda: cleanup_vm("{}0001".format(vm_name), provider))
    catalog_item.create()
    service_catalogs = ServiceCatalogs(appliance, catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    logger.info("Waiting for cfme provision request for service {}".format(catalog_item.name))
    request_description = catalog_item.name
    provision_request = RequestCollection(appliance).instantiate(request_description,
                                                                 partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_finished()
    return catalog_item.name