Commit 5d6f23dd authored by Spiros Koulouzis's avatar Spiros Koulouzis

adding interface to topologies

parent 6cef7540
......@@ -6,6 +6,7 @@
package nl.uva.sne.drip.service;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
......@@ -43,7 +44,6 @@ public class ProvisionerService {
toscaTemplate = addProvisionInterface(toscaTemplate);
return null;
}
......@@ -54,11 +54,27 @@ public class ProvisionerService {
protected ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) {
List<Map<String, NodeTemplate>> vmTopologies = getVmTopologies(toscaTemplate);
for (Map<String, NodeTemplate> vmTopologyMap : vmTopologies) {
NodeTemplate vmTopology = vmTopologyMap.get(vmTopologyMap.keySet().iterator().next());
String topologyName = vmTopologyMap.keySet().iterator().next();
NodeTemplate vmTopology = vmTopologyMap.get(topologyName);
Map<String, Object> interfaces = vmTopology.getInterfaces();
Map<String, Object> cloudStormInterface = getCloudStormProvisionInterface(topologyName);
interfaces.put("cloudStorm", cloudStormInterface);
}
return toscaTemplate;
}
private Map<String, Object> getCloudStormProvisionInterface(String topologyName) {
Map<String, Object> csMap = new HashMap<>();
Map<String, Object> provisionMap = new HashMap<>();
Map<String, Object> inputs = new HashMap<>();
inputs.put("code_type", "SEQ");
inputs.put("object_type", "SubTopology");
inputs.put("objects", topologyName);
provisionMap.put("inputs", inputs);
csMap.put("provision", provisionMap);
}
}
......@@ -35,8 +35,10 @@ import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.Swagger2SpringBoot;
import nl.uva.sne.drip.api.ApiException;
import nl.uva.sne.drip.configuration.MongoConfig;
import nl.uva.sne.drip.model.Credentials;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
......@@ -61,7 +63,7 @@ public class ServiceTests {
private String testApplicationExampleToscaContents;
private static final String testApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example.yaml";
private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_updated.yaml";
private static final String testOutputApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_updated.yaml";
private static final String testOutputApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_output.yaml";
@Autowired
CredentialService credentialService;
......@@ -331,11 +333,12 @@ public class ServiceTests {
@Test
public void testProvisionerServiceProvision() {
public void testProvisionerServiceProvision() throws FileNotFoundException, IOException, ApiException {
FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
FileInputStream in = new FileInputStream(testOutputApplicationExampleToscaFilePath);
MultipartFile file = new MockMultipartFile("file", in);
toscaTemplateID = toscaTemplateService.saveFile(file);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(toscaTemplateService.findByID(toscaTemplateID));
provisionService.addProvisionInterface(toscaTemplate);
}
......
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