Signed-off-by: Jincheng Miao <jmiao@xxxxxxxxxx> --- repos/domain/domain_fsfreeze.py | 76 +++++++++++++++++++++++++++++++++++++++ repos/domain/domain_fsthaw.py | 49 +++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py diff --git a/repos/domain/domain_fsfreeze.py b/repos/domain/domain_fsfreeze.py new file mode 100644 index 0000000..f91cd46 --- /dev/null +++ b/repos/domain/domain_fsfreeze.py @@ -0,0 +1,76 @@ +#!/usr/bin/evn python +# To test domain fsfreeze + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {'mountpoint': ''} + + +def check_frozen_num(mp, num): + """check the number of frozen fs""" + if mp == None: + return True + + if len(mp) == num: + return True + else: + return False + + +def parse_mountpoint(mp): + """parse the argument mountpoint""" + if mp == None: + return None + + return [p.strip() for p in mp.split(',')] + + +def check_guest_status(domobj): + """Check guest current status""" + state = domobj.info()[0] + if state == libvirt.VIR_DOMAIN_SHUTOFF or \ + state == libvirt.VIR_DOMAIN_SHUTDOWN: + # add check function + return False + else: + return True + + +def domain_fsfreeze(params): + """domain fsfreeze test function""" + logger = params['logger'] + guestname = params['guestname'] + mountpoint = parse_mountpoint(params.get('mountpoint')) + + conn = sharedmod.libvirtobj['conn'] + + domobj = conn.lookupByName(guestname) + + # Check domain block status + if check_guest_status(domobj): + pass + else: + domobj.create() + time.sleep(90) + + try: + num = domobj.fsFreeze(mountpoint, 0) + logger.info("freeze %s fs" % num) + + if check_frozen_num(mountpoint, num): + logger.info("Check frozen fs num: pass") + else: + logger.error("Check frozen fs num: failed") + return 1 + + except libvirtError, e: + logger.error("API error message: %s, error code is %s" + % (e.message, e.get_error_code())) + return 1 + + return 0 diff --git a/repos/domain/domain_fsthaw.py b/repos/domain/domain_fsthaw.py new file mode 100644 index 0000000..cebbe22 --- /dev/null +++ b/repos/domain/domain_fsthaw.py @@ -0,0 +1,49 @@ +#!/usr/bin/evn python +# To test domain fsthaw + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {} + + +def check_guest_status(domobj): + """Check guest current status""" + state = domobj.info()[0] + if state == libvirt.VIR_DOMAIN_SHUTOFF or \ + state == libvirt.VIR_DOMAIN_SHUTDOWN: + # add check function + return False + else: + return True + + +def domain_fsthaw(params): + """domain fsthaw test function""" + logger = params['logger'] + guestname = params['guestname'] + + conn = sharedmod.libvirtobj['conn'] + + domobj = conn.lookupByName(guestname) + + # Check domain block status + if check_guest_status(domobj): + pass + else: + domobj.create() + time.sleep(90) + + try: + num = domobj.fsThaw() + logger.info("fsThaw %s fs" % num) + except libvirtError, e: + logger.error("API error message: %s, error code is %s" + % (e.message, e.get_error_code())) + return 1 + + return 0 -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list