@@ -417,12 +417,10 @@ protected Answer copySnapshotToTemplateFromNfsToNfs(CopyCommand cmd, SnapshotObj
417417 } else if (srcData .getHypervisorType () == HypervisorType .KVM ) {
418418 File srcFile = getFile (srcData .getPath (), srcDataStore .getUrl ());
419419 File destFile = getFile (destData .getPath (), destDataStore .getUrl ());
420- // get snapshot file name, add extension if it is missing
420+ // get snapshot file name
421421 String templateName = srcFile .getName ();
422- if (!templateName .endsWith (ImageFormat .QCOW2 .getFileExtension ())) {
423- templateName = templateName + ImageFormat .QCOW2 .getFileExtension ();
424- }
425- String destFileFullPath = destFile .getAbsolutePath () + File .separator + templateName ;
422+ // add kvm file extension for copied template name
423+ String destFileFullPath = destFile .getAbsolutePath () + File .separator + templateName + "." + ImageFormat .QCOW2 .getFileExtension ();
426424 s_logger .debug ("copy snapshot " + srcFile .getAbsolutePath () + " to template " + destFileFullPath );
427425 Script .runSimpleBashScript ("cp " + srcFile .getAbsolutePath () + " " + destFileFullPath );
428426 // template post processing
@@ -439,7 +437,7 @@ protected Answer copySnapshotToTemplateFromNfsToNfs(CopyCommand cmd, SnapshotObj
439437 loc .save ();
440438 TemplateProp prop = loc .getTemplateInfo ();
441439 TemplateObjectTO newTemplate = new TemplateObjectTO ();
442- newTemplate .setPath (destData .getPath () + File .separator + templateName );
440+ newTemplate .setPath (destData .getPath () + File .separator + templateName + "." + ImageFormat . QCOW2 . getFileExtension () );
443441 newTemplate .setFormat (ImageFormat .QCOW2 );
444442 newTemplate .setSize (prop .getSize ());
445443 return new CopyCmdAnswer (newTemplate );
0 commit comments