Commit d17647f0 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Fix ansible bugs: set correct name for deployer and fix deployer ansible logging

parent a55f54c7
...@@ -135,23 +135,24 @@ public class ConfigurationService { ...@@ -135,23 +135,24 @@ public class ConfigurationService {
Matcher match = p.matcher(ymlStr); Matcher match = p.matcher(ymlStr);
while (match.find()) { while (match.find()) {
String line = match.group(); String line = match.group();
if (!line.contains("\"")) { if (!line.contains("\"") || line.contains("'")) {
String cpusNum = line.split(":")[1]; String cpusNum = line.split(":")[1];
cpusNum = cpusNum.replaceAll(",", "").trim(); cpusNum = cpusNum.replaceAll(",", "").trim();
ymlStr = ymlStr.replaceAll(cpusNum, "\"" + cpusNum + "\""); ymlStr = ymlStr.replaceAll(cpusNum, '\'' + cpusNum + '\'');
} }
} }
p = Pattern.compile("memory:.*"); p = Pattern.compile("memory:.*");
match = p.matcher(ymlStr); match = p.matcher(ymlStr);
while (match.find()) { while (match.find()) {
String line = match.group(); String line = match.group();
if (!line.contains("\"")) { if (!line.contains("\"") || line.contains("'")) {
String memory = line.split(":")[1]; String memory = line.split(":")[1];
memory = memory.replaceAll("}", "").trim(); memory = memory.replaceAll("}", "").trim();
ymlStr = ymlStr.replaceAll(memory, "\"" + memory + "\""); ymlStr = ymlStr.replaceAll(memory, '\'' + memory + '\'');
} }
} }
return ymlStr;
return ymlStr.replaceAll("'''", "'");
} }
} }
...@@ -145,10 +145,7 @@ public class DeployService { ...@@ -145,10 +145,7 @@ public class DeployService {
null).get(0); null).get(0);
; ;
deployerInvokationMessage.setOwner(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername()); deployerInvokationMessage.setOwner(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername());
// Message response = MessageGenerator.generate ArtificialMessage(System.getProperty("user.home")
// + File.separator + "workspace" + File.separator + "DRIP"
// + File.separator + "docs" + File.separator + "json_samples"
// + File.separator + "deployer_ansible_response_benchmark.json");
logger.info("Calling deployer"); logger.info("Calling deployer");
Message response = (deployer.call(deployerInvokationMessage)); Message response = (deployer.call(deployerInvokationMessage));
logger.info("Got response from deployer"); logger.info("Got response from deployer");
...@@ -292,7 +289,12 @@ public class DeployService { ...@@ -292,7 +289,12 @@ public class DeployService {
private MessageParameter createConfigurationParameter(String configurationID, String confType) throws JSONException { private MessageParameter createConfigurationParameter(String configurationID, String confType) throws JSONException {
String configuration = configurationService.get(configurationID, "yml"); String configuration = configurationService.get(configurationID, "yml");
MessageParameter configurationParameter = new MessageParameter(); MessageParameter configurationParameter = new MessageParameter();
configurationParameter.setName(confType); if (confType.equals("ansible")) {
configurationParameter.setName("playbook");
} else {
configurationParameter.setName(confType);
}
configurationParameter.setEncoding("UTF-8"); configurationParameter.setEncoding("UTF-8");
configurationParameter.setValue(configuration); configurationParameter.setValue(configuration);
return configurationParameter; return configurationParameter;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package nl.uva.sne.drip.api.v1.rest; package nl.uva.sne.drip.api.v1.rest;
import nl.uva.sne.drip.drip.commons.data.v1.external.GrafanaMonitorringMessage;
import com.webcohesion.enunciate.metadata.rs.ResponseCode; import com.webcohesion.enunciate.metadata.rs.ResponseCode;
import com.webcohesion.enunciate.metadata.rs.StatusCodes; import com.webcohesion.enunciate.metadata.rs.StatusCodes;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -53,8 +54,8 @@ public class MonitorringMessageController { ...@@ -53,8 +54,8 @@ public class MonitorringMessageController {
public @ResponseBody public @ResponseBody
String post(@RequestBody MonitorringMessage message) { String post(@RequestBody MonitorringMessage message) {
return monitorringMessageService.save(message).getId(); return monitorringMessageService.save(message).getId();
} }
@RequestMapping(value = "/{id}", method = RequestMethod.GET) @RequestMapping(value = "/{id}", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody public @ResponseBody
......
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