throw new Exception();
}
}
/* Prepare vm profile. */
ProfileVm profVm;
if ((new File(profVmPath)).isFile()) {
/* The file exists so we load and update it. */
profVm = new ProfileVm(profVmPath);
/* Check moref of both the profile and vmInfo is same. */
String moref = profVm.getMoref();
if (! moref.equals(vmInfo.getMoref())) {
logger_.warning
(String.format
("moref %s != %s.\n", moref, vmInfo.getMoref()));
throw new Exception();
}
/* is_clean must be true to continue backup process. */
if (profVm.isClean() == false) {
throw new Exception("profVm is not clean.");
}
/* Overwrite the name of the virtula machine. */
profVm.setName(vmInfo.getName());
} else {
/* Config file does not exist then we create it. */
profVm = new ProfileVm();
profVm.initializeMetadata(vmInfo);
profVm.write(profVmPath);
}
/* Create backup */
profVm.makeBackup();
return profVm;
}