Commit 0962d33f authored by Spiros Koulouzis's avatar Spiros Koulouzis

added interfaces import

parent f5f5c03c
......@@ -4,7 +4,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
......
......@@ -3,6 +3,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
topology_template:
node_templates:
compute:
......
......@@ -4,6 +4,7 @@ imports:
- {nodes: 'https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml'}
- {capabilities: 'https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml'}
- {policies: 'https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml'}
- {interfaces: 'https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml'}
topology_template:
node_templates:
concepcion_topology:
......
......@@ -4,6 +4,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
......
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.commons.utils;
import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate;
/**
*
* @author S. Koulouzis
*/
class NodeTemplateFactory {
static NodeTemplate create(Map.Entry node) {
NodeTemplate nodeTemplate = new NodeTemplate();
Map<String, Object> nodeMap = (Map<String, Object>) node.getValue();
nodeTemplate.setArtifacts((Map<String, Object>) nodeMap.get("artifacts"));
return null;
}
}
......@@ -31,7 +31,7 @@ import nl.uva.sne.drip.model.ToscaTemplate;
*/
public class TOSCAUtils {
public static List<Map<String, NodeTemplate>> getNodes(ToscaTemplate toscaTemplate, String filterType, String filterValue) {
private static List<Map<String, NodeTemplate>> getNodes(ToscaTemplate toscaTemplate, String filterType, String filterValue) {
boolean byType = false;
boolean byName = false;
switch (filterType) {
......
package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
......@@ -7,14 +9,19 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/**
* Credentials
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-25T14:09:25.182Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Credentials {
@Id
@JsonIgnore
private String id;
@JsonProperty("protocol")
private String protocol = null;
......@@ -38,7 +45,14 @@ public class Credentials {
this.protocol = protocol;
return this;
}
@JsonIgnore
public String getId() {
return id;
}
public void setID(String id) {
this.id = id;
}
/**
* Get protocol
* @return protocol
......
......@@ -179,7 +179,7 @@ public class NodeTemplate {
public NodeTemplate putInterfacesItem(String key, Object interfacesItem) {
if (this.interfaces == null) {
this.interfaces = new HashMap<String, Object>();
this.interfaces = new HashMap<>();
}
this.interfaces.put(key, interfacesItem);
return this;
......
package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
......@@ -9,14 +11,19 @@ import java.util.List;
import java.util.Map;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/**
* ToscaTemplate
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-25T14:09:25.182Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ToscaTemplate {
@Id
@JsonIgnore
private String id;
@JsonProperty("tosca_definitions_version")
private String toscaDefinitionsVersion = null;
......@@ -87,7 +94,14 @@ public class ToscaTemplate {
this.toscaDefinitionsVersion = toscaDefinitionsVersion;
return this;
}
@JsonIgnore
public String getId() {
return id;
}
public void setID(String id) {
this.id = id;
}
/**
* Get toscaDefinitionsVersion
* @return toscaDefinitionsVersion
......
......@@ -13,6 +13,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.TOSCAUtils;
import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -39,16 +40,25 @@ public class ProvisionerService {
String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
List<Map.Entry> vmTopologies = getVmTopologies(toscaTemplate);
for(Map.Entry topology: vmTopologies){
topology.
}
toscaTemplate = addProvisionInterface(toscaTemplate);
return null;
}
public List<Map.Entry> getVmTopologies(ToscaTemplate toscaTemplate) {
private List<Map<String, NodeTemplate>> getVmTopologies(ToscaTemplate toscaTemplate) {
return TOSCAUtils.getNodesByType(toscaTemplate, "tosca.nodes.ARTICONF.VM.topology");
}
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());
Map<String, Object> interfaces = vmTopology.getInterfaces();
}
return toscaTemplate;
}
}
......@@ -61,10 +61,14 @@ 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";
@Autowired
CredentialService credentialService;
private String credentialID;
@Autowired
ProvisionerService provisionService;
@Autowired
private WebApplicationContext wac;
......@@ -324,4 +328,16 @@ public class ServiceTests {
int size = credentialService.getAllIds().size();
assertEquals(0, size);
}
@Test
public void testProvisionerServiceProvision() {
FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
MultipartFile file = new MockMultipartFile("file", in);
toscaTemplateID = toscaTemplateService.saveFile(file);
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