Commit 4c8faa9f authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'fix-99' into 'proactive-dev'

Fix BYON resources handling when job is submitted and ByonNode removal

See merge request !144
parents d062dade f0eb3f1b
Pipeline #15639 passed with stages
in 3 minutes and 12 seconds
......@@ -700,10 +700,19 @@ public class PAGateway {
newDeployment.setDeploymentType(NodeType.BYON);
newDeployment.setByonNode(byonNode);
PACloud cloud = new PACloud();
String nodeSourceName = "BYON_NS_" + byonNode.getId();
cloud.setCloudID(nodeSourceName);
cloud.setNodeSourceNamePrefix(nodeSourceName);
cloud.setCloudType(CloudType.BYON);
cloud.addDeployment(newDeployment);
newDeployment.setPaCloud(cloud);
EntityManagerHelper.persist(cloud);
List<ByonNode> byonNodeList = new LinkedList<>();
byonNodeList.add(byonNode);
LOGGER.info("BYON node Added: " + byonNode.getName() + " Ip: " + byonNode.getIpAddresses().get(0).getValue());
defineByonNodeSource(byonNodeList, "BYON_NS_" + byonNode.getId());
defineByonNodeSource(byonNodeList, nodeSourceName);
LOGGER.info("BYON node source BYON_NS_" + byonNode.getId() + " is defined");
newDeployment.setTask(task);
......@@ -824,14 +833,29 @@ public class PAGateway {
LOGGER.error("The passed BYON ID is not Found in the database");
return false;
}
else {
if(!undeployByonNs(byonNode, false, true)) {
LOGGER.warn("The BYON node source undeploy finished with errors");
LOGGER.info("Deleting the corresponding PACloud from the database ...");
PACloud paCloud = EntityManagerHelper.find(PACloud.class, "BYON_NS_" + byonNode.getId());
if (paCloud != null) {
if (paCloud.getDeployments() != null) {
LOGGER.info("Cleaning deployments from related tasks {}", paCloud.getDeployments().toString());
paCloud.getDeployments().forEach(deployment -> deployment.getTask().removeDeployment(deployment));
LOGGER.info("Cleaning deployments from paCloud {}", paCloud.getCloudID());
paCloud.clearDeployments();
}
LOGGER.info("Deleting the BYON node " + byonNode.getId() +" from the database" );
EntityManagerHelper.remove(byonNode);
EntityManagerHelper.commit();
EntityManagerHelper.remove(paCloud);
} else {
LOGGER.warn("The PACloud related to the byonNode {} is not found.", byonNode.getName());
}
if(!undeployByonNs(byonNode, false, true)) {
LOGGER.warn("The BYON node source undeploy finished with errors!");
}
LOGGER.info("Deleting the BYON node " + byonNode.getId() +" from the database...");
byonNode.setNodeCandidate(null);
EntityManagerHelper.remove(byonNode);
EntityManagerHelper.commit();
return true;
/*TODO:
* change the hardcoding for preempt and remove variables
......
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