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

adding interface to topologies

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