CLOUDSTACK-7868: Failed storage.PrimaryStorageDownloadCommand leaves corrupt VDIs in primary storage.

This commit is contained in:
Sanjay Tripathi 2014-11-08 13:34:31 +05:30
parent a275bd7ca4
commit 6a6d4d876f
2 changed files with 21 additions and 1 deletions

View File

@ -2744,6 +2744,16 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
try {
vdi.destroy(conn);
} catch (Exception e) {
String msg = "Failed to destroy VDI : " + nameLabel + "due to " + e.toString() + "\n Force deleting VDI using system 'rm' command";
s_logger.warn(msg);
try {
String srUUID = vdi.getSR(conn).getUuid(conn);
String vdiUUID = vdi.getUuid(conn);
String vdifile = "/var/run/sr-mount/" + srUUID + "/" + vdiUUID + ".vhd";
String results = callHostPluginAsync(conn, "vmopspremium", "remove_corrupt_vdi", 10, "vdifile", vdifile);
} catch (Exception e2) {
s_logger.warn(e2);
}
}
}
} catch (Exception e) {

View File

@ -100,6 +100,16 @@ def copy_vhd_from_secondarystorage(session, args):
txt = '10#failed'
return txt
@echo
def remove_corrupt_vdi(session, args):
vdifile = args['vdifile']
try:
cmd = ['rm', '-f', vdifile]
txt = util.pread2(cmd)
except:
txt = '10#failed'
return txt
@echo
def setup_heartbeat_sr(session, args):
host = args['host']
@ -146,4 +156,4 @@ def asmonitor(session, args):
return 'fail'
if __name__ == "__main__":
XenAPIPlugin.dispatch({"forceShutdownVM":forceShutdownVM, "upgrade_snapshot":upgrade_snapshot, "create_privatetemplate_from_snapshot":create_privatetemplate_from_snapshot, "copy_vhd_to_secondarystorage":copy_vhd_to_secondarystorage, "copy_vhd_from_secondarystorage":copy_vhd_from_secondarystorage, "setup_heartbeat_sr":setup_heartbeat_sr, "setup_heartbeat_file":setup_heartbeat_file, "heartbeat": heartbeat, "asmonitor": asmonitor})
XenAPIPlugin.dispatch({"forceShutdownVM":forceShutdownVM, "upgrade_snapshot":upgrade_snapshot, "create_privatetemplate_from_snapshot":create_privatetemplate_from_snapshot, "copy_vhd_to_secondarystorage":copy_vhd_to_secondarystorage, "copy_vhd_from_secondarystorage":copy_vhd_from_secondarystorage, "setup_heartbeat_sr":setup_heartbeat_sr, "setup_heartbeat_file":setup_heartbeat_file, "heartbeat": heartbeat, "asmonitor": asmonitor, "remove_corrupt_vdi": remove_corrupt_vdi})