Commit 25c5a25c authored by Ali Fahs's avatar Ali Fahs
Browse files

Adding a new method to get the Byon host name and node source

parent 055a5de6
Pipeline #17352 passed with stage
in 1 minute and 17 seconds
...@@ -1208,6 +1208,34 @@ public class PAGateway { ...@@ -1208,6 +1208,34 @@ public class PAGateway {
return deployNodeTask; return deployNodeTask;
} }
private String getBYONHostname(String nsName) {
List<String> nodeHostnames = new LinkedList<>();
try {
nodeHostnames = resourceManagerGateway.getAsyncDeployedNodesInformation(nsName, "hostname");
}
catch(Exception e) {
LOGGER.error(" resourceManagerGateway threw an exception: " + e);
}
if (nodeHostnames == null) {
LOGGER.error("The node Source "+ nsName + " Does not have any nodes");
throw new IllegalStateException("Node source is empty no hostname can be retrieved");
}
else {
if (nodeHostnames.size() != 1) {
if (nodeHostnames.size() == 0) {
LOGGER.error("The node Source " + nsName + " Does not have any nodes");
throw new IllegalStateException("Node source is empty no hostname can be retrieved");
} else {
LOGGER.error("The node Source " + nsName + " has more than one node");
throw new IllegalStateException("Node source has multiple nodes");
}
}
}
LOGGER.info("The hostname is retrieved successfully: " + nodeHostnames.get(0));
return nodeHostnames.get(0);
}
private ScriptTask createInfraBYONTask(Task task, Deployment deployment, String taskNameSuffix, String nodeToken) { private ScriptTask createInfraBYONTask(Task task, Deployment deployment, String taskNameSuffix, String nodeToken) {
LOGGER.debug("Acquiring node BYON script file: " + getClass().getResource(File.separator + "acquire_node_BYON_script.groovy").toString()); LOGGER.debug("Acquiring node BYON script file: " + getClass().getResource(File.separator + "acquire_node_BYON_script.groovy").toString());
ScriptTask deployNodeTask = PAFactory.createGroovyScriptTaskFromFile("acquireBYONNode_" + task.getName() + taskNameSuffix, ScriptTask deployNodeTask = PAFactory.createGroovyScriptTaskFromFile("acquireBYONNode_" + task.getName() + taskNameSuffix,
...@@ -1216,11 +1244,9 @@ public class PAGateway { ...@@ -1216,11 +1244,9 @@ public class PAGateway {
deployNodeTask.setPreScript(PAFactory.createSimpleScriptFromFIle("pre_acquire_node_script.groovy", "groovy")); deployNodeTask.setPreScript(PAFactory.createSimpleScriptFromFIle("pre_acquire_node_script.groovy", "groovy"));
Map<String, TaskVariable> variablesMap = new HashMap<>(); Map<String, TaskVariable> variablesMap = new HashMap<>();
variablesMap.put("NS_name", new TaskVariable("NS_name", String NsName = deployment.getPaCloud().getNodeSourceNamePrefix();
deployment.getPaCloud().getNodeSourceNamePrefix() + deployment.getLocationName())); variablesMap.put("NS_name", new TaskVariable("NS_name", NsName));
//TODO: To check this. Which ip address is used as host in RM? variablesMap.put("host_name", new TaskVariable("host_name", getBYONHostname(NsName)));
variablesMap.put("host_name", new TaskVariable("host_name",
deployment.getByonNode().getIpAddresses().get(0).getValue()));
variablesMap.put("token", new TaskVariable("token", nodeToken)); variablesMap.put("token", new TaskVariable("token", nodeToken));
LOGGER.debug("Variables to be added to the task: " + variablesMap.toString()); LOGGER.debug("Variables to be added to the task: " + variablesMap.toString());
......
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