System.out.println(msg); logger_.info(msg);
/*
* Make generation profile.
*/
SnapshotManager snap = vmm.getCurrentSnapshot();
logger_.info(String.format("snapshot: %s", snap.getName()));
List<VmdkInfo> vmdkInfoList = snap.getConfig().getAllVmdkInfo();
/* debug */
msg = String.format("There are %d disks.", vmdkInfoList.size());
System.out.println(msg); logger_.info(msg);
for (VmdkInfo vmdkInfo : vmdkInfoList) {
logger_.info(vmdkInfo.toString());
}
/* Prepare generation profile. */
ProfileGeneration profGen =
vmArcMgr.prepareNewGeneration
(snap.getVmInfo(), snap.getSnapInfo(), vmdkInfoList, cal,
backupInfo.isGzip);
vmArcMgr.setTargetGeneration(profGen);
/*
* Export ovf and delete disk information from the ovf.
*/
String ovfFilePath = profGen.getOvfPath();
if (ovfFilePath == null) {
throw new Exception("ovfFilePath is null");
}
ret = exportOvfAndSave(vmm, ovfFilePath);
if (ret == false) {
throw new Exception
(String.format("ovf export failed (%s).", ovfFilePath));
}
/*
* Dump each vmdk file.
*/
boolean isAllVmdkDumpSucceeded = true;
for (VmdkInfo vmdkInfo : vmdkInfoList) {
int diskId = profGen.getDiskIdWithUuid(vmdkInfo.uuid_);
if (backupInfo.isNoVmdk) {
profGen.setVmdkdumpResult(diskId, true);
} else {
if (profGen.isIndependentDisk(diskId)) {
msg = String.format
("Dump vmdk %s skipped (independent disk)",
vmdkInfo.uuid_);
System.out.println(msg); logger_.info(msg);
ret = true;
} else {
ret = backupVmdk
(vmm, vmArcMgr, snap, vmdkInfo, backupInfo.isSan);
msg = String.format("Dump vmdk %s %s.",
vmdkInfo.uuid_,
(ret ? "succeeded" : "failed"));
System.out.println(msg); logger_.info(msg);
}
isAllVmdkDumpSucceeded &= ret;
/* Reconnect and reload if disconnected. */
try {
String vmMoref = vmm.getMoref();
String snapMoref = snap.getMoref();
gm_.connect();
vmm = gm_.searchVmWithMoref(vmMoref);
if (vmm == null) { throw new Exception("vmm is null."); }
snap = vmm.searchSnapshotWithMoref(snapMoref);
if (snap == null) { throw new Exception("snap is null."); }