Commit 3594473f authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'fix-92-93' into 'proactive-dev'

Fix SAL to handle BYON nodes registration before job creation scenario:issues 92 and 93

See merge request !141
parents 19965d59 fc91ed11
Pipeline #15530 passed with stages
in 1 minute and 54 seconds
......@@ -494,7 +494,7 @@ public class PAGateway {
filename = File.separator + "Define_NS_BYON.xml";
variables.put("NS_name", nodeSourceName);
variables.put("pa_protocol", "http");
variables.put("tokens", "BYON_"+byonNode.getJob().getJobId());
variables.put("tokens", "BYON_" + byonNode.getJobId());
variables.put("ssh_username", byonNode.getLoginCredential().getUsername());
variables.put("ssh_password", byonNode.getLoginCredential().getPassword());
/* IMPORTANT: Later we should relay only on the ssh_key. For now all the nodes must have the same login
......@@ -633,8 +633,6 @@ public class PAGateway {
public ByonNode registerNewByonNode(ByonDefinition byonNodeDefinition, String jobId) {
Validate.notNull(byonNodeDefinition, "The received Byon node definition is empty. Nothing to be registered.");
Validate.notNull(jobId, "The received jobId is empty. Nothing to be registered.");
Job job = EntityManagerHelper.find(Job.class, jobId);
assert job != null;
LOGGER.info("Registering a new BYON definition related to job " + jobId + " ...");
NodeCandidate byonNC = ByonUtils.createByonNodeCandidate(byonNodeDefinition, jobId);
......@@ -644,7 +642,7 @@ public class PAGateway {
newByonNode.setLoginCredential(byonNodeDefinition.getLoginCredential());
newByonNode.setIpAddresses(byonNodeDefinition.getIpAddresses());
newByonNode.setNodeProperties(byonNodeDefinition.getNodeProperties());
newByonNode.setJob(job);
newByonNode.setJobId(jobId);
newByonNode.setNodeCandidate(byonNC);
EntityManagerHelper.persist(newByonNode);
......@@ -671,7 +669,7 @@ public class PAGateway {
return listByonNodes;
} else {
for (ByonNode byonNode : listByonNodes) {
if (byonNode.getJob().getJobId().equals(jobId)) {
if (jobId.equals(byonNode.getJobId())) {
filteredByonNodes.add(byonNode);
}
}
......@@ -692,9 +690,9 @@ public class PAGateway {
Validate.notNull(byonIdPerComponent, "The received byonIdPerComponent structure is empty. Nothing to be added.");
EntityManagerHelper.begin();
byonIdPerComponent.forEach((byonNodeId, componentId) -> {
byonIdPerComponent.forEach((byonNodeId, componentName) -> {
ByonNode byonNode = EntityManagerHelper.find(ByonNode.class, byonNodeId);
Task task = EntityManagerHelper.find(Task.class, componentId);
Task task = EntityManagerHelper.find(Task.class, jobId + componentName);
assert byonNode!=null : "The BYON ID passed in the mapping does not exist in the database";
assert task!=null : "The componentId passed in the mapping does not exist in the database";
......@@ -706,9 +704,9 @@ public class PAGateway {
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());
LOGGER.info("BYON node source BYON_NS_"+ byonNode.getId() + " is defined");
LOGGER.info("BYON node Added: " + byonNode.getName() + " Ip: " + byonNode.getIpAddresses().get(0).getValue());
defineByonNodeSource(byonNodeList, "BYON_NS_" + byonNode.getId());
LOGGER.info("BYON node source BYON_NS_" + byonNode.getId() + " is defined");
newDeployment.setTask(task);
newDeployment.setNumber(task.getNextDeploymentID());
......
......@@ -64,8 +64,9 @@ public class ByonNode implements Serializable {
@JsonProperty("allocated")
private Boolean allocated = null;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
private Job job;
@Column(name = "JOB_ID")
@JsonProperty("jobId")
private String jobId;
public ByonNode name(String name) {
this.name = name;
......@@ -198,7 +199,8 @@ public class ByonNode implements Serializable {
Objects.equals(this.nodeCandidate, byonNode.nodeCandidate) &&
Objects.equals(this.id, byonNode.id) &&
Objects.equals(this.userId, byonNode.userId) &&
Objects.equals(this.allocated, byonNode.allocated);
Objects.equals(this.allocated, byonNode.allocated) &&
Objects.equals(this.jobId, byonNode.jobId);
}
@Override
......@@ -221,6 +223,7 @@ public class ByonNode implements Serializable {
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" allocated: ").append(toIndentedString(allocated)).append("\n");
sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
sb.append("}");
return sb.toString();
}
......
Markdown is supported
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