vre-modeler/src/org/gcube/vremanagement/vremodeler/test/ModelerTest.java

98 lines
3.7 KiB
Java

package org.gcube.vremanagement.vremodeler.test;
import java.util.Calendar;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.types.URI;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.types.VOID;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.CollectionList;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType;
import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType;
import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator;
public class ModelerTest {
public static void main(String[] args) {
try{
/*
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery riquery= client.getQuery(GCUBERIQuery.class);
riquery.addAtomicConditions(new AtomicCondition("//ServiceName", "VREModeler"));
List<GCUBERunningInstance> results=client.execute(riquery, GCUBEScope.getScope(args[0]));
*/
ModelerFactoryServiceAddressingLocator mfal =new ModelerFactoryServiceAddressingLocator();
/*EndpointReferenceType epr= results.get(0).getAccessPoint().getEndpoint("gcube/vremanagement/vremodeler/ModelerFactoryService");
System.out.println(epr);*/
EndpointReferenceType epr= new EndpointReferenceType(new URI("http://nb-lelii.isti.cnr.it:8080/wsrf/services/gcube/vremanagement/vremodeler/ModelerFactoryService"));
ModelerFactoryPortType mfptp= mfal.getModelerFactoryPortTypePort(epr);
mfptp = GCUBERemotePortTypeContext.getProxy(mfptp, GCUBEScope.getScope(args[0]));
EndpointReferenceType eprModelerRes= mfptp.createResource(new VOID());
ModelerServiceAddressingLocator msal= new ModelerServiceAddressingLocator();
ModelerServicePortType msptp=msal.getModelerServicePortTypePort(eprModelerRes);
msptp = GCUBERemotePortTypeContext.getProxy(msptp, GCUBEScope.getScope(args[0]));
System.out.println("creation requested");
VREDescription vreReq= new VREDescription();
Calendar cal= Calendar.getInstance();
vreReq.setStartTime(Calendar.getInstance());
cal.add(Calendar.MONTH, 1);
vreReq.setEndTime(cal);
vreReq.setDescription("desc");
vreReq.setDesigner("Lucio");
vreReq.setManager("Lucio");
vreReq.setName("lucioCloud");
msptp.setDescription(vreReq);
System.out.println("description set");
CollectionList cl=msptp.getCollection(new VOID());
System.out.println("collection list is null?"+(cl.getList()==null));
for(int i=0; i< cl.getList().length; i++)
System.out.println(i+" - "+cl.getList(i));
msptp.setCollection(new CollectionArray(new String[]{cl.getList(0).getId()}));
System.out.println("collection set");
FunctionalityIDArray fida= new FunctionalityIDArray();
fida.setFunctionalityIDElement(new String[]{"0"});
msptp.setFunctionality(fida);
System.out.println("functionality set");
msptp.setUseCloud(true);
msptp.setCloudVMs(2);
//msptp.setUseCloud(false);
//msptp.setGHNs(new GHNArray(new String[]{"af63ccc0-d6a7-11df-b524-ba33a5c87470","73ceb130-e844-11df-a7f0-e529e2191760"},"af63ccc0-d6a7-11df-b524-ba33a5c87470"));
msptp.deployVRE(new VOID());
for (int i=0; i<200; i++){
Thread.sleep(30000);
System.out.println("report is:");
System.out.println(msptp.checkStatus(new VOID()));
}
}catch(Exception e){e.printStackTrace();}
}
}