Commit 95ab9ebe authored by Spiros Koulouzis's avatar Spiros Koulouzis

added Provisioner type

parent b8838009
......@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.Provisioner;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
......@@ -84,9 +85,8 @@ public class ToscaHelper {
id = Integer.valueOf(resp);
}
public List<Map<String, Object>> getSupportedProvisionInterfaceDefinitions() throws ApiException {
public List<Map<String, Object>> getProvisionInterfaceDefinitions(List<String> toscaInterfaceTypes) throws ApiException {
List<Map<String, Object>> interfaceDefinitions = new ArrayList<>();
List<String> toscaInterfaceTypes = getSuportedProvisionInterfaceTypes();
for (String type : toscaInterfaceTypes) {
String derivedFrom = null;
List<Map<String, Object>> interfaces = api.getTypes(String.valueOf(id), "interface_types", null, type, null, null, null, null, null, derivedFrom);
......@@ -223,10 +223,12 @@ public class ToscaHelper {
return toscaTemplate;
}
private List<String> getSuportedProvisionInterfaceTypes() {
List<String> suportedProvisionInterfaceTypes = new ArrayList<>();
suportedProvisionInterfaceTypes.add("tosca.interfaces.ARTICONF.CloudsStorm");
return suportedProvisionInterfaceTypes;
public NodeTemplateMap setProvisionerInterfaceInVMTopology(NodeTemplateMap vmTopologyMap, Provisioner provisioner) throws ApiException {
List<String> toscaInterfaceTypes = new ArrayList<>();
toscaInterfaceTypes.add(provisioner.getToscaInterfaceType());
List<Map<String, Object>> definitions = getProvisionInterfaceDefinitions(toscaInterfaceTypes);
return null;
}
}
package nl.uva.sne.drip.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
/**
* Provisioner
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-26T14:52:47.859Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-26T15:03:16.208Z")
public class Provisioner {
@JsonProperty("name")
private String name = null;
@JsonProperty("version")
private String version = null;
@JsonProperty("description")
private String description = null;
@JsonProperty("tosca_interface_type")
private String toscaInterfaceType = null;
public Provisioner name(String name) {
this.name = name;
return this;
}
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Provisioner version(String version) {
this.version = version;
return this;
}
/**
* Get version
*
* @return version
*
*/
@ApiModelProperty(value = "")
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Provisioner description(String description) {
this.description = description;
return this;
}
/**
* Get description
*
* @return description
*
*/
@ApiModelProperty(value = "")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Provisioner toscaInterfaceType(String toscaInterfaceType) {
this.toscaInterfaceType = toscaInterfaceType;
return this;
}
/**
* Get toscaInterfaceType
*
* @return toscaInterfaceType
*
*/
@ApiModelProperty(value = "")
public String getToscaInterfaceType() {
return toscaInterfaceType;
}
public void setToscaInterfaceType(String toscaInterfaceType) {
this.toscaInterfaceType = toscaInterfaceType;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
......@@ -19,12 +117,16 @@ public class Provisioner {
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
Provisioner provisioner = (Provisioner) o;
return Objects.equals(this.name, provisioner.name)
&& Objects.equals(this.version, provisioner.version)
&& Objects.equals(this.description, provisioner.description)
&& Objects.equals(this.toscaInterfaceType, provisioner.toscaInterfaceType);
}
@Override
public int hashCode() {
return Objects.hash();
return Objects.hash(name, version, description, toscaInterfaceType);
}
@Override
......@@ -32,6 +134,10 @@ public class Provisioner {
StringBuilder sb = new StringBuilder();
sb.append("class Provisioner {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" version: ").append(toIndentedString(version)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" toscaInterfaceType: ").append(toIndentedString(toscaInterfaceType)).append("\n");
sb.append("}");
return sb.toString();
}
......
......@@ -17,6 +17,7 @@ import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.Message;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.Provisioner;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.rpc.DRIPCaller;
......@@ -45,6 +46,9 @@ public class DRIPService {
@Autowired
private ToscaHelper helper;
@Autowired
ProvisionerService provisionerService;
private String execute(ToscaTemplate toscaTemplate) throws JsonProcessingException, ApiException, Exception {
try {
......@@ -120,12 +124,12 @@ public class DRIPService {
return execute(toscaTemplate);
}
private ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception {
private ToscaTemplate addProvisionInterface(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception {
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
List<Provisioner> provisioners = null;
for (NodeTemplateMap vmTopologyMap : vmTopologies) {
provisioners = provisionerService.findByProvider(provider.toLowerCase());
provisioners = provisionerService.findAll();
if (provisioners != null && provisioners.size() > 0) {
Provisioner provisioner = getBestProvisioners(vmTopologyMap.getNodeTemplate(), provisioners);
vmTopologyMap = helper.setProvisionerInterfaceInVMTopology(vmTopologyMap, provisioner);
......@@ -136,4 +140,8 @@ public class DRIPService {
}
private Provisioner getBestProvisioners(NodeTemplate nodeTemplate, List<Provisioner> provisioners) {
return provisioners.get(0);
}
}
......@@ -5,14 +5,10 @@
*/
package nl.uva.sne.drip.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.dao.CredentialDAO;
import nl.uva.sne.drip.model.Provisioner;
import nl.uva.sne.drip.model.tosca.Credential;
/**
*
......@@ -21,13 +17,12 @@ import nl.uva.sne.drip.model.tosca.Credential;
@Service
public class ProvisionerService {
public List<Provisioner> findAll() {
List<Provisioner> all = new ArrayList<>();
Provisioner provisioner = new Provisioner();
provisioner.
provisioner.setName("CloudsStorm");
provisioner.setDescription("Interface for VM topology management with CloudsStorm. More at https://cloudsstorm.github.io/");
provisioner.setToscaInterfaceType("tosca.interfaces.ARTICONF.CloudsStorm");
all.add(provisioner);
return all;
}
......
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