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

Fix empty communication and script tasks building

parent b7d200ad
......@@ -85,6 +85,7 @@ public class PAGateway {
private List<Port> extractListOfPortsToOpen(JSONArray ports) {
List<Port> portsToOpen = new LinkedList<>();
if (ports != null) {
ports.forEach(object -> {
JSONObject portEntry = (JSONObject) object;
if (Objects.equals("PortProvided", portEntry.optString("type"))) {
......@@ -92,6 +93,7 @@ public class PAGateway {
portsToOpen.add(portToOpen);
}
});
}
return portsToOpen;
}
......@@ -125,7 +127,9 @@ public class PAGateway {
private List<String> extractParentTasks(JSONObject job, JSONObject task) {
List<String> parentTasks = new LinkedList<>();
task.optJSONArray("ports").forEach(portObject -> {
JSONArray ports = task.optJSONArray("ports");
if (ports != null) {
ports.forEach(portObject -> {
JSONObject portEntry = (JSONObject) portObject;
if (Objects.equals("PortRequired", portEntry.optString("type"))
&& portEntry.optBoolean("isMandatory")) {
......@@ -134,6 +138,7 @@ public class PAGateway {
parentTasks.add(findTaskByProvidedPort(job.optJSONArray("tasks"), providedPortName));
}
});
}
return parentTasks;
}
......@@ -586,7 +591,14 @@ public class PAGateway {
if (!(task.getInstallation().getInstall().isEmpty() &&
task.getInstallation().getPreInstall().isEmpty() &&
task.getInstallation().getPostInstall().isEmpty())) {
scriptTaskInstall = PAFactory.createBashScriptTask(task.getName() + "_install" + taskNameSuffix, task.getInstallation().getInstall());
if (!task.getInstallation().getInstall().isEmpty()) {
scriptTaskInstall = PAFactory.createBashScriptTask(task.getName() + "_install" + taskNameSuffix,
task.getInstallation().getInstall());
} else {
scriptTaskInstall = PAFactory.createBashScriptTask(task.getName() + "_install" + taskNameSuffix,
"echo \"Installation script is empty. Nothing to be executed.\"");
}
if (!task.getInstallation().getPreInstall().isEmpty()) {
scriptTaskInstall.setPreScript(PAFactory.createSimpleScript(task.getInstallation().getPreInstall(), "bash"));
}
......@@ -600,7 +612,14 @@ public class PAGateway {
if (!(task.getInstallation().getStart().isEmpty() &&
task.getInstallation().getPreStart().isEmpty() &&
task.getInstallation().getPostStart().isEmpty())) {
scriptTaskStart = PAFactory.createBashScriptTask(task.getName() + "_start" + taskNameSuffix, task.getInstallation().getStart());
if (!task.getInstallation().getStart().isEmpty()) {
scriptTaskStart = PAFactory.createBashScriptTask(task.getName() + "_start" + taskNameSuffix,
task.getInstallation().getStart());
} else {
scriptTaskStart = PAFactory.createBashScriptTask(task.getName() + "_start" + taskNameSuffix,
"echo \"Installation script is empty. Nothing to be executed.\"");
}
if (!task.getInstallation().getPreStart().isEmpty()) {
scriptTaskStart.setPreScript(PAFactory.createSimpleScript(task.getInstallation().getPreStart(), "bash"));
}
......
......@@ -6,4 +6,6 @@ while [ `ps aux | grep [l]ock_is_held | wc -l` != 0 ]; do
((i=i+10));
done
echo "Exited the while loop, time spent: $i"
ps aux | grep [a]pt
\ No newline at end of file
echo "ps aux | grep apt"
ps aux | grep apt
echo "Waiting for lock task ended properly."
\ No newline at end of file
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