}
}
private HashMap<String, Disk.Operation> createVm() throws Exception {
// Find the template and template snapshot to clone from
final VcVirtualMachine template =
VcCache.get(vmSchema.diskSchema.getParent());
VcSnapshot snap =
template.getSnapshotByName(vmSchema.diskSchema.getParentSnap());
if (snap == null) {
// this is a blocking call
snap = template.createSnapshot(vmSchema.diskSchema.getParentSnap(),
"Serengeti template Root Snapshot");
}
ConfigSpecImpl configSpec = new ConfigSpecImpl();
// Resource schema
ResourceSchemaUtil.setResourceSchema(configSpec, vmSchema.resourceSchema);
// Add managed-by information
// VmConfigUtil.addManagedByToConfigSpec(
// newConfigSpec, VcContext.getService().getExtensionKey(), "dbvm");
HashMap<String, Disk.Operation> diskMap =
new HashMap<String, Disk.Operation>();
if (requireClone()) {
VcVirtualMachine.CreateSpec vmSpec =
new VcVirtualMachine.CreateSpec(newVmName, snap, targetRp,
targetDs, vmFolder, host, linkedClone, configSpec);
// Clone from the template
vcVm = template.cloneVm(vmSpec, null);
} else {
// copy parent vm's version/product info/vapp options
copyParentVmSettings(template, configSpec);
vcVm = targetRp.createVm(configSpec, targetDs, vmFolder);