diff --git a/build.xml b/build.xml index 52e8b46..72496b7 100644 --- a/build.xml +++ b/build.xml @@ -1,15 +1,15 @@ - - - + - - - - + + + + - + - - - + + + @@ -63,7 +66,7 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - + @@ -83,38 +86,39 @@ etics.build: (optional) Set to 'true', it indicates that build structures a + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -131,163 +135,169 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + @@ -295,7 +305,7 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - + @@ -318,10 +328,10 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - - - - + + + + @@ -373,8 +383,15 @@ etics.build: (optional) Set to 'true', it indicates that build structures a + + + + + - + @@ -383,9 +400,10 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - + - + + @@ -395,136 +413,163 @@ etics.build: (optional) Set to 'true', it indicates that build structures a - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - + + + + - - - - - + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + diff --git a/schema/ModelerService.wsdl b/schema/ModelerService.wsdl index c831500..4c918f3 100644 --- a/schema/ModelerService.wsdl +++ b/schema/ModelerService.wsdl @@ -142,6 +142,10 @@ + + + + @@ -240,6 +244,13 @@ + + + + + + + @@ -355,6 +366,11 @@ + + + + + diff --git a/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java b/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java index d94d214..3381e91 100644 --- a/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java +++ b/src/org/gcube/vremanagement/vremodeler/consumers/GenericResourceConsumer.java @@ -38,7 +38,7 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class); logger.info("notification received for genericResource "+id+" and operation "+operation); - if (id.compareTo(this.functionalityResourceId)==0 && (operation.compareTo("update")==0)){ + if ((operation.compareTo("update")==0) && id.compareTo(this.functionalityResourceId)==0){ logger.trace("notification received for functionalityResource with id "+id+" in scope "+scope.toString()); KGCUBEGenericFunctionalityResource resource= new KGCUBEGenericFunctionalityResource(); resource.load(new StringReader(profile)); @@ -54,6 +54,7 @@ private GCUBELog logger= new GCUBELog(GHNConsumer.class); FunctionalityHandler functionalityHandler= new FunctionalityHandler(); KGCUBEGenericFunctionalityResource functResource=new KGCUBEGenericFunctionalityResource(); functResource.load(new StringReader(profile)); + this.functionalityResourceId=functResource.getID(); functionalityHandler.add(functResource); } else if (ServiceContext.getContext().getSecondaryTypeGenericResourceRequired().contains(genericResource.getSecondaryType())) diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java b/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java index 651bbbc..faae001 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java @@ -10,18 +10,20 @@ import org.gcube.vremanagement.vremodeler.stubs.deployreport.DeployReport; public class ModelerPersistenceDelegate extends GCUBEWSFilePersistenceDelegate{ - protected void onLoad(ModelerResource resource, ObjectInputStream ois) throws Exception { + protected synchronized void onLoad(ModelerResource resource, ObjectInputStream ois) throws Exception { super.onLoad(resource, ois); resource.setId((String)ois.readObject()); resource.setDeployReport((DeployReport)ois.readObject()); resource.setUseCloud(ois.readBoolean()); + if (resource.isUseCloud())resource.setNumberOfVMsForCloud(ois.readInt()); } - protected void onStore(ModelerResource resource,ObjectOutputStream oos) throws Exception { + protected synchronized void onStore(ModelerResource resource,ObjectOutputStream oos) throws Exception { super.onStore(resource, oos); oos.writeObject(resource.getId()); oos.writeObject(resource.getDeployReport()); oos.writeBoolean(resource.isUseCloud()); + if (resource.isUseCloud())oos.writeInt(resource.getNumberOfVMsForCloud()); } } diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ModelerResource.java b/src/org/gcube/vremanagement/vremodeler/impl/ModelerResource.java index dd4c4c3..0e37e1b 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ModelerResource.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ModelerResource.java @@ -23,6 +23,7 @@ public class ModelerResource extends GCUBEWSResource { this.setId((String) args[0]); this.deployReport=null; this.isUseCloud=false; + this.numberOfVMsForCloud=-1; } diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java b/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java index d677e80..a355550 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ModelerService.java @@ -98,11 +98,6 @@ public class ModelerService { */ public GHNList getGHNs(VOID var) throws GCUBEFault{ logger.trace("getGHNs method"); - try { - if (getResource().isUseCloud()) throw new GCUBEFault("deply on cloud is selected, the ghns cannot be returned"); - } catch (ResourceException e1) { - throw new GCUBEFault(e1); - } ResultSet res; ArrayList relatedGHN=new ArrayList(); try{ @@ -511,10 +506,21 @@ public class ModelerService { getResource().store(); } - public boolean isUseCloud() throws Exception{ + /** + * + * @param r VOID + * @return + * @throws Exception + */ + public boolean isUseCloud(VOID r) throws Exception{ return getResource().isUseCloud(); } + /** + * + * @param numberOfVMs + * @throws Exception + */ public void setCloudVMs(int numberOfVMs) throws Exception{ ModelerResource resource = getResource(); if (!resource.isUseCloud()) throw new Exception("the number of VMs cannot be set, you are not using cloud deployement"); @@ -522,4 +528,16 @@ public class ModelerService { resource.store(); } + /** + * + * @param r VOID + * @return + * @throws Exception + */ + public int getCloudVMs(VOID r) throws Exception{ + ModelerResource resource = getResource(); + if (!resource.isUseCloud()) throw new Exception("the number of VMs cannot be returned, you are not using cloud deployement"); + return resource.getNumberOfVMsForCloud(); + } + } diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java b/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java index b4d9fb4..f97e1bf 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ServiceContext.java @@ -62,6 +62,7 @@ public class ServiceContext extends GCUBEServiceContext{ ISNotifier notifier= GHNContext.getImplementation(ISNotifier.class); for (GCUBEScope scope : ServiceContext.getContext().getInstance().getScopes().values()){ + if (scope.isInfrastructure()) continue; ServiceContext.getContext().setScope(scope); ArrayList genResList= new ArrayList(); diff --git a/src/org/gcube/vremanagement/vremodeler/impl/deploy/DeployGHNsOnCloud.java b/src/org/gcube/vremanagement/vremodeler/impl/deploy/DeployGHNsOnCloud.java index ef0ec31..48ddfce 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/deploy/DeployGHNsOnCloud.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/deploy/DeployGHNsOnCloud.java @@ -3,7 +3,6 @@ package org.gcube.vremanagement.vremodeler.impl.deploy; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import net.java.dev.jaxb.array.StringArray; import org.apache.axis.client.Call; @@ -15,6 +14,7 @@ import org.gcube.vremanagement.vremodeler.stubs.deployreport.GHNonCloudReport; import org.gcube.vremanagement.vremodeler.stubs.deployreport.State; import org.uoa.eolus.Eolus; import org.uoa.eolus.EolusServiceLocator; +import org.uoa.eolus.startContainer; public class DeployGHNsOnCloud{ @@ -52,11 +52,10 @@ public class DeployGHNsOnCloud{ ((Stub) eolus)._setProperty(Call.USERNAME_PROPERTY, username); ((Stub) eolus)._setProperty(Call.PASSWORD_PROPERTY, password); - + //filling the report - List ghnsStates=new ArrayList(numberOfVMs); - Collections.fill(ghnsStates, State.Running); - this.report.setDeployingState(ghnsStates); + report.setDeployingState(new State[numberOfVMs]); + Arrays.fill(report.getDeployingState(), State.Waiting); VM[] hostnames=createVMs(eolus); configureAndStartContainers(eolus, hostnames); @@ -81,38 +80,51 @@ public class DeployGHNsOnCloud{ StringArray vnets = new StringArray(); vnets.setItem(nets); - //TODO: change this code + //TODO: change this code to support more VMs templates String template=eolus.getTemplates().getItem()[0]; + logger.trace("got the template: "+template); VM[] vmsNames= new VM[numberOfVMs]; //the first VM will be set with limited resource (1Gb of ram) for the RM eolus.createVM(template, vreName+"ResourceManager", 2, 1024, vnets); vmsNames[0]= new VM(vreName+"ResourceManager"); - + logger.trace("creating the first VM for ResourceManager "+vreName+"ResourceManager"); + report.getDeployingState()[0]=State.Running; //the others VMs will be created with 2 GB of ram for (int i=1; i 2) - this.report.getDeployingState().set(i, State.Failed); + logger.trace("configuring the GHN on host for VM "+hostnames[i].getName()+" got the following report:"); + logger.trace("std output "+res[0]); + //terrible... waiting for enhancement + if (res.length > 2) { + this.report.getDeployingState()[i]= State.Failed; + logger.trace("std error "+res[1]); + } } + + //waiting few seconds before start the container + Thread.sleep(60000); + //starting the containers + for (int i=0; i { } private void insert(GCUBEHostingNode ghn) throws Exception { + +//GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR, ISONCLOUD BOOLEAN) ArrayList row= new ArrayList(10); String id= ghn.getID(); row.add(id); diff --git a/src/org/gcube/vremanagement/vremodeler/stubs/deployreport/GHNonCloudReport.java b/src/org/gcube/vremanagement/vremodeler/stubs/deployreport/GHNonCloudReport.java index d53e974..b4db11e 100644 --- a/src/org/gcube/vremanagement/vremodeler/stubs/deployreport/GHNonCloudReport.java +++ b/src/org/gcube/vremanagement/vremodeler/stubs/deployreport/GHNonCloudReport.java @@ -1,9 +1,6 @@ package org.gcube.vremanagement.vremodeler.stubs.deployreport; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; public class GHNonCloudReport implements Serializable { /** @@ -13,11 +10,10 @@ public class GHNonCloudReport implements Serializable { private State state; - private List deployingState= new ArrayList(); + private State[] deployingState; public GHNonCloudReport() { this.state= State.Waiting; - Collections.fill(this.deployingState, State.Waiting); } @@ -29,11 +25,11 @@ public class GHNonCloudReport implements Serializable { this.state = state; } - public List getDeployingState() { + public State[] getDeployingState() { return deployingState; } - public void setDeployingState(List deployingState) { + public void setDeployingState(State[] deployingState) { this.deployingState = deployingState; } } diff --git a/src/org/gcube/vremanagement/vremodeler/test/ModelerTest.java b/src/org/gcube/vremanagement/vremodeler/test/ModelerTest.java index 80f7379..e13ac0e 100644 --- a/src/org/gcube/vremanagement/vremodeler/test/ModelerTest.java +++ b/src/org/gcube/vremanagement/vremodeler/test/ModelerTest.java @@ -1,22 +1,17 @@ package org.gcube.vremanagement.vremodeler.test; -import java.util.Date; -import java.util.List; - +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.contexts.GHNContext; -import org.gcube.common.core.informationsystem.client.AtomicCondition; -import org.gcube.common.core.informationsystem.client.ISClient; -import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery; -import org.gcube.common.core.resources.GCUBERunningInstance; 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.GHNArray; 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; @@ -31,10 +26,11 @@ public class ModelerTest { GCUBERIQuery riquery= client.getQuery(GCUBERIQuery.class); riquery.addAtomicConditions(new AtomicCondition("//ServiceName", "VREModeler")); List 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= 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])); @@ -43,40 +39,57 @@ public class ModelerTest { ModelerServiceAddressingLocator msal= new ModelerServiceAddressingLocator(); ModelerServicePortType msptp=msal.getModelerServicePortTypePort(eprModelerRes); - - msptp = GCUBERemotePortTypeContext.getProxy(msptp, GCUBEScope.getScope(args[0])); + + System.out.println("creation requested"); - VRERequest vreReq= new VRERequest(); - vreReq.setStartTime(new Date().getTime()); - vreReq.setEndTime(new Date().getTime()); - vreReq.setVREDescription("desc"); - vreReq.setVREDesigner("Lucio"); - vreReq.setVREManager("Lucio"); - vreReq.setVREName("test"); - msptp.setVREModel(vreReq); - System.out.println("first call done"); - System.out.println(msptp.getGHNs(new VOID())); - /* - CollectionArray ca= new CollectionArray(); - ca.setCollectionElement(new String[]{"e60f6340-e970-11dd-bb52-d1724dda0823"}); - msptp.setCollection(ca); + + 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("testCloud"); + 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"); - GHNArray ghnArray= new GHNArray(); - ghnArray.setGHNElement(new String[]{"64033f00-ea3a-11dd-af49-d0586efd3870","29b7ff70-ea3a-11dd-810a-d18bf0285315"}); - msptp.setGHNs(ghnArray); + msptp.setUseCloud(true); + msptp.setCloudVMs(2); - System.out.println("-"+msptp.checkStatus(new VOID()).getReports(0)+"-"); + //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();} }