From 85c7debf0e8e5ce0517eb423aafc19fcfb9e1373 Mon Sep 17 00:00:00 2001 From: Ali_fahs Date: Wed, 14 Apr 2021 16:54:45 +0200 Subject: [PATCH 1/2] Get the number of available candidate nodes --- .../main/java/org/activeeon/morphemic/PAGateway.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index 9f2a3ddc..d893b980 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -308,6 +308,16 @@ public class PAGateway { return filteredNodeCandidates; } + /** + * This function returns the number of available node candidates according to the added clouds + * @return the number of available node candidates + */ + public int getLengthOfNodeCandidates() { + List allNodeCandidates = EntityManagerHelper.createQuery("SELECT nc FROM NodeCandidate nc", + NodeCandidate.class).getResultList(); + return allNodeCandidates.size(); + } + /** * Define a node source in PA server related to a deployment information * @param nodeSourceName A valid and unique node source name -- GitLab From 4c94a8ab6429e7bf19dcc34e2b7772063c20a82c Mon Sep 17 00:00:00 2001 From: Ali_fahs Date: Tue, 20 Apr 2021 10:06:24 +0200 Subject: [PATCH 2/2] A function to return the list of deployed VMs --- .../main/java/org/activeeon/morphemic/PAGateway.java | 10 ++++++++++ .../deployment/PAResourceManagerGateway.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java index d893b980..e2428221 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/PAGateway.java @@ -11,6 +11,7 @@ import org.apache.log4j.Logger; import org.codehaus.jackson.map.ObjectMapper; import org.json.JSONArray; import org.json.JSONObject; +import org.ow2.proactive.resourcemanager.common.event.RMNodeEvent; import org.ow2.proactive.resourcemanager.exception.RMException; import org.ow2.proactive.scheduler.common.exception.NotConnectedException; import org.ow2.proactive.scheduler.common.exception.UserException; @@ -318,6 +319,15 @@ public class PAGateway { return allNodeCandidates.size(); } + /** + * This function returns a list of available VMs + * @return rmNodeEvents a list of available Nodes and their associate parameters + */ + public List getListOfActiveVMs() throws NotConnectedException, PermissionRestException { + List rmNodeEvents = resourceManagerGateway.getListOfNodesEvents(); + return rmNodeEvents; + } + /** * Define a node source in PA server related to a deployment information * @param nodeSourceName A valid and unique node source name diff --git a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java index 883866de..7ae0023f 100644 --- a/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java +++ b/scheduling-abstraction-layer/src/main/java/org/activeeon/morphemic/infrastructure/deployment/PAResourceManagerGateway.java @@ -5,6 +5,7 @@ import org.apache.http.conn.ConnectTimeoutException; import org.apache.log4j.Logger; import org.ow2.proactive.resourcemanager.common.NSState; import org.ow2.proactive.resourcemanager.common.event.RMNodeEvent; +import org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent; import org.ow2.proactive.resourcemanager.common.event.dto.RMStateFull; import org.ow2.proactive.resourcemanager.exception.RMException; import org.ow2.proactive.resourcemanager.exception.RMNodeException; @@ -86,6 +87,15 @@ public class PAResourceManagerGateway { rmRestInterface = RMConnectionHelper.init(paURL); } + /** + * Get the available VMs at the proactive server + * @return rmNodeEvents the list of the available VMs + */ + public List getListOfNodesEvents() throws NotConnectedException, PermissionRestException { + RMStateFull rmStateFull = rmRestInterface.getRMStateFull(RMConnectionHelper.getSessionId()); + List rmNodeEvents = rmStateFull.getNodesEvents(); + return rmNodeEvents; + } /** * Connect to the ProActive server -- GitLab