2323import org .apache .cloudstack .framework .async .AsyncRpcConext ;
2424import org .apache .cloudstack .storage .EndPoint ;
2525import org .apache .cloudstack .storage .command .CommandResult ;
26- import org .apache .cloudstack .storage .command .CopyTemplateToPrimaryStorageCmd ;
26+ import org .apache .cloudstack .storage .command .CopyCmd ;
2727import org .apache .cloudstack .storage .command .CopyTemplateToPrimaryStorageAnswer ;
2828import org .apache .cloudstack .storage .datastore .PrimaryDataStore ;
29+ import org .apache .cloudstack .storage .image .TemplateInfo ;
2930import org .apache .cloudstack .storage .to .ImageOnPrimayDataStoreTO ;
3031import org .apache .cloudstack .storage .volume .TemplateOnPrimaryDataStoreInfo ;
3132import org .springframework .stereotype .Component ;
3637public class DefaultImageMotionStrategy implements ImageMotionStrategy {
3738
3839 @ Override
39- public boolean canHandle (TemplateOnPrimaryDataStoreInfo templateStore ) {
40+ public boolean canHandle (TemplateInfo templateStore ) {
4041 // TODO Auto-generated method stub
4142 return true ;
4243 }
4344
44- @ Override
45- public EndPoint getEndPoint (TemplateOnPrimaryDataStoreInfo templateStore ) {
46- PrimaryDataStore pdi = templateStore .getPrimaryDataStore ();
47- return pdi .getEndPoints ().get (0 );
48- }
4945
50- @ Override
51- public boolean copyTemplate (TemplateOnPrimaryDataStoreInfo templateStore , EndPoint ep ) {
52- ImageOnPrimayDataStoreTO imageTo = new ImageOnPrimayDataStoreTO (templateStore );
53- CopyTemplateToPrimaryStorageCmd copyCommand = new CopyTemplateToPrimaryStorageCmd (imageTo );
54- ep .sendMessage (copyCommand );
55- return true ;
56- }
5746
5847 private class CreateTemplateContext <T > extends AsyncRpcConext <T > {
5948 private final TemplateOnPrimaryDataStoreInfo template ;
@@ -69,10 +58,10 @@ public TemplateOnPrimaryDataStoreInfo getTemplate() {
6958 }
7059
7160 @ Override
72- public void copyTemplateAsync (TemplateOnPrimaryDataStoreInfo templateStore , EndPoint ep , AsyncCompletionCallback <CommandResult > callback ) {
73- ImageOnPrimayDataStoreTO imageTo = new ImageOnPrimayDataStoreTO ( templateStore );
74- CopyTemplateToPrimaryStorageCmd copyCommand = new CopyTemplateToPrimaryStorageCmd ( imageTo );
75- CreateTemplateContext <CommandResult > context = new CreateTemplateContext <CommandResult >(callback , templateStore );
61+ public void copyTemplateAsync (String destUri , String srcUri , EndPoint ep , AsyncCompletionCallback <CommandResult > callback ) {
62+
63+ CopyCmd copyCommand = new CopyCmd ( destUri , srcUri );
64+ CreateTemplateContext <CommandResult > context = new CreateTemplateContext <CommandResult >(callback , null );
7665 AsyncCallbackDispatcher <DefaultImageMotionStrategy , Answer > caller = AsyncCallbackDispatcher .create (this );
7766 caller .setCallback (caller .getTarget ().copyTemplateCallBack (null , null ))
7867 .setContext (context );
@@ -98,4 +87,10 @@ public Object copyTemplateCallBack(AsyncCallbackDispatcher<DefaultImageMotionStr
9887 return null ;
9988 }
10089
90+ @ Override
91+ public EndPoint getEndPoint (TemplateInfo destTemplate ,
92+ TemplateInfo srcTemplate ) {
93+ return null ;
94+ }
95+
10196}
0 commit comments