Commit 63ff07a8 authored by Spiros Koulouzis's avatar Spiros Koulouzis

add credentials to toscatemplate

parent f7f33f11
...@@ -26,7 +26,6 @@ import java.util.ArrayList; ...@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap; import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.tosca.Credential; import nl.uva.sne.drip.model.tosca.Credential;
...@@ -36,8 +35,6 @@ import org.apache.commons.io.FileUtils; ...@@ -36,8 +35,6 @@ import org.apache.commons.io.FileUtils;
import nl.uva.sne.drip.sure.tosca.client.ApiException; import nl.uva.sne.drip.sure.tosca.client.ApiException;
import nl.uva.sne.drip.sure.tosca.client.Configuration; import nl.uva.sne.drip.sure.tosca.client.Configuration;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
/** /**
* *
...@@ -228,13 +225,14 @@ public class ToscaHelper { ...@@ -228,13 +225,14 @@ public class ToscaHelper {
return null; return null;
} }
public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplate vmTopology) { public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplateMap vmTopologyMap) {
Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates(); Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates();
Set<String> keys = nodes.keySet(); nodes.put(vmTopologyMap.getName(), vmTopologyMap.getNodeTemplate());
for (String key : keys) { // Set<String> keys = nodes.keySet();
NodeTemplate node = nodes.get(key); // for (String key : keys) {
} // NodeTemplate node = nodes.get(key);
return null; // }
return toscaTemplate;
} }
} }
...@@ -103,11 +103,10 @@ public class DRIPService { ...@@ -103,11 +103,10 @@ public class DRIPService {
if (credentials != null && credentials.size() > 0) { if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopologyMap.getNodeTemplate(), credentials); Credential credential = getBestCredential(vmTopologyMap.getNodeTemplate(), credentials);
vmTopologyMap = helper.setCredentialsInVMTopology(vmTopologyMap, credential); vmTopologyMap = helper.setCredentialsInVMTopology(vmTopologyMap, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap.getNodeTemplate()); toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap);
return toscaTemplate;
} }
} }
return null; return toscaTemplate;
} }
} }
...@@ -13,6 +13,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; ...@@ -13,6 +13,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import nl.uva.sne.drip.api.NotFoundException;
import nl.uva.sne.drip.dao.ToscaTemplateDAO; import nl.uva.sne.drip.dao.ToscaTemplateDAO;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -64,8 +65,11 @@ public class ToscaTemplateService { ...@@ -64,8 +65,11 @@ public class ToscaTemplateService {
return save(tt); return save(tt);
} }
public String findByID(String id) throws JsonProcessingException { public String findByID(String id) throws JsonProcessingException, NotFoundException {
ToscaTemplate tt = dao.findById(id).get(); ToscaTemplate tt = dao.findById(id).get();
if(tt==null){
throw new NotFoundException(404, "ToscaTemplate with id: "+id+" not found");
}
String ymlStr = objectMapper.writeValueAsString(tt); String ymlStr = objectMapper.writeValueAsString(tt);
return ymlStr; return ymlStr;
} }
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment=""> <list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/ToscaTemplateService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/service/ToscaTemplateService.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="FavoritesManager">
<favorites_list name="drip-planner" />
</component>
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
<list> <list>
......
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