How to use check_domain_state method in localstack

Best Python code snippet using localstack_python

revert.py

Source:revert.py Github

copy

Full Screen

...6from libvirt import libvirtError7from src import sharedmod8required_params = ('guestname', 'snapshotname',)9optional_params = {}10def check_domain_state(conn, guestname, logger):11 """ check if the domain exists and in shutdown state as well """12 guest_names = conn.listDefinedDomains()13 if guestname not in guest_names:14 logger.error("%s is running or does not exist" % guestname)15 return False16 else:17 return True18def revert(params):19 """ snapshot revert a snapshot for a given guest,20 this case could be with other cases togerther to21 check the functionality of snapshot22 """23 logger = params['logger']24 guestname = params['guestname']25 snapshotname = params['snapshotname']26 conn = sharedmod.libvirtobj['conn']27 logger.info("checking if the guest is poweroff")28 if not check_domain_state(conn, guestname, logger):29 logger.error("checking failed")30 return 131 try:32 logger.info("revert a snapshot for %s" % guestname)33 domobj = conn.lookupByName(guestname)34 snap = domobj.snapshotLookupByName(snapshotname, 0)35 domobj.revertToSnapshot(snap, 0)36 logger.info("revert snapshot succeeded")37 except libvirtError, e:38 logger.error("API error message: %s, error code is %s" \39 % (e.message, e.get_error_code()))40 return 1...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful