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

added Provisioner type

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