Example #1
0
def vm_crud(vm_name, provider_crud, provider_key, provider_type):
    if is_cloud_provider(provider_key):
        if provider_type == "openstack":
            return OpenStackInstance(vm_name, provider_crud)
        elif provider_type == "ec2":
            return EC2Instance(vm_name, provider_crud)
        else:
            raise Exception("Unknown provider type {}!".format(provider_type))
    else:
        return Vm(vm_name, provider_crud)
def vm_crud(vm_name, provider):
    if is_cloud_provider(provider.key):
        if provider.type == "openstack":
            return OpenStackInstance(vm_name, provider)
        elif provider.type == "ec2":
            return EC2Instance(vm_name, provider)
        else:
            raise Exception("Unknown provider type {}!".format(provider.type))
    else:
        return Vm(vm_name, provider)
    if provider.type == "ec2":
        cls = EC2Instance
    elif provider.type == "openstack":
        cls = OpenStackInstance
    else:
        cls = Vm
    return cls(
        'test_genealogy_{}'.format(fauxfactory.gen_alpha(length=8).lower()),
        provider, template_name=small_template)


# uncollected above in pytest_generate_tests
@pytest.mark.meta(blockers=["GH#ManageIQ/manageiq:473"])
@pytest.mark.parametrize("from_edit", [True, False], ids=["via_edit", "via_summary"])
@pytest.mark.uncollectif(
    lambda provider, from_edit: is_cloud_provider(provider.key) and not from_edit)
def test_vm_genealogy_detected(
        request, setup_provider, provider, small_template, soft_assert, from_edit, vm_crud):
    """Tests vm genealogy from what CFME can detect.

    Prerequisities:
        * A provider that is set up and having suitable templates for provisioning.

    Steps:
        * Provision the VM
        * Then, depending on whether you want to check it via ``Genealogy`` or edit page:
            * Open the edit page of the VM and you can see the parent template in the dropdown.
                Assert that it corresponds with the template the VM was deployed from.
            * Open VM Genealogy via details page and see the the template being an ancestor of the
                VM.
                        scope="module")


@pytest.fixture(scope="function")
def vm_crud(provider, small_template):
    return VM.factory('test_genealogy_{}'.format(
        fauxfactory.gen_alpha(length=8).lower()),
                      provider,
                      template_name=small_template)


# uncollected above in pytest_generate_tests
@pytest.mark.meta(blockers=["GH#ManageIQ/manageiq:473"])
@pytest.mark.parametrize("from_edit", [True, False],
                         ids=["via_edit", "via_summary"])
@pytest.mark.uncollectif(lambda provider, from_edit: is_cloud_provider(
    provider.key) and not from_edit)
def test_vm_genealogy_detected(request, setup_provider, provider,
                               small_template, soft_assert, from_edit,
                               vm_crud):
    """Tests vm genealogy from what CFME can detect.

    Prerequisities:
        * A provider that is set up and having suitable templates for provisioning.

    Steps:
        * Provision the VM
        * Then, depending on whether you want to check it via ``Genealogy`` or edit page:
            * Open the edit page of the VM and you can see the parent template in the dropdown.
                Assert that it corresponds with the template the VM was deployed from.
            * Open VM Genealogy via details page and see the the template being an ancestor of the
                VM.