diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-09-21 01:01:14 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-09-21 01:01:14 +0000 |
commit | daed1ebdd575697db3ac9ac3b5fafd621e1c0ddd (patch) | |
tree | 53481cb88f2569c5fdce72fb16f898a0588de6af /plugins | |
parent | 741593370c86f8154ac77c39f066056a15553a8f (diff) | |
parent | bfdae32efbeffcb74e7b2a0c48cb89cbf4c11329 (diff) | |
download | nova-daed1ebdd575697db3ac9ac3b5fafd621e1c0ddd.tar.gz |
Merge "XenAPI: run vhd-util repair if VHD check fails"
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py index d5561ce73e..2ee2841501 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/utils.py @@ -218,6 +218,13 @@ def _assert_vhd_not_hidden(path): "VHD %s is marked as hidden without child" % path) +def _vhd_util_check(vdi_path): + check_cmd = ["vhd-util", "check", "-n", vdi_path, "-p"] + out = run_command(check_cmd, ok_exit_codes=[0, 22]) + first_line = out.splitlines()[0].strip() + return out, first_line + + def _validate_vhd(vdi_path): """This checks for several errors in the VHD structure. @@ -229,9 +236,13 @@ def _validate_vhd(vdi_path): Dom0's are out-of-sync. This would corrupt the SR if it were imported, so generate an exception to bail. """ - check_cmd = ["vhd-util", "check", "-n", vdi_path, "-p"] - out = run_command(check_cmd, ok_exit_codes=[0, 22]) - first_line = out.splitlines()[0].strip() + out, first_line = _vhd_util_check(vdi_path) + + if 'invalid' in first_line: + LOG.warning("VHD invalid, attempting repair.") + repair_cmd = ["vhd-util", "repair", "-n", vdi_path] + run_command(repair_cmd) + out, first_line = _vhd_util_check(vdi_path) if 'invalid' in first_line: if 'footer' in first_line: @@ -259,6 +270,8 @@ def _validate_vhd(vdi_path): "%(extra)s" % {'vdi_path': vdi_path, 'part': part, 'details': details, 'extra': extra}) + LOG.info("VDI is valid: %s" % vdi_path) + def _validate_vdi_chain(vdi_path): """This check ensures that the parent pointers on the VHDs are valid |