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

added interfaces import

parent f5f5c03c
...@@ -4,7 +4,7 @@ imports: ...@@ -4,7 +4,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml - 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 - 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 - 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: repositories:
docker_hub: https://hub.docker.com/ docker_hub: https://hub.docker.com/
......
...@@ -3,6 +3,7 @@ imports: ...@@ -3,6 +3,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml - 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 - 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 - 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: topology_template:
node_templates: node_templates:
compute: compute:
......
...@@ -4,6 +4,7 @@ imports: ...@@ -4,6 +4,7 @@ imports:
- {nodes: 'https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml'} - {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'} - {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'} - {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: topology_template:
node_templates: node_templates:
concepcion_topology: concepcion_topology:
......
...@@ -4,6 +4,7 @@ imports: ...@@ -4,6 +4,7 @@ imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml - 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 - 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 - 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: repositories:
docker_hub: https://hub.docker.com/ 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; ...@@ -31,7 +31,7 @@ import nl.uva.sne.drip.model.ToscaTemplate;
*/ */
public class TOSCAUtils { 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 byType = false;
boolean byName = false; boolean byName = false;
switch (filterType) { switch (filterType) {
......
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -7,14 +9,19 @@ import java.util.HashMap; ...@@ -7,14 +9,19 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/** /**
* Credentials * Credentials
*/ */
@Validated @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 { public class Credentials {
@Id
@JsonIgnore
private String id;
@JsonProperty("protocol") @JsonProperty("protocol")
private String protocol = null; private String protocol = null;
...@@ -38,7 +45,14 @@ public class Credentials { ...@@ -38,7 +45,14 @@ public class Credentials {
this.protocol = protocol; this.protocol = protocol;
return this; return this;
} }
@JsonIgnore
public String getId() {
return id;
}
public void setID(String id) {
this.id = id;
}
/** /**
* Get protocol * Get protocol
* @return protocol * @return protocol
......
...@@ -179,7 +179,7 @@ public class NodeTemplate { ...@@ -179,7 +179,7 @@ public class NodeTemplate {
public NodeTemplate putInterfacesItem(String key, Object interfacesItem) { public NodeTemplate putInterfacesItem(String key, Object interfacesItem) {
if (this.interfaces == null) { if (this.interfaces == null) {
this.interfaces = new HashMap<String, Object>(); this.interfaces = new HashMap<>();
} }
this.interfaces.put(key, interfacesItem); this.interfaces.put(key, interfacesItem);
return this; return this;
......
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -9,14 +11,19 @@ import java.util.List; ...@@ -9,14 +11,19 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/** /**
* ToscaTemplate * ToscaTemplate
*/ */
@Validated @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 { public class ToscaTemplate {
@Id
@JsonIgnore
private String id;
@JsonProperty("tosca_definitions_version") @JsonProperty("tosca_definitions_version")
private String toscaDefinitionsVersion = null; private String toscaDefinitionsVersion = null;
...@@ -87,7 +94,14 @@ public class ToscaTemplate { ...@@ -87,7 +94,14 @@ public class ToscaTemplate {
this.toscaDefinitionsVersion = toscaDefinitionsVersion; this.toscaDefinitionsVersion = toscaDefinitionsVersion;
return this; return this;
} }
@JsonIgnore
public String getId() {
return id;
}
public void setID(String id) {
this.id = id;
}
/** /**
* Get toscaDefinitionsVersion * Get toscaDefinitionsVersion
* @return toscaDefinitionsVersion * @return toscaDefinitionsVersion
......
...@@ -13,6 +13,7 @@ import java.util.logging.Level; ...@@ -13,6 +13,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.TOSCAUtils; import nl.uva.sne.drip.commons.utils.TOSCAUtils;
import nl.uva.sne.drip.model.Message; import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
...@@ -39,16 +40,25 @@ public class ProvisionerService { ...@@ -39,16 +40,25 @@ public class ProvisionerService {
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
List<Map.Entry> vmTopologies = getVmTopologies(toscaTemplate);
for(Map.Entry topology: vmTopologies){ toscaTemplate = addProvisionInterface(toscaTemplate);
topology.
}
return null; 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"); 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,11 +61,15 @@ public class ServiceTests { ...@@ -61,11 +61,15 @@ 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";
@Autowired @Autowired
CredentialService credentialService; CredentialService credentialService;
private String credentialID; private String credentialID;
@Autowired
ProvisionerService provisionService;
@Autowired @Autowired
private WebApplicationContext wac; private WebApplicationContext wac;
private MockMvc mockMvc; private MockMvc mockMvc;
...@@ -324,4 +328,16 @@ public class ServiceTests { ...@@ -324,4 +328,16 @@ public class ServiceTests {
int size = credentialService.getAllIds().size(); int size = credentialService.getAllIds().size();
assertEquals(0, 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