예제 #1
0
def new_snapshot(test_vm, has_name=True, memory=False, create_description=True):
    name = fauxfactory.gen_alphanumeric(8)
    return InfraVm.Snapshot(
        name="snpshot_{}".format(name) if has_name else None,
        description="snapshot_{}".format(name) if create_description else None,
        memory=memory,
        parent_vm=test_vm
    )
예제 #2
0
def test_create_snapshot_via_ae(appliance, request, domain, small_test_vm):
    """This test checks whether the vm.create_snapshot works in AE.

    Prerequisities:
        * A VMware provider
        * A VM that has been discovered by CFME

    Steps:
        * Clone the Request class inside the System namespace into a new domain
        * Add a method named ``snapshot`` and insert the provided code there.
        * Add an instance named ``snapshot`` and set the methd from previous step
            as ``meth5``
        * Run the simulation of the method against the VM, preferably setting
            ``snap_name`` to something that can be checked
        * Wait until snapshot with such name appears.
    """
    # PREPARE
    file = data_path.join("ui").join("automate").join(
        "test_create_snapshot_via_ae.rb")
    with file.open("r") as f:
        method_contents = f.read()
    miq_domain = DomainCollection(appliance).instantiate(name='ManageIQ')
    miq_class = miq_domain.namespaces.instantiate(
        name='System').classes.instantiate(name='Request')
    miq_class.copy_to(domain)
    request_cls = domain.namespaces.instantiate(
        name='System').classes.instantiate(name='Request')
    request.addfinalizer(request_cls.delete)
    method = request_cls.methods.create(name="snapshot",
                                        location='inline',
                                        script=method_contents)
    request.addfinalizer(method.delete)
    instance = request_cls.instances.create(
        name="snapshot", fields={"meth5": {
            'value': "snapshot"
        }})
    request.addfinalizer(instance.delete)

    # SIMULATE
    snap_name = fauxfactory.gen_alpha()
    snapshot = InfraVm.Snapshot(name=snap_name, parent_vm=small_test_vm)
    simulate(appliance=appliance,
             instance="Request",
             request="snapshot",
             target_type='VM and Instance',
             target_object=small_test_vm.name,
             execute_methods=True,
             attributes_values={"snap_name": snap_name})

    wait_for(lambda: snapshot.exists,
             timeout="2m",
             delay=10,
             fail_func=small_test_vm.provider.browser.refresh,
             handle_exception=True,
             message="Waiting for snapshot create")

    # Clean up if it appeared
    snapshot.delete()
예제 #3
0
def test_vm_reconfig_resize_disk_snapshot(request,
                                          disk_type,
                                          disk_mode,
                                          full_vm,
                                          memory=False):
    """

    Bugzilla:
        1631448

    Polarion:
        assignee: nansari
        initialEstimate: 1/8h
        startsin: 5.11
        casecomponent: Infra
        caseposneg: negative
        setup:
            1. Have a VM running on vsphere provider
        testSteps:
            1. Go to Compute -> infrastructure -> Virtual Machines -> Select Vm
            2. Create a snapshot for selected VM
            3. Go to VM reconfiguration and try to resize disk of the VM
        expectedResults:
            1. VM selected
            2. Snapshot created
            3. Resize is not allowed when snapshots are attached
    """

    snapshot = InfraVm.Snapshot(
        name=fauxfactory.gen_alphanumeric(start="snap_"),
        description=fauxfactory.gen_alphanumeric(start="desc_"),
        memory=memory,
        parent_vm=full_vm)
    snapshot.create()
    request.addfinalizer(snapshot.delete)

    view = navigate_to(full_vm, 'Reconfigure')
    row = next(r for r in view.disks_table.rows())

    # Delete button should enabled
    assert row.actions.widget.is_enabled

    # Re-sized button should not displayed
    assert not row[9].widget.is_displayed