Commit d062dade authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'purgesal-v2' into 'proactive-dev'

Add purging SAL's DB endpoint

See merge request !142
parents 3594473f 36c42f33
Pipeline #15534 passed with stages
in 1 minute and 48 seconds
......@@ -197,7 +197,6 @@ public class PAGateway {
EmsDeploymentRequest.class).getResultList();
}
/**
*
* Return the dot format of the application's graph
......@@ -656,7 +655,6 @@ public class PAGateway {
}
/**
* Return the List of registered BYON nodes
* @param jobId A constructed job identifier, If "0" is passed as the JobId all the Byon Nodes will be returned
......@@ -723,7 +721,6 @@ public class PAGateway {
return 0;
}
/**
* Undeploy clouds
* @param cloudIDs List of cloud IDs to remove
......@@ -1930,4 +1927,36 @@ public class PAGateway {
LOGGER.info("Results of task: " + taskName + " fetched successfully: " + taskResultsMap.toString());
return taskResultsMap;
}
public void cleanAll() {
EntityManagerHelper.begin();
LOGGER.info("Cleaning Jobs ...");
Job.clean();
LOGGER.info("Cleaning Tasks ...");
Task.clean();
LOGGER.info("Cleaning PAClouds ...");
PACloud.clean();
LOGGER.info("Cleaning Deployments ...");
Deployment.clean();
LOGGER.info("Cleaning Ports ...");
Port.clean();
LOGGER.info("Cleaning Credentials ...");
Credentials.clean();
LOGGER.info("Cleaning EmsDeploymentRequests ...");
EmsDeploymentRequest.clean();
LOGGER.info("Cleaning NodeCandidates ...");
NodeCandidate.clean();
LOGGER.info("Cleaning Clouds ...");
Cloud.clean();
LOGGER.info("Cleaning Images ...");
Image.clean();
LOGGER.info("Cleaning Hardwares ...");
Hardware.clean();
LOGGER.info("Cleaning Jobs ...");
Location.clean();
LOGGER.info("Cleaning ByonNodes ...");
ByonNode.clean();
EntityManagerHelper.commit();
LOGGER.info("Done.");
}
}
......@@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.activeeon.morphemic.service.EntityManagerHelper;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
......@@ -68,6 +69,11 @@ public class ByonNode implements Serializable {
@JsonProperty("jobId")
private String jobId;
public static void clean() {
List<ByonNode> allByonNodes = EntityManagerHelper.createQuery("SELECT bn FROM ByonNode bn", ByonNode.class).getResultList();
allByonNodes.forEach(EntityManagerHelper::remove);
}
public ByonNode name(String name) {
this.name = name;
return this;
......
......@@ -5,9 +5,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
......@@ -49,6 +51,11 @@ public class Cloud implements Serializable {
@JsonProperty("owner")
private String owner = null;
public static void clean() {
List<Cloud> allClouds = EntityManagerHelper.createQuery("SELECT c FROM Cloud c", Cloud.class).getResultList();
allClouds.forEach(EntityManagerHelper::remove);
}
/**
* State of the cloud
*/
......
package org.activeeon.morphemic.model;
import lombok.*;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
......@@ -32,4 +34,9 @@ public class Credentials implements Serializable {
@Column(name = "DOMAIN")
private String domain;
public static void clean() {
List<Credentials> allCredentials = EntityManagerHelper.createQuery("SELECT c FROM Credentials c", Credentials.class).getResultList();
allCredentials.forEach(EntityManagerHelper::remove);
}
}
......@@ -4,9 +4,11 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
......@@ -60,6 +62,12 @@ public class Deployment implements Serializable {
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
private ByonNode byonNode;
public static void clean() {
List<Deployment> allDeployments = EntityManagerHelper.createQuery("SELECT d FROM Deployment d", Deployment.class).getResultList();
allDeployments.forEach(EntityManagerHelper::remove);
}
@Override
public String toString() {
switch (deploymentType) {
......
package org.activeeon.morphemic.model;
import lombok.*;
import org.activeeon.morphemic.service.EntityManagerHelper;
import org.hibernate.annotations.GenericGenerator;
import org.ow2.proactive.scheduler.common.task.TaskVariable;
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
......@@ -19,6 +21,11 @@ import java.util.Map;
@Table(name = "EMSDEPLOYMENTREQUEST")
public class EmsDeploymentRequest implements Serializable {
public static void clean() {
List<EmsDeploymentRequest> allEmsDeploymentRequests = EntityManagerHelper.createQuery("SELECT emsdr FROM EmsDeploymentRequest emsdr", EmsDeploymentRequest.class).getResultList();
allEmsDeploymentRequests.forEach(EntityManagerHelper::remove);
}
public enum TargetType {
vm("IAAS"),
container("PAAS"),
......
......@@ -3,9 +3,11 @@ package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
/**
......@@ -54,6 +56,11 @@ public class Hardware implements Serializable {
@JsonProperty("owner")
private String owner = null;
public static void clean() {
List<Hardware> allHardwares = EntityManagerHelper.createQuery("SELECT h FROM Hardware h", Hardware.class).getResultList();
allHardwares.forEach(EntityManagerHelper::remove);
}
public Hardware id(String id) {
this.id = id;
return this;
......
......@@ -3,9 +3,11 @@ package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
/**
......@@ -46,6 +48,11 @@ public class Image implements Serializable {
@JsonProperty("owner")
private String owner = null;
public static void clean() {
List<Image> allImages = EntityManagerHelper.createQuery("SELECT i FROM Image i", Image.class).getResultList();
allImages.forEach(EntityManagerHelper::remove);
}
public Image id(String id) {
this.id = id;
return this;
......
......@@ -3,6 +3,7 @@ package org.activeeon.morphemic.model;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import lombok.*;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.IOException;
......@@ -40,6 +41,11 @@ public class Job implements Serializable {
@OneToMany(fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.REFRESH)
private List<Task> tasks;
public static void clean() {
List<Job> allJobs = EntityManagerHelper.createQuery("SELECT j FROM Job j", Job.class).getResultList();
allJobs.forEach(EntityManagerHelper::remove);
}
public Task findTask(String taskName) {
return tasks.stream()
.filter(task -> task.getName().equals(taskName)).findAny().orElse(null);
......
......@@ -5,9 +5,11 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
......@@ -32,6 +34,11 @@ public class Location implements Serializable {
@JsonProperty("providerId")
private String providerId = null;
public static void clean() {
List<Location> allLocations = EntityManagerHelper.createQuery("SELECT l FROM Location l", Location.class).getResultList();
allLocations.forEach(EntityManagerHelper::remove);
}
/**
* Scope of the location
*/
......
......@@ -31,6 +31,11 @@ public class NodeCandidate implements Serializable {
@JsonProperty("id")
private String id = null;
public static void clean() {
List<NodeCandidate> allNodeCandidates = EntityManagerHelper.createQuery("SELECT nc FROM NodeCandidate nc", NodeCandidate.class).getResultList();
allNodeCandidates.forEach(EntityManagerHelper::remove);
}
/**
* Gets or Sets nodeCandidateType
*/
......
......@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
......@@ -68,6 +69,11 @@ public class PACloud implements Serializable {
@OneToOne
private Credentials credentials;
public static void clean() {
List<PACloud> allPAClouds = EntityManagerHelper.createQuery("SELECT pac FROM PACloud pac", PACloud.class).getResultList();
allPAClouds.forEach(EntityManagerHelper::remove);
}
public void addDeployment(Deployment deployment) {
if (deployments==null){
deployments = new LinkedList<>();
......
......@@ -2,9 +2,11 @@ package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import org.activeeon.morphemic.service.EntityManagerHelper;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
......@@ -34,4 +36,9 @@ public class Port implements Serializable {
throw new IllegalArgumentException(String.format("Invalid port value provided: %d", value));
}
}
public static void clean() {
List<Port> allPorts = EntityManagerHelper.createQuery("SELECT p FROM Port p", Port.class).getResultList();
allPorts.forEach(EntityManagerHelper::remove);
}
}
......@@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.activeeon.morphemic.service.EntityManagerHelper;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
......@@ -60,6 +61,11 @@ public class Task implements Serializable {
@Column(name = "NEXT_DEPLOYMENT_ID")
private Long nextDeploymentID = 0L;
public static void clean() {
List<Task> allTasks = EntityManagerHelper.createQuery("SELECT t FROM Task t", Task.class).getResultList();
allTasks.forEach(EntityManagerHelper::remove);
}
public void addDeployment(Deployment deployment) {
if (deployments==null){
deployments = new LinkedList<>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment