コード例 #1
0
def test_retire_stack(provider, provisioning, create_template, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    set_default_view("Stacks", "Grid View")
    dialog_name, template = create_template
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template.template_name)
    catalog_item.create()
    stack_data = prepare_stack_data(provider, provisioning)
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=2500, delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    stack = Stack(stack_data['stack_name'])
    stack.retire_stack()

    @request.addfinalizer
    def _cleanup_templates():
        template.delete_all_templates()
        stack_data['vm_name'].delete_from_provider()
コード例 #2
0
def test_broken_angular_select(request):
    """Test that checks the fancy selects do not break.

    Prerequisities:
        * A fresh downstream appliance

    Steps:
        1) Create a catalog.
        2) Create a catalog item, can be Generic and assign the catalog and OSE Installer dialog
            for testing purposes
        3) Try ordering the service, but instead of confirming the form, try changing some select.
    """
    # OSE Installer dialog, one dropdown from it
    the_select = AngularSelect("param_operatingSystemType")
    cat = Catalog("Test_catalog_{}".format(fauxfactory.gen_alpha()))
    cat.create()
    request.addfinalizer(cat.delete)
    item = CatalogItem(
        item_type="Generic",
        name="Catitem_{}".format(fauxfactory.gen_alpha()),
        description=fauxfactory.gen_alpha(),
        display_in=True,
        catalog=cat.name,
        dialog="azure-single-vm-from-user-image")
    item.create()
    request.addfinalizer(item.delete)
    sc = service_catalogs.ServiceCatalogs(item.name)
    navigate_to(sc, 'Order')
    # The check itself
    fill(the_select, "Linux")
    assert not the_select.is_broken, "The select displayed itself next ot the angular select"
コード例 #3
0
def test_remove_template_provisioning(provider, provisioning, create_template, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = create_template
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(
        item_type="Orchestration",
        name=item_name,
        description="my catalog",
        display_in=True,
        catalog=catalog.name,
        dialog=dialog_name,
        orch_template=template.template_name,
    )
    catalog_item.create()
    stack_data = prepare_stack_data(provider, provisioning)
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    # This is part of test - remove template and see if provision fails , so not added as finalizer
    template.delete_all_templates()
    row_description = "Provisioning Service [{}] from [{}]".format(item_name, item_name)
    cells = {"Description": row_description}
    wait_for(lambda: requests.find_request(cells), num_sec=500, delay=20)
    row, __ = wait_for(requests.wait_for_request, [cells, True], fail_func=requests.reload, num_sec=1000, delay=20)
    assert row.last_message.text == "Service_Template_Provisioning failed"
コード例 #4
0
ファイル: __init__.py プロジェクト: vprusa/cfme_tests
def services(request, rest_api, a_provider, dialog, service_catalogs):
    """
    The attempt to add the service entities via web
    """
    template, host, datastore, iso_file, vlan, catalog_item_type = map(
        a_provider.data.get("provisioning").get,
        ('template', 'host', 'datastore', 'iso_file', 'vlan',
         'catalog_item_type'))

    provisioning_data = {
        'vm_name': 'test_rest_{}'.format(fauxfactory.gen_alphanumeric()),
        'host_name': {
            'name': [host]
        },
        'datastore_name': {
            'name': [datastore]
        }
    }

    if a_provider.type == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
        provisioning_data['vlan'] = vlan
        catalog_item_type = "RHEV"
    elif a_provider.type == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'
    catalog = service_catalogs[0].name
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog.label,
                               catalog_name=template,
                               provider=a_provider.name,
                               prov_data=provisioning_data)

    catalog_item.create()
    service_catalogs = ServiceCatalogs("service_name")
    service_catalogs.order(catalog_item.catalog, catalog_item)
    row_description = catalog_item.name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=2000,
                       delay=20)
    assert row.last_message.text == 'Request complete'
    try:
        services = [_ for _ in rest_api.collections.services]
        services[0]
    except IndexError:
        raise Exception("No options are selected")

    @request.addfinalizer
    def _finished():
        services = [_ for _ in rest_api.collections.services]
        if len(services) != 0:
            rest_api.collections.services.action.delete(*services)

    return services
コード例 #5
0
def create_catalog_item(provider,
                        provisioning,
                        vm_name,
                        dialog,
                        catalog,
                        console_template=None):
    catalog_item_type = provider.catalog_name
    provision_type, template, host, datastore, iso_file, vlan = map(
        provisioning.get, ('provision_type', 'template', 'host', 'datastore',
                           'iso_file', 'vlan'))
    if console_template:
        logger.info("Console template name : {}".format(console_template.name))
        template = console_template.name
    item_name = dialog.label
    if provider.one_of(InfraProvider):
        catalog_name = template
        provisioning_data = {
            'catalog': {
                'vm_name': vm_name,
                'provision_type': provision_type
            },
            'environment': {
                'host_name': {
                    'name': host
                },
                'datastore_name': {
                    'name': datastore
                }
            },
            'network': {
                'vlan': partial_match(vlan)
            },
        }
    elif provider.one_of(CloudProvider):
        catalog_name = provisioning['image']['name']
        provisioning_data = {
            'catalog': {
                'vm_name': vm_name
            },
            'properties': {
                'instance_type': partial_match(provisioning['instance_type']),
                'guest_keypair': provisioning['guest_keypair'],
                'boot_disk_size': provisioning.get('boot_disk_size', None)
            },
            'environment': {
                'availability_zone': provisioning['availability_zone'],
                'cloud_network': provisioning['cloud_network']
            }
        }
    catalog_item = CatalogItem(item_type=catalog_item_type,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               catalog_name=catalog_name,
                               provider=provider,
                               prov_data=provisioning_data)
    catalog_item.create()
    return catalog_item
コード例 #6
0
def catalog_item(dialog, catalog):
    item_name = generate_random_string()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog)
    catalog_item.create()
    yield catalog_item
コード例 #7
0
def test_cloud_catalog_item(appliance, setup_provider, provider, dialog, catalog, request,
                            provisioning):
    """Tests cloud catalog item

    Metadata:
        test_flag: provision
    """
    # azure accepts only 15 chars vm name
    vm_name = 'test{}'.format(fauxfactory.gen_string('alphanumeric', 5))
    # 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 = {
        'catalog': {'vm_name': vm_name,
                    },
        'properties': {'instance_type': partial_match(provisioning['instance_type']),
                       },
        'environment': {'security_groups': partial_match(provisioning['security_group']),
                        }
    }

    if provider.type == "azure":
        env_updates = dict(
            cloud_network=partial_match(provisioning['virtual_private_cloud']),
            cloud_subnet=provisioning['cloud_subnet'],
            resource_groups=provisioning['resource_group'],
        )
        provisioning_data['environment'].update(env_updates)
        provisioning_data.update({
            'customize': {
                'admin_username': provisioning['customize_username'],
                'root_password': provisioning['customize_password']}})
    else:
        provisioning_data['properties']['guest_keypair'] = provisioning['guest_keypair']
        provisioning_data['properties']['boot_disk_size'] = provisioning['boot_disk_size']
        env_updates = dict(
            availability_zone=provisioning['availability_zone'],
            cloud_tenant=provisioning['cloud_tenant'],
            cloud_network=provisioning['cloud_network'])
        provisioning_data['environment'].update(env_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 = appliance.collections.requests.instantiate(request_description,
                                                                   partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
コード例 #8
0
def catalog_item(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog)
    catalog_item.create()
    yield catalog_item
コード例 #9
0
def test_broken_angular_select(request):
    """Test that checks the fancy selects do not break.

    Prerequisities:
        * A fresh downstream appliance

    Steps:
        1) Create a catalog.
        2) Create a catalog item, can be Generic and assign the catalog and OSE Installer dialog
            for testing purposes
        3) Try ordering the service, but instead of confirming the form, try changing some select.
    """
    # OSE Installer dialog, one dropdown from it
    the_select = AngularSelect("ose_size")
    cat = Catalog("Test_catalog_{}".format(fauxfactory.gen_alpha()))
    cat.create()
    request.addfinalizer(cat.delete)
    item = CatalogItem(item_type="Generic",
                       name="Catitem_{}".format(fauxfactory.gen_alpha()),
                       description=fauxfactory.gen_alpha(),
                       display_in=True,
                       catalog=cat.name,
                       dialog="OSE Installer")
    item.create()
    request.addfinalizer(item.delete)

    # The check itself
    pytest.sel.force_navigate("order_service_catalog",
                              context={
                                  "catalog": cat.name,
                                  "catalog_item": item
                              })
    fill(the_select, "Medium")
    assert not the_select.is_broken, "The select displayed itself next ot the angular select"
コード例 #10
0
def catalog_item(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog)
    catalog_item.create()
    yield catalog_item
コード例 #11
0
def test_retire_stack(setup_provider, provider, provisioning,
                      dialog, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    set_default_view("Stacks", "Grid View")
    dialog_name, template = dialog
    method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Aamzon Web Services desc')
    template.create(method)
    template.create_service_dialog_from_template(dialog_name, template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template.template_name,
                  provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    request.addfinalizer(lambda: template.delete_all_templates())
    logger.info('Waiting for cfme provision request for service %s' % item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=2500, delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    stack = Stack(stackname)
    stack.retire_stack()
コード例 #12
0
def test_remove_template_provisioning(setup_provider, provider, provisioning,
                                      dialog, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = dialog
    method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Amzn Web Services')
    template.create(method)
    template.create_service_dialog_from_template(dialog_name, template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template.template_name,
                  provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    # This is part of test - remove template and see if provision fails , so not added as finalizer
    template.delete_all_templates()
    row_description = 'Provisioning Service [{}] from [{}]'.format(item_name, item_name)
    cells = {'Description': row_description}
    wait_for(lambda: requests.find_request(cells), num_sec=500, delay=20)
    row, __ = wait_for(requests.wait_for_request, [cells, True],
      fail_func=requests.reload, num_sec=1000, delay=20)
    assert row.last_message.text == 'Service_Template_Provisioning failed'
コード例 #13
0
def test_broken_angular_select(appliance, request):
    """Test that checks the fancy selects do not break.

    Prerequisities:
        * A fresh downstream appliance

    Steps:
        1) Create a catalog.
        2) Create a catalog item, can be Generic and assign the catalog and OSE Installer dialog
            for testing purposes
        3) Try ordering the service, but instead of confirming the form, try changing some select.
    """
    # OSE Installer dialog, one dropdown from it
    the_select = AngularSelect("param_operatingSystemType")
    cat = Catalog("Test_catalog_{}".format(fauxfactory.gen_alpha()))
    cat.create()
    request.addfinalizer(cat.delete)
    item = CatalogItem(item_type="Generic",
                       name="Catitem_{}".format(fauxfactory.gen_alpha()),
                       description=fauxfactory.gen_alpha(),
                       display_in=True,
                       catalog=cat,
                       dialog="azure-single-vm-from-user-image")
    item.create()
    request.addfinalizer(item.delete)
    sc = ServiceCatalogs(appliance, item.catalog, item.name)
    navigate_to(sc, 'Order')
    # The check itself
    fill(the_select, "Linux")
    assert not the_select.is_broken, "The select displayed itself next ot the angular select"
コード例 #14
0
def test_broken_angular_select(request):
    """Test that checks the fancy selects do not break.

    Prerequisities:
        * A fresh downstream appliance

    Steps:
        1) Create a catalog.
        2) Create a catalog item, can be Generic and assign the catalog and OSE Installer dialog
            for testing purposes
        3) Try ordering the service, but instead of confirming the form, try changing some select.
    """
    # OSE Installer dialog, one dropdown from it
    the_select = AngularSelect("ose_size")
    cat = Catalog("Test_catalog_{}".format(fauxfactory.gen_alpha()))
    cat.create()
    request.addfinalizer(cat.delete)
    item = CatalogItem(
        item_type="Generic",
        name="Catitem_{}".format(fauxfactory.gen_alpha()),
        description=fauxfactory.gen_alpha(),
        display_in=True,
        catalog=cat.name,
        dialog="OSE Installer")
    item.create()
    request.addfinalizer(item.delete)

    # The check itself
    pytest.sel.force_navigate(
        "order_service_catalog",
        context={"catalog": cat.name, "catalog_item": item})
    fill(the_select, "Medium")
    assert not the_select.is_broken, "The select displayed itself next ot the angular select"
コード例 #15
0
def test_no_template_catalog_item(provider, provisioning, vm_name, dialog,
                                  catalog):
    """Tests no template catalog item

    Metadata:
        test_flag: provision
    """
    template, catalog_item_type = map(provisioning.get,
                                      ('template', 'catalog_item_type'))
    if provider.type == 'rhevm':
        catalog_item_type = version.pick({
            version.LATEST: "RHEV",
            '5.3': "RHEV",
            '5.2': "Redhat"
        })
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog)
    catalog_item.create()
    flash.assert_message_match(
        version.pick({
            version.LOWEST: "'Catalog/Name' is required",
            "5.4": "Source_id must have valid template"
        }))
コード例 #16
0
def test_remove_template_provisioning(provider, create_template, catalog,
                                      request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = create_template
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name,
                               orch_template=template.template_name,
                               provider_type=provider.name)
    catalog_item.create()
    stackname = "test_" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    # This is part of test - remove template and see if provision fails , so not added as finalizer
    template.delete_all_templates()
    row_description = 'Provisioning Service [{}] from [{}]'.format(
        item_name, item_name)
    cells = {'Description': row_description}
    wait_for(lambda: requests.find_request(cells), num_sec=500, delay=20)
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=1000,
                       delay=20)
    assert row.last_message.text == 'Service_Template_Provisioning failed'
コード例 #17
0
def test_reconfigure_service(provider, provisioning, create_template, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = create_template
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template.template_name)
    catalog_item.create()
    stack_data = prepare_stack_data(provider, provisioning)

    @request.addfinalizer
    def _cleanup_vms():
        if provider.mgmt.stack_exist(stack_data['stack_name']):
            wait_for(lambda: provider.mgmt.delete_stack(stack_data['stack_name']),
             delay=10, num_sec=800, message="wait for stack delete")
        template.delete_all_templates()
        stack_data['vm_name'].delete_from_provider()

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=2000, delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    myservice = MyService(catalog_item.name)
    myservice.reconfigure_service()
コード例 #18
0
def test_dynamicdropdown_dialog(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog.label)
    catalog_item.create()
    service_catalogs = ServiceCatalogs("service_name")
    service_catalogs.order(catalog_item.catalog, catalog_item)
コード例 #19
0
def test_dynamicdropdown_dialog(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog.label)
    catalog_item.create()
    service_catalogs = ServiceCatalogs("service_name")
    service_catalogs.order(catalog_item.catalog, catalog_item)
コード例 #20
0
def test_provision_stack(setup_provider, provider, provisioning, dialog,
                         catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template_name = dialog
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name,
                               orch_template=template_name,
                               provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    if provider.type == 'ec2':
        stack_data = {
            'stack_name':
            stackname,
            'key_name':
            provisioning['stack_provisioning']['key_name'],
            'db_user':
            provisioning['stack_provisioning']['db_user'],
            'db_password':
            provisioning['stack_provisioning']['db_password'],
            'db_root_password':
            provisioning['stack_provisioning']['db_root_password'],
            'select_instance_type':
            provisioning['stack_provisioning']['instance_type'],
        }
    elif provider.type == 'openstack':
        stack_data = {
            'stack_name': stackname,
        }

    @request.addfinalizer
    def _cleanup_vms():
        if provider.mgmt.stack_exist(stackname):
            provider.mgmt.delete_stack(stackname)

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    flash.assert_no_errors()
    logger.info('Waiting for cfme provision request for service %s' %
                item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=2500,
                       delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
コード例 #21
0
def test_delete_catalog_deletes_service(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog)
    catalog_item.create()
    catalog.delete()
    service_catalogs = ServiceCatalogs(catalog, catalog_item.name)
    with error.expected(NoSuchElementException):
        service_catalogs.order()
コード例 #22
0
def catalog_item(dialog, catalog):
    item_name = generate_random_string()
    catalog_item = CatalogItem(item_type="Generic",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog)
    catalog_item.create()
    yield catalog_item
コード例 #23
0
def test_no_template_catalog_item(provider, provisioning, setup_provider, vm_name, dialog, catalog):
    """Tests no template catalog item
    Metadata:
        test_flag: provision
    """
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=provider.catalog_name, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog, dialog=dialog)
    with error.expected("'Catalog/Name' is required"):
        catalog_item.create()
コード例 #24
0
def test_delete_catalog_deletes_service(appliance, dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog)
    catalog_item.create()
    catalog.delete()
    service_catalogs = ServiceCatalogs(appliance, catalog, catalog_item.name)
    with error.expected(NoSuchElementException):
        service_catalogs.order()
コード例 #25
0
def test_delete_catalog_deletes_service(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog)
    catalog_item.create()
    catalog.delete()
    service_catalogs = ServiceCatalogs("service_name")
    with error.expected(CandidateNotFound):
        service_catalogs.order(catalog.name, catalog_item)
コード例 #26
0
def test_delete_catalog_deletes_service(dialog, catalog):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Generic", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog)
    catalog_item.create()
    catalog.delete()
    service_catalogs = ServiceCatalogs("service_name")
    with error.expected(CandidateNotFound):
        service_catalogs.order(catalog.name, catalog_item)
コード例 #27
0
ファイル: test_rest.py プロジェクト: pombredanne/cfme_tests
def services(request, a_provider, rest_api, dialog, service_catalogs):
    """
    The attempt to add the service entities via web
    """
    template, host, datastore, iso_file, vlan, catalog_item_type = map(a_provider.data.get(
        "provisioning").get,
        ('template', 'host', 'datastore', 'iso_file', 'vlan', 'catalog_item_type'))

    provisioning_data = {
        'vm_name': 'test_rest_{}'.format(fauxfactory.gen_alphanumeric()),
        'host_name': {'name': [host]},
        'datastore_name': {'name': [datastore]}
    }

    if a_provider.type == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
        provisioning_data['vlan'] = vlan
        catalog_item_type = version.pick({
            version.LATEST: "RHEV",
            '5.3': "RHEV",
            '5.2': "Redhat"
        })
    elif a_provider.type == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'
    catalog = service_catalogs[0].name
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type, name=item_name,
                               description="my catalog", display_in=True,
                               catalog=catalog,
                               dialog=dialog.label,
                               catalog_name=template,
                               provider=a_provider.name,
                               prov_data=provisioning_data)

    catalog_item.create()
    service_catalogs = ServiceCatalogs("service_name")
    service_catalogs.order(catalog_item.catalog, catalog_item)
    row_description = catalog_item.name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
        fail_func=requests.reload, num_sec=2000, delay=20)
    assert row.last_message.text == 'Request complete'
    try:
        services = [_ for _ in rest_api.collections.services]
        services[0]
    except IndexError:
        pytest.skip("There is no service to be taken")

    @request.addfinalizer
    def _finished():
        services = [_ for _ in rest_api.collections.services]
        if len(services) != 0:
            rest_api.collections.services.action.delete(*services)

    return services
コード例 #28
0
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 = {
        'catalog': {'vm_name': vm_name,
                    },
        'properties': {'instance_type': provisioning['instance_type'],
                       },
        'environment': {'security_groups': [provisioning['security_group']],
                        },
    }

    if provider.type == "azure":
        env_updates = dict(
            cloud_network=provisioning['virtual_private_cloud'],
            cloud_subnet=provisioning['cloud_subnet'],
            resource_groups=[provisioning['resource_group']],
        )
    else:
        provisioning_data['properties']['guest_keypair'] = provisioning['guest_keypair']
        provisioning_data['properties']['boot_disk_size'] = provisioning['boot_disk_size']
        env_updates = dict(
            availability_zone=provisioning['availability_zone'],
            cloud_tenant=provisioning['cloud_tenant'],
            cloud_network=provisioning['cloud_network'])

    provisioning_data['environment'].update(env_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 = appliance.collections.requests.instantiate(request_description,
                                                                   partial_check=True)
    provision_request.wait_for_request()
    assert provision_request.is_succeeded()
コード例 #29
0
def test_cloud_catalog_item(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(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    flash.assert_no_errors()
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=1200,
                       delay=20)
    assert row.request_state.text == 'Finished'
コード例 #30
0
def catalog_item(dialog, catalog):
    cat_item = CatalogItem(item_type="Generic",
                           name='test_item_' + fauxfactory.gen_alphanumeric(),
                           description="my catalog item", display_in=True,
                           catalog=catalog, dialog=dialog)
    yield cat_item

    # fixture cleanup
    try:
        cat_item.delete()
    except NoSuchElementException:
        logger.warning('test_catalog_item: catalog_item yield fixture cleanup, catalog item "{}" '
                       'not found'.format(cat_item.name))
コード例 #31
0
def catalog_item(dialog, catalog):
    cat_item = CatalogItem(item_type="Generic",
                           name='test_item_' + fauxfactory.gen_alphanumeric(),
                           description="my catalog item", display_in=True,
                           catalog=catalog, dialog=dialog)
    yield cat_item

    # fixture cleanup
    try:
        cat_item.delete()
    except NoSuchElementException:
        logger.warning('test_catalog_item: catalog_item yield fixture cleanup, catalog item "{}" '
                       'not found'.format(cat_item.name))
コード例 #32
0
def catalog_item(dialog, catalog, template, provider):
    template, dialog = template
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               orch_template=template,
                               provider=provider)
    catalog_item.create()
    return catalog_item, template
コード例 #33
0
def catalog_item(dialog_name, catalog, template):
    item_name = fauxfactory.gen_alphanumeric()

    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name,
                               orch_template=template.template_name)
    catalog_item.create()

    yield catalog_item, item_name
コード例 #34
0
def test_cloud_catalog_item(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.name,
                               dialog=dialog,
                               catalog_name=image,
                               provider=provider,
                               prov_data=provisioning_data)
    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.name)
    service_catalogs.order()
    flash.assert_no_errors()
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=1200, delay=20)
    assert row.request_state.text == 'Finished'
コード例 #35
0
def test_no_template_catalog_item(provider, provisioning, setup_provider, vm_name, dialog, catalog):
    """Tests no template catalog item
    Metadata:
        test_flag: provision
    """
    template, catalog_item_type = map(provisioning.get,
        ('template', 'catalog_item_type'))
    if provider.type == 'rhevm':
        catalog_item_type = "RHEV"
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog, dialog=dialog)
    catalog_item.create()
    flash.assert_message_match("'Catalog/Name' is required")
コード例 #36
0
def catalog_item(dialog, catalog, template, provider, dialog_name):
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog_name,
                               orch_template=template,
                               provider=provider)
    catalog_item.create()
    yield catalog_item
    if catalog_item.exists:
        catalog_item.delete()
コード例 #37
0
def test_no_template_catalog_item(provider, provisioning, setup_provider, vm_name, dialog, catalog):
    """Tests no template catalog item
    Metadata:
        test_flag: provision
    """
    template, catalog_item_type = map(provisioning.get,
        ('template', 'catalog_item_type'))
    if provider.type == 'rhevm':
        catalog_item_type = "RHEV"
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog, dialog=dialog)
    catalog_item.create()
    flash.assert_message_match("'Catalog/Name' is required")
コード例 #38
0
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()
コード例 #39
0
def catalog_item(dialog, catalog, template, provider):
    template, dialog, service_name = dialog
    item_name = service_name

    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               orch_template=template,
                               provider=provider)
    catalog_item.create()

    yield catalog_item, template
コード例 #40
0
def test_no_template_catalog_item(provider, provisioning, setup_provider,
                                  vm_name, dialog, catalog):
    """Tests no template catalog item
    Metadata:
        test_flag: provision
    """
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=provider.catalog_name,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog)
    with error.expected("'Catalog/Name' is required"):
        catalog_item.create()
コード例 #41
0
def test_reconfigure_service(setup_provider, provider, provisioning, dialog,
                             catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = dialog
    method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Amzn Web')
    template.create(method)
    template.create_service_dialog_from_template(dialog_name,
                                                 template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name,
                               orch_template=template.template_name,
                               provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}

    @request.addfinalizer
    def _cleanup_vms():
        if provider.mgmt.stack_exist(stackname):
            wait_for(lambda: provider.mgmt.delete_stack(stackname),
                     delay=10,
                     num_sec=800,
                     message="wait for stack delete")
        template.delete_all_templates()

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=2000,
                       delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    myservice = MyService(catalog_item.name)
    myservice.reconfigure_service()
コード例 #42
0
def catalog_item(provider, vm_name, dialog, catalog, provisioning, setup_pxe_servers_vm_prov):
    # generate_tests makes sure these have values
    pxe_template, host, datastore, pxe_server, pxe_image, pxe_kickstart, pxe_root_password,\
        pxe_image_type, pxe_vlan = map(
            provisioning.get, (
                'pxe_template', 'host', 'datastore', 'pxe_server', 'pxe_image', 'pxe_kickstart',
                'pxe_root_password', 'pxe_image_type', 'vlan'
            )
        )

    provisioning_data = {
        'catalog': {'provision_type': 'PXE',
                    'pxe_server': pxe_server,
                    'pxe_image': {'name': pxe_image},
                    'vm_name': vm_name,
                    },
        'environment': {'datastore_name': {'name': datastore},
                        'host_name': {'name': host},
                        },
        'customize': {'root_password': pxe_root_password,
                      'custom_template': {'name': pxe_kickstart},
                      },
        'network': {'vlan': partial_match(pxe_vlan),
                    },
    }

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=provider.catalog_name, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog, catalog_name=pxe_template,
                  provider=provider, prov_data=provisioning_data)
    yield catalog_item
コード例 #43
0
ファイル: gen_data.py プロジェクト: jdemon519/cfme_tests
def service_templates(request, rest_api, dialog, num=4):
    catalog_items = []
    new_names = []
    for _ in range(num):
        new_name = 'item_{}'.format(fauxfactory.gen_alphanumeric())
        new_names.append(new_name)
        catalog_items.append(
            CatalogItem(item_type='Generic',
                        name=new_name,
                        description='my catalog',
                        display_in=True,
                        dialog=dialog.label))

    for catalog_item in catalog_items:
        catalog_item.create()

    collection = rest_api.collections.service_templates

    for new_name in new_names:
        wait_for(lambda: collection.find_by(name=new_name),
                 num_sec=180,
                 delay=10)

    s_tpls = [ent for ent in collection if ent.name in new_names]

    @request.addfinalizer
    def _finished():
        collection.reload()
        to_delete = [ent for ent in collection if ent.name in new_names]
        if len(to_delete) != 0:
            collection.action.delete(*to_delete)

    return s_tpls
コード例 #44
0
def create_catalog_item(provider,
                        provisioning,
                        vm_name,
                        dialog,
                        catalog,
                        console_template=None):

    template, host, datastore, iso_file, catalog_item_type, vlan = map(
        provisioning.get, ('template', 'host', 'datastore', 'iso_file',
                           'catalog_item_type', 'vlan'))
    if console_template:
        logger.info("Console template name : {}".format(console_template.name))
        template = console_template.name
    item_name = dialog.label
    provisioning_data = dict(vm_name=vm_name,
                             host_name={'name': [host]},
                             datastore_name={'name': [datastore]},
                             vlan=vlan)

    if provider.type == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
    elif provider.type == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'
    catalog_item = CatalogItem(item_type=catalog_item_type,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               catalog_name=template,
                               provider=provider,
                               prov_data=provisioning_data)
    return catalog_item
コード例 #45
0
def catalog_item(setup_provider, provider, vm_name, dialog, catalog, provisioning):
    iso_template, host, datastore, iso_file, iso_kickstart,\
        iso_root_password, iso_image_type, vlan = map(provisioning.get, ('pxe_template', 'host',
                                'datastore', 'iso_file', 'iso_kickstart',
                                'iso_root_password', 'iso_image_type', 'vlan'))

    provisioning_data = {
        'catalog': {'vm_name': vm_name,
                    'provision_type': 'ISO',
                    'iso_file': {'name': iso_file},
                    },
        'environment': {'host_name': {'name': host},
                        'datastore_name': {'name': datastore},
                        },
        'customize': {'custom_template': {'name': iso_kickstart},
                      'root_password': iso_root_password,
                      },
        'network': {'vlan': partial_match(vlan),
                    },
    }

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="RHEV", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog, catalog_name=iso_template,
                  provider=provider, prov_data=provisioning_data)
    yield catalog_item
コード例 #46
0
def catalog_item(provider, vm_name, dialog, catalog, provisioning):
    template, host, datastore, iso_file, catalog_item_type = map(
        provisioning.get,
        ('template', 'host', 'datastore', 'iso_file', 'catalog_item_type'))

    provisioning_data = {
        'vm_name': vm_name,
        'host_name': {
            'name': [host]
        },
        'datastore_name': {
            'name': [datastore]
        }
    }

    if provider.type == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
        provisioning_data['vlan'] = provisioning['vlan']
        catalog_item_type = "RHEV"
    elif provider.type == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type,
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog,
                               dialog=dialog,
                               catalog_name=template,
                               provider=provider,
                               prov_data=provisioning_data)
    yield catalog_item
コード例 #47
0
def service_templates(request, rest_api, dialog):
    catalog_items = []
    for index in range(1, 5):
        catalog_items.append(
            CatalogItem(item_type="Generic",
                        name="item_{}_{}".format(
                            index, fauxfactory.gen_alphanumeric()),
                        description="my catalog",
                        display_in=True,
                        dialog=dialog.label))

    for catalog_item in catalog_items:
        catalog_item.create()

    try:
        s_tpls = [_ for _ in rest_api.collections.service_templates]
        s_tpls[0]
    except IndexError:
        raise Exception("There is no service template to be taken")

    @request.addfinalizer
    def _finished():
        s_tpls = [_ for _ in rest_api.collections.service_templates]
        if len(s_tpls) != 0:
            rest_api.collections.service_templates.action.delete(*s_tpls)

    return s_tpls
コード例 #48
0
def test_retire_stack(setup_provider, provider, provisioning, dialog, catalog,
                      request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    set_default_view("Stacks", "Grid View")
    dialog_name, template = dialog
    method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Amzn Web Services desc')
    template.create(method)
    template.create_service_dialog_from_template(dialog_name,
                                                 template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name,
                               orch_template=template.template_name,
                               provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    request.addfinalizer(lambda: template.delete_all_templates())
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=2500,
                       delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    stack = Stack(stackname)
    stack.retire_stack()

    @request.addfinalizer
    def _cleanup_templates():
        template.delete_all_templates()
コード例 #49
0
def test_reconfigure_service(setup_provider, provider, dialog, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template = dialog
    method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Amzn Web')
    # template.create(method)
    try:
        template.create(method)
    except FlashMessageException:
        method = METHOD_TORSO.replace('"Description" : "AWS',
                                  '"Description" : "Amazon Web')
        template.create(method)
    template.create_service_dialog_from_template(dialog_name, template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template.template_name,
                  provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    stack_data = {'stack_name': stackname}

    @request.addfinalizer
    def _cleanup_vms():
        if provider.mgmt.stack_exist(stackname):
            wait_for(lambda: provider.mgmt.delete_stack(stackname),
             delay=10, num_sec=800, message="wait for stack delete")
        template.delete_all_templates()

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    logger.info('Waiting for cfme provision request for service %s', item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=2000, delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
    myservice = MyService(catalog_item.name)
    myservice.reconfigure_service()
コード例 #50
0
def test_remove_template_provisioning(setup_provider, provider, provisioning,
                                      catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name_new = "dialog_" + fauxfactory.gen_alphanumeric()
    template_type = provisioning['stack_provisioning']['template_type']
    template = OrchestrationTemplate(
        template_type=template_type,
        template_name=fauxfactory.gen_alphanumeric())
    template.create(METHOD_TORSO)
    template.create_service_dialog_from_template(dialog_name_new,
                                                 template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration",
                               name=item_name,
                               description="my catalog",
                               display_in=True,
                               catalog=catalog.name,
                               dialog=dialog_name_new,
                               orch_template=template.template_name,
                               provider_type=provider.name)
    catalog_item.create()
    if provider.type == 'ec2':
        stack_data = {'stack_name': "stack" + fauxfactory.gen_alphanumeric()}
    elif provider.type == 'openstack':
        stack_data = {'stack_name': "stack" + fauxfactory.gen_alphanumeric()}
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    flash.assert_no_errors()
    template.delete()
    row_description = 'Provisioning Service [{}] from [{}]'.format(
        item_name, item_name)
    cells = {'Description': row_description}
    wait_for(lambda: requests.go_to_request(cells), num_sec=500, delay=20)
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload,
                       num_sec=1000,
                       delay=20)
    assert row.last_message.text == 'Service_Template_Provisioning failed'
コード例 #51
0
def catalog_item(config_manager, dialog, catalog):
    config_manager_obj = config_manager
    provisionig_data = config_manager_obj.yaml_data['provisioning_data']
    item_type, provider, template = map(provisionig_data.get,
        ('item_type', 'provider', 'template'))
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=item_type, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog,
                  dialog=dialog, provider_type=provider, config_template=template)
    return catalog_item
コード例 #52
0
def test_reconfigure_service(
    provider_init, provider_key, provider_crud, provider_type, provisioning, dialog, catalog, request
):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template_name = dialog
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(
        item_type="Orchestration",
        name=item_name,
        description="my catalog",
        display_in=True,
        catalog=catalog.name,
        dialog=dialog_name,
        orch_template=template_name,
        provider_type=provider_crud.name,
    )
    catalog_item.create()
    if provider_type == "ec2":
        stack_data = {
            "stack_name": fauxfactory.gen_alphanumeric(),
            "key_name": provisioning["stack_provisioning"]["key_name"],
            "db_user": provisioning["stack_provisioning"]["db_user"],
            "db_password": provisioning["stack_provisioning"]["db_password"],
            "db_root_password": provisioning["stack_provisioning"]["db_root_password"],
            "select_instance_type": provisioning["stack_provisioning"]["instance_type"],
        }
    elif provider_type == "openstack":
        stack_data = {"stack_name": fauxfactory.gen_alphanumeric()}
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    flash.assert_no_errors()
    logger.info("Waiting for cfme provision request for service %s" % item_name)
    row_description = item_name
    cells = {"Description": row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True], fail_func=requests.reload, num_sec=1000, delay=20)
    assert row.last_message.text == "Service Provisioned Successfully"
    myservice = MyService(catalog_item.name)
    myservice.reconfigure_service()
コード例 #53
0
def test_provision_stack(setup_provider, provider, provisioning, dialog, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name, template_name = dialog
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name, orch_template=template_name,
                  provider_type=provider.name)
    catalog_item.create()
    stackname = "test-" + fauxfactory.gen_alphanumeric()
    if provider.type == 'ec2':
        stack_data = {
            'stack_name': stackname,
            'key_name': provisioning['stack_provisioning']['key_name'],
            'db_user': provisioning['stack_provisioning']['db_user'],
            'db_password': provisioning['stack_provisioning']['db_password'],
            'db_root_password': provisioning['stack_provisioning']['db_root_password'],
            'select_instance_type': provisioning['stack_provisioning']['instance_type'],
        }
    elif provider.type == 'openstack':
        stack_data = {
            'stack_name': stackname,
        }

    @request.addfinalizer
    def _cleanup_vms():
        if provider.mgmt.stack_exist(stackname):
            provider.mgmt.delete_stack(stackname)

    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    flash.assert_no_errors()
    logger.info('Waiting for cfme provision request for service %s' % item_name)
    row_description = item_name
    cells = {'Description': row_description}
    row, __ = wait_for(requests.wait_for_request, [cells, True],
                       fail_func=requests.reload, num_sec=2500, delay=20)
    assert row.last_message.text == 'Service Provisioned Successfully'
コード例 #54
0
def test_no_template_catalog_item(provider, provisioning, vm_name, dialog, catalog):
    """Tests no template catalog item

    Metadata:
        test_flag: provision
    """
    template, catalog_item_type = map(provisioning.get,
        ('template', 'catalog_item_type'))
    if provider.type == 'rhevm':
        catalog_item_type = version.pick({
            version.LATEST: "RHEV",
            '5.3': "RHEV",
            '5.2': "Redhat"
        })
    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type=catalog_item_type, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog, dialog=dialog)
    catalog_item.create()
    flash.assert_message_match(version.pick({version.LOWEST: "'Catalog/Name' is required",
                                             "5.4": "Source_id must have valid template"}))
コード例 #55
0
def test_no_template_catalog_item(provider_crud, provider_type, provisioning,
                                  vm_name, dialog, catalog):
    """Tests no template catalog item

    Metadata:
        test_flag: provision
    """
    template, catalog_item_type = map(provisioning.get,
        ('template', 'catalog_item_type'))
    if provider_type == 'rhevm':
        catalog_item_type = version.pick({
            version.LATEST: "RHEV",
            '5.3': "RHEV",
            '5.2': "Redhat"
        })
    item_name = generate_random_string()
    catalog_item = CatalogItem(item_type=catalog_item_type, name=item_name,
                  description="my catalog", display_in=True, catalog=catalog, dialog=dialog)
    catalog_item.create()
    flash.assert_message_match("'Catalog/Name' is required")
コード例 #56
0
def test_remove_template_provisioning(setup_provider, provider, provisioning, catalog, request):
    """Tests stack provisioning

    Metadata:
        test_flag: provision
    """
    dialog_name_new = "dialog_" + fauxfactory.gen_alphanumeric()
    template_type = provisioning['stack_provisioning']['template_type']
    template = OrchestrationTemplate(template_type=template_type,
                                     template_name=fauxfactory.gen_alphanumeric())
    template.create(METHOD_TORSO)
    template.create_service_dialog_from_template(dialog_name_new, template.template_name)

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(item_type="Orchestration", name=item_name,
                  description="my catalog", display_in=True, catalog=catalog.name,
                  dialog=dialog_name_new, orch_template=template.template_name,
                  provider_type=provider.name)
    catalog_item.create()
    if provider.type == 'ec2':
        stack_data = {
            'stack_name': "stack" + fauxfactory.gen_alphanumeric()
        }
    elif provider.type == 'openstack':
        stack_data = {
            'stack_name': "stack" + fauxfactory.gen_alphanumeric()
        }
    service_catalogs = ServiceCatalogs("service_name", stack_data)
    service_catalogs.order_stack_item(catalog.name, catalog_item)
    flash.assert_no_errors()
    template.delete()
    row_description = 'Provisioning Service [{}] from [{}]'.format(item_name, item_name)
    cells = {'Description': row_description}
    wait_for(lambda: requests.go_to_request(cells), num_sec=500, delay=20)
    row, __ = wait_for(requests.wait_for_request, [cells, True],
      fail_func=requests.reload, num_sec=1000, delay=20)
    assert row.last_message.text == 'Service_Template_Provisioning failed'
コード例 #57
0
ファイル: gen_data.py プロジェクト: dajohnso/cfme_tests
def service_data(request, rest_api, a_provider, service_dialog=None, service_catalog=None):
    """
    The attempt to add the service entities via web
    """
    if not service_dialog:
        service_dialog = dialog()
    if not service_catalog:
        service_catalog = service_catalog_obj(request, rest_api)

    template, host, datastore, vlan, catalog_item_type = map(
        a_provider.data.get('provisioning').get,
        ('template', 'host', 'datastore', 'vlan', 'catalog_item_type'))

    provisioning_data = {
        'vm_name': 'test_rest_{}'.format(fauxfactory.gen_alphanumeric()),
        'host_name': {'name': [host]},
        'datastore_name': {'name': [datastore]}
    }

    if a_provider.type == 'rhevm':
        provisioning_data['provision_type'] = 'Native Clone'
        provisioning_data['vlan'] = vlan
        catalog_item_type = 'RHEV'
    elif a_provider.type == 'virtualcenter':
        provisioning_data['provision_type'] = 'VMware'
        provisioning_data['vlan'] = vlan

    vm_name = version.pick({
        version.LOWEST: provisioning_data['vm_name'] + '_0001',
        '5.7': provisioning_data['vm_name'] + '0001'})

    item_name = fauxfactory.gen_alphanumeric()
    catalog_item = CatalogItem(
        item_type=catalog_item_type,
        name=item_name,
        description='my catalog',
        display_in=True,
        catalog=service_catalog,
        dialog=service_dialog,
        catalog_name=template,
        provider=a_provider,
        prov_data=provisioning_data
    )

    catalog_item.create()
    service_catalogs = ServiceCatalogs(catalog_item.catalog, catalog_item.name)
    service_catalogs.order()
    row_description = catalog_item.name
    cells = {'Description': row_description}
    row, _ = wait_for(requests.wait_for_request, [cells, True],
        fail_func=requests.reload, num_sec=2000, delay=60)
    assert row.request_state.text == 'Finished'
    assert row.status.text != 'Error', "Provisioning failed with the message `{}`".format(
        row.last_message.text)

    # on 5.8 the service name visible via REST API is in form <assigned_name>-DATE-TIMESTAMP
    # (i.e. 2ojnKgZRCJ-20170410-113646) for services created using UI
    rest_service = rest_api.collections.services.get(name='{}%'.format(catalog_item.name))

    @request.addfinalizer
    def _finished():
        try:
            a_provider.mgmt.delete_vm(vm_name)
        except Exception:
            # vm can be deleted/retired by test
            logger.warning("Failed to delete vm '{}'.".format(vm_name))
        try:
            rest_api.collections.services.get(name=rest_service.name).action.delete()
        except ValueError:
            # service can be deleted by test
            logger.warning("Failed to delete service '{}'.".format(rest_service.name))

    return {'service_name': rest_service.name, 'vm_name': vm_name}
コード例 #58
0
def test_cloud_catalog_item(appliance, vm_name, setup_provider, provider, dialog, catalog, request,
                            provisioning):
    """Tests cloud catalog item

    Metadata:
        test_flag: provision
    """
    wait_for(provider.is_refreshed, func_kwargs=dict(refresh_delta=10), timeout=600)
    request.addfinalizer(lambda: cleanup_vm("{}0001".format(vm_name), provider))
    image = provisioning['image']['name']
    item_name = "{}-service-{}".format(provider.name, fauxfactory.gen_alphanumeric())

    inst_args = {
        'catalog': {'vm_name': vm_name
                    },
        'environment': {
            'availability_zone': provisioning.get('availability_zone', None),
            'security_groups': [provisioning.get('security_group', None)],
            'cloud_tenant': provisioning.get('cloud_tenant', None),
            'cloud_network': provisioning.get('cloud_network', None),
            'cloud_subnet': provisioning.get('cloud_subnet', None),
            'resource_groups': provisioning.get('resource_group', None)
        },
        'properties': {
            'instance_type': partial_match(provisioning.get('instance_type', None)),
            'guest_keypair': provisioning.get('guest_keypair', None)}
    }
    # GCE specific
    if provider.one_of(GCEProvider):
        recursive_update(inst_args, {
            'properties': {
                'boot_disk_size': provisioning['boot_disk_size'],
                'is_preemptible': True}
        })
    # Azure specific
    if provider.one_of(AzureProvider):
        recursive_update(inst_args, {
            'customize': {
                'admin_username': provisioning['customize_username'],
                'root_password': provisioning['customize_password']}})

    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=inst_args)
    request.addfinalizer(catalog_item.delete)
    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 = appliance.collections.requests.instantiate(request_description,
                                                                   partial_check=True)
    provision_request.wait_for_request()
    msg = "Request failed with the message {}".format(provision_request.rest.message)
    assert provision_request.is_succeeded(), msg