147147import com .cloud .agent .api .storage .CreatePrivateTemplateAnswer ;
148148import com .cloud .agent .api .storage .CreatePrivateTemplateCommand ;
149149import com .cloud .agent .api .storage .DestroyCommand ;
150- import com .cloud .agent .api .storage .DownloadAnswer ;
151150import com .cloud .agent .api .storage .PrimaryStorageDownloadCommand ;
151+ import com .cloud .agent .api .storage .PrimaryStorageDownloadAnswer ;
152152import com .cloud .agent .api .to .NicTO ;
153153import com .cloud .agent .api .to .StorageFilerTO ;
154154import com .cloud .agent .api .to .VirtualMachineTO ;
@@ -1765,7 +1765,7 @@ private StoragePool getNfsSPbyURI(Connect conn, URI uri) throws LibvirtException
17651765 return sp ;
17661766 }
17671767 }
1768- protected Answer execute (final PrimaryStorageDownloadCommand cmd ) {
1768+ protected PrimaryStorageDownloadAnswer execute (final PrimaryStorageDownloadCommand cmd ) {
17691769 String tmplturl = cmd .getUrl ();
17701770 int index = tmplturl .lastIndexOf ("/" );
17711771 String mountpoint = tmplturl .substring (0 , index );
@@ -1781,7 +1781,7 @@ protected Answer execute(final PrimaryStorageDownloadCommand cmd) {
17811781 try {
17821782 secondaryPool = getNfsSPbyURI (_conn , new URI (mountpoint ));
17831783 if (secondaryPool == null ) {
1784- return new Answer ( cmd , false , " Failed to create storage pool" );
1784+ return new PrimaryStorageDownloadAnswer ( " Failed to create storage pool" );
17851785 }
17861786 if (tmpltname == null ) {
17871787 /*Hack: server just pass the directory of system vm template, need to scan the folder */
@@ -1790,7 +1790,7 @@ protected Answer execute(final PrimaryStorageDownloadCommand cmd) {
17901790 }
17911791 String [] volumes = secondaryPool .listVolumes ();
17921792 if (volumes == null ) {
1793- return new Answer ( cmd , false , "Failed to get volumes from pool: " + secondaryPool .getName ());
1793+ return new PrimaryStorageDownloadAnswer ( "Failed to get volumes from pool: " + secondaryPool .getName ());
17941794 }
17951795 for (String volumeName : volumes ) {
17961796 if (volumeName .endsWith ("qcow2" )) {
@@ -1799,40 +1799,32 @@ protected Answer execute(final PrimaryStorageDownloadCommand cmd) {
17991799 }
18001800 }
18011801 if (tmpltname == null ) {
1802- return new Answer ( cmd , false , "Failed to get template from pool: " + secondaryPool .getName ());
1802+ return new PrimaryStorageDownloadAnswer ( "Failed to get template from pool: " + secondaryPool .getName ());
18031803 }
18041804 }
18051805 tmplVol = getVolume (secondaryPool , getPathOfStoragePool (secondaryPool ) + tmpltname );
18061806 if (tmplVol == null ) {
1807- return new Answer ( cmd , false , " Can't find volume" );
1807+ return new PrimaryStorageDownloadAnswer ( " Can't find volume" );
18081808 }
18091809 primaryPool = _conn .storagePoolLookupByUUIDString (cmd .getPoolUuid ());
18101810 if (primaryPool == null ) {
1811- return new Answer ( cmd , false , " Can't find primary storage pool" );
1811+ return new PrimaryStorageDownloadAnswer ( " Can't find primary storage pool" );
18121812 }
18131813 LibvirtStorageVolumeDef vol = new LibvirtStorageVolumeDef (UUID .randomUUID ().toString (), tmplVol .getInfo ().capacity , volFormat .QCOW2 , null , null );
18141814 s_logger .debug (vol .toString ());
18151815 primaryVol = copyVolume (primaryPool , vol , tmplVol );
18161816 if (primaryVol == null ) {
1817- return new Answer ( cmd , false , " Can't create storage volume on storage pool" );
1817+ return new PrimaryStorageDownloadAnswer ( " Can't create storage volume on storage pool" );
18181818 }
1819-
18201819 StorageVolInfo priVolInfo = primaryVol .getInfo ();
1821- DownloadAnswer answer = new DownloadAnswer (null ,
1822- 100 ,
1823- cmd ,
1824- com .cloud .storage .VMTemplateStorageResourceAssoc .Status .DOWNLOADED ,
1825- primaryVol .getKey (),
1826- primaryVol .getKey ());
1827- answer .setTemplateSize (priVolInfo .allocation );
1828- return answer ;
1820+ return new PrimaryStorageDownloadAnswer (primaryVol .getKey (), priVolInfo .allocation );
18291821 } catch (LibvirtException e ) {
18301822 result = "Failed to download template: " + e .toString ();
18311823 s_logger .debug (result );
1832- return new Answer ( cmd , false , result );
1824+ return new PrimaryStorageDownloadAnswer ( result );
18331825 } catch (URISyntaxException e ) {
18341826 // TODO Auto-generated catch block
1835- return new Answer ( cmd , false , e .toString ());
1827+ return new PrimaryStorageDownloadAnswer ( e .toString ());
18361828 } finally {
18371829 try {
18381830 if (primaryVol != null ) {
0 commit comments