2323import org .apache .cloudstack .platform .subsystem .api .storage .DataStoreEndPoint ;
2424import org .apache .cloudstack .platform .subsystem .api .storage .VolumeProfile ;
2525
26- import org .apache .cloudstack .platform .subsystem .api .storage .TemplateProfile ;
2726import org .apache .cloudstack .platform .subsystem .api .storage .TemplateStrategy ;
28-
27+ import com .cloud .agent .api .storage .DownloadProgressCommand ;
28+ import com .cloud .agent .api .storage .DownloadProgressCommand .RequestType ;
2929import com .cloud .agent .api .Answer ;
3030import com .cloud .agent .api .storage .CreateAnswer ;
3131import com .cloud .agent .api .storage .CreateCommand ;
32+ import com .cloud .agent .api .storage .DownloadCommand ;
33+ import com .cloud .agent .api .storage .PrimaryStorageDownloadAnswer ;
3234import com .cloud .agent .api .storage .PrimaryStorageDownloadCommand ;
3335import com .cloud .agent .api .to .VolumeTO ;
36+ import com .cloud .storage .TemplateProfile ;
3437import com .cloud .vm .DiskProfile ;
3538
3639
@@ -45,18 +48,29 @@ public AbstractStorageDriver(DataStore ds) {
4548 }
4649
4750 public TemplateProfile install (TemplateProfile tp , DataStoreEndPoint ep ) {
48- PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand (tp .getUniqueName (), tp .getURI (), tp .getFormat (),
51+ PrimaryStorageDownloadCommand dcmd = new PrimaryStorageDownloadCommand (tp .getName (), tp .getUrl (), tp .getFormat (),
4952 0 , _ds .getId (), _ds .getUUID (), _ts .getDownloadWait ());
5053 dcmd .setSecondaryStorageUrl (tp .getImageStorageUri ());
5154 dcmd .setPrimaryStorageUrl (_ds .getURI ());
52- Answer asw = ep .sendCommand (dcmd );
55+ PrimaryStorageDownloadAnswer asw = ( PrimaryStorageDownloadAnswer ) ep .sendCommand (dcmd );
5356
54- TemplateProfile tpn = new TemplateProfile ();
55- tpn .setLocalPath ("/mnt/test" );
56- tpn .setTemplatePoolRefId (tp .getTemplatePoolRefId ());
57- return tpn ;
57+ tp .setLocalPath (asw .getInstallPath ());
58+ return tp ;
5859 }
5960
61+ public TemplateProfile register (TemplateProfile tp , DataStoreEndPoint ep , boolean freshDownload ) {
62+
63+ DownloadCommand dcmd =
64+ new DownloadCommand (_ds .getURI (), tp .getTemplate (), _ts .getMaxTemplateSizeInBytes ());
65+ dcmd .setProxy (_ts .getHttpProxy ());
66+ if (!freshDownload ) {
67+ dcmd = new DownloadProgressCommand (dcmd , tp .getJobId (), RequestType .GET_OR_RESTART );
68+ }
69+
70+ ep .sendCommand (dcmd );
71+ return tp ;
72+ }
73+
6074 public DiskProfile createVolumeFromTemplate (DiskProfile volProfile , TemplateProfile tp , DataStoreEndPoint ep ) {
6175 CreateCommand cmd = new CreateCommand (volProfile , tp .getLocalPath (), _ds .getTO ());
6276 CreateAnswer ans = (CreateAnswer )ep .sendCommand (cmd );
0 commit comments