def new_snapshot(test_vm, has_name=True): if has_name: new_snapshot = Vm.Snapshot( name="snpshot_" + fauxfactory.gen_alphanumeric(8), description="snapshot", memory=False, parent_vm=test_vm ) else: new_snapshot = Vm.Snapshot( description="snapshot_" + fauxfactory.gen_alphanumeric(8), memory=False, parent_vm=test_vm ) return new_snapshot
def new_snapshot(test_vm, has_name=True, memory=False): return Vm.Snapshot(name="snpshot_{}".format( fauxfactory.gen_alphanumeric(8)) if has_name else None, description="snapshot_{}".format( fauxfactory.gen_alphanumeric(8)), memory=memory, parent_vm=test_vm)
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 = Vm.Snapshot(name=snap_name, parent_vm=small_test_vm) simulate(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()
def test_create_snapshot_via_ae(request, domain, 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 = Domain("ManageIQ (Locked)") miq_class = Class("Request", namespace=Namespace("System", domain=miq_domain)) request_cls = miq_class.copy_to(domain) request.addfinalizer(request_cls.delete) method = Method("snapshot", data=method_contents, cls=request_cls) method.create() request.addfinalizer(method.delete) instance = Instance("snapshot", values={"meth5": "snapshot"}, cls=request_cls) instance.create() request.addfinalizer(instance.delete) # SIMULATE snap_name = fauxfactory.gen_alpha() snapshot = Vm.Snapshot(name=snap_name, parent_vm=test_vm) simulate(instance="Request", request="snapshot", attribute=["VM and Instance", test_vm.name], execute_methods=True, avp={"snap_name": snap_name}) wait_for(snapshot.does_snapshot_exist, timeout="2m", delay=10) # Clean up if it appeared snapshot.delete()