Commit bab2b8a9 authored by Spiros Koulouzis's avatar Spiros Koulouzis

set correct key for all VMs

parent a059b890
......@@ -207,7 +207,7 @@ public class DeployService {
Map<String, Object> toscaProvisonMap = pro.getKeyValue();
List<String> vmNames = TOSCAUtils.getVMsNodeNamesFromTopology(toscaProvisonMap);
for (String name : vmNames) {
Map<String, Object> outputs = TOSCAUtils.getOutputsForNode(toscaProvisonMap, name);
Map<String, String> outputs = TOSCAUtils.getOutputsForNode(toscaProvisonMap, name);
MessageParameter messageParameter = createCredentialPartameter(outputs);
parameters.add(messageParameter);
}
......@@ -235,20 +235,16 @@ public class DeployService {
deployDao.deleteAll();
}
private MessageParameter createCredentialPartameter(Map<String, Object> outputs) {
private MessageParameter createCredentialPartameter(Map<String, String> outputs) {
MessageParameter messageParameter = new MessageParameter();
messageParameter.setName("credential");
messageParameter.setEncoding("UTF-8");
String key = TOSCAUtils.getOutputPair(outputs, "private_deployer_key").get(1);
messageParameter.setValue(key);
// This key is configured on all vms fo the 'user_name'
messageParameter.setValue(outputs.get("private_user_key"));
Map<String, String> attributes = new HashMap<>();
String ip = TOSCAUtils.getOutputPair(outputs, "ip").get(1);
attributes.put("IP", ip);
String role = TOSCAUtils.getOutputPair(outputs, "role").get(1);
attributes.put("role", role);
String user = TOSCAUtils.getOutputPair(outputs, "user_name").get(1);
attributes.put("user", user);
attributes.put("IP", outputs.get("ip"));
attributes.put("role", outputs.get("role"));
attributes.put("user", outputs.get("user_name"));
messageParameter.setAttributes(attributes);
return messageParameter;
}
......
......@@ -78,18 +78,18 @@ public class TOSCAUtils {
return outputs;
}
public static Map<String, Object> getOutputsForNode(Map<String, Object> toscaProvisonMap, String nodeName) {
public static Map<String, String> getOutputsForNode(Map<String, Object> toscaProvisonMap, String nodeName) {
Map<String, Object> topologyTemplate = (Map<String, Object>) ((Map<String, Object>) toscaProvisonMap.get("topology_template"));
Map<String, Object> outputs = (Map<String, Object>) topologyTemplate.get("outputs");
Map<String, Object> matchedOutputs = new HashMap<>();
Map<String, String> matchedOutputs = new HashMap<>();
Iterator it = outputs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry output = (Map.Entry) it.next();
Map<String, Object> outputValue = (Map<String, Object>) output.getValue();
Map<String, Object> val = (Map<String, Object>) outputValue.get("value");
List<String> attribute = (List<String>) val.get("get_attribute");
if (attribute.get(0).equals(nodeName)) {
matchedOutputs.put((String) output.getKey(), outputValue);
List<Map<String, String>> val = (List<Map<String, String>>) output.getValue();
for (Map<String, String> map : val) {
if (map.containsKey(nodeName)) {
matchedOutputs.put((String) output.getKey(), map.get(nodeName));
}
}
}
return matchedOutputs;
......
......@@ -282,7 +282,6 @@ public class Consumer extends DefaultConsumer {
// List<File> public_cloud_key = MessageParsing.getSSHKeys(parameters, tempInputDirPath + File.separator, "name.pub", "public_cloud_key");
// List<File> private_cloud_key = MessageParsing.getSSHKeys(parameters, tempInputDirPath + File.separator, "id_rsa", "private_cloud_key");
UserCredential userCredential = getUserCredential(parameters, tempInputDirPath);
UserDatabase userDatabase = getUserDB();
......@@ -494,8 +493,8 @@ public class Consumer extends DefaultConsumer {
if (cred instanceof EC2Credential) {
userCredential.cloudAccess.put("ec2", cred);
}
if (cred instanceof EGICredential) {
userCredential.cloudAccess.put("egi", cred);
if (cred instanceof EGICredential) {
userCredential.cloudAccess.put("egi", cred);
}
if (cred instanceof ExoGENICredential) {
userCredential.cloudAccess.put("exogeni", cred);
......@@ -563,6 +562,7 @@ public class Consumer extends DefaultConsumer {
if (userPrivateName != null) {
param = new MessageParameter();
param.setEncoding(charset);
// This key is configured on all vms fo the 'user_name'
param.setName("private_user_key");
byte[] bytes = Files.readAllBytes(Paths.get(tempInputDirPath + File.separator + userPrivateName));
param.setValue(new String(bytes, charset));
......
......@@ -2,28 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="slolved cap error">
<change beforePath="$PROJECT_DIR$/../Dockerfiles/deployer/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/../Dockerfiles/deployer/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/nb-configuration.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/nb-configuration.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/RootController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/DeployParameter.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/DeployParameter.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/DeployRequest.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/DeployRequest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/.idea/drip-deployer.iml" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/.idea/drip-deployer.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/control_agent.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/control_agent.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_check.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_check.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_compose.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_compose.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_engine.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_engine.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_kubernetes.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_kubernetes.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/docker_swarm.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/docker_swarm.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-deployer/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-deployer/rpc_server.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/v1/Consumer.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/v1/Consumer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/basic_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/basic_planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/easy-install.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/prettytable.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/venv/lib/python3.6/site-packages/pyparsing.py" beforeDir="false" />
......
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