Exemplo n.º 1
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()
Exemplo n.º 2
0
def generated_request(appliance, a_provider, provider_data, provisioning,
                      template_name, vm_name):
    """Creates a provision request, that is not automatically approved, and returns the search data.

    After finishing the test, request should be automatically deleted.

    Slightly modified code from :py:module:`cfme.tests.infrastructure.test_provisioning`
    """
    first_name = fauxfactory.gen_alphanumeric()
    last_name = fauxfactory.gen_alphanumeric()
    notes = fauxfactory.gen_alphanumeric()
    e_mail = "{}@{}.test".format(first_name, last_name)
    host, datastore = map(provisioning.get, ('host', 'datastore'))
    vm = Vm(name=vm_name, provider=a_provider, template_name=template_name)
    view = navigate_to(vm, 'Provision')

    provisioning_data = {
        'request': {
            'email': e_mail,
            'first_name': first_name,
            'last_name': last_name,
            'notes': notes
        },
        'catalog': {
            'vm_name': vm_name,
            'num_vms': '10'
        },
        'environment': {
            'host_name': {
                'name': host
            },
            'datastore_name': {
                'name': datastore
            }
        },
    }

    # Same thing, different names. :\
    if provider_data["type"] == 'rhevm':
        provisioning_data['catalog']['provision_type'] = 'Native Clone'
    elif provider_data["type"] == 'virtualcenter':
        provisioning_data['catalog']['provision_type'] = 'VMware'

    try:
        provisioning_data['network'] = {'vlan': provisioning['vlan']}
    except KeyError:
        # provisioning['vlan'] is required for rhevm provisioning
        if provider_data["type"] == 'rhevm':
            raise pytest.fail(
                'rhevm requires a vlan value in provisioning info')

    view.form.fill_with(provisioning_data, on_change=view.form.submit_button)
    request_cells = {
        "Description":
        "Provision from [{}] to [{}###]".format(template_name, vm_name),
    }
    provision_request = RequestCollection(appliance).instantiate(
        cells=request_cells)
    yield provision_request

    browser().get(store.base_url)
    appliance.server.login_admin()

    provision_request.remove_request()