Commit 3310ed45 authored by Spiros Koulouzis's avatar Spiros Koulouzis

get available credentials

parent 959f4a83
......@@ -115,7 +115,7 @@ node_types:
attributes:
credential:
type: tosca.datatypes.Credential
required: false
required: false
interfaces:
Standard:
create: dumy.yaml
......
......@@ -31,6 +31,9 @@ import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
import org.apache.commons.io.FileUtils;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import nl.uva.sne.drip.sure.tosca.client.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
/**
*
......@@ -38,15 +41,21 @@ import nl.uva.sne.drip.sure.tosca.client.Configuration;
*/
public class ToscaHelper {
private final DefaultApi api;
private DefaultApi api;
private final ObjectMapper objectMapper;
private ObjectMapper objectMapper;
public static final String VM_CAPABILITY = "tosca.capabilities.ARTICONF.VM";
private static final String VM_TYPE = "tosca.nodes.ARTICONF.VM.Compute";
private static final String VM_NUM_OF_CORES = "num_cores";
private static final String MEM_SIZE = "mem_size";
private static final String VM_OS = "os";
private static final String VM_TOPOLOGY = "tosca.nodes.ARTICONF.VM.topology";
private Integer id;
@Autowired
public ToscaHelper(String sureToscaBasePath) {
init(sureToscaBasePath);
}
/**
* @return the id
......@@ -55,23 +64,23 @@ public class ToscaHelper {
return id;
}
private final Integer id;
public ToscaHelper(ToscaTemplate toscaTemplate, String sureToscaBasePath) throws JsonProcessingException, IOException, ApiException {
// public ToscaHelper(ToscaTemplate toscaTemplate, String sureToscaBasePath) throws JsonProcessingException, IOException, ApiException {
// init(sureToscaBasePath);
// uploadToscaTemplate(toscaTemplate);
// }
private void init(String sureToscaBasePath) {
Configuration.getDefaultApiClient().setBasePath(sureToscaBasePath);
api = new DefaultApi(Configuration.getDefaultApiClient());
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
id = uploadToscaTemplate(toscaTemplate);
}
private Integer uploadToscaTemplate(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException {
public void uploadToscaTemplate(ToscaTemplate toscaTemplate) throws JsonProcessingException, IOException, ApiException {
String ymlStr = objectMapper.writeValueAsString(toscaTemplate);
File toscaTemplateFile = File.createTempFile("temp-toscaTemplate", ".yml");
FileUtils.writeByteArrayToFile(toscaTemplateFile, ymlStr.getBytes());
String resp = api.uploadToscaTemplate(toscaTemplateFile);
return Integer.valueOf(resp);
id = Integer.valueOf(resp);
}
public List<Map<String, Object>> getProvisionInterfaceDefinitions(List<String> toscaInterfaceTypes) throws ApiException {
......@@ -90,7 +99,7 @@ public class ToscaHelper {
return vmTopologyTemplates;
}
public List<NodeTemplate> getTopologyTemplateVMs(NodeTemplate nodeTemplate) throws ApiException {
public List<NodeTemplate> getTemplateVMsForVMTopology(NodeTemplate nodeTemplate) throws ApiException {
List<Map<String, Object>> requirements = nodeTemplate.getRequirements();
List<NodeTemplate> vms = new ArrayList<>();
for (Map<String, Object> req : requirements) {
......
......@@ -18,7 +18,7 @@ import javax.validation.constraints.*;
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
public class VMMetaInfo {
public class VMMetaInfo {
/**
* @return the vmType
......@@ -33,228 +33,233 @@ public class VMMetaInfo {
public void setVmType(String vmType) {
this.vmType = vmType;
}
@JsonProperty("OS")
private String OS = null;
@JsonProperty("VMType")
private String vmType = null;
@JsonProperty("OS")
private String OS = null;
@JsonProperty("CPU")
private String CPU = null;
@JsonProperty("VMType")
private String vmType = null;
@JsonProperty("MEM")
private String MEM = null;
@JsonProperty("CPU")
private String CPU = null;
@JsonProperty("Price")
private String price = null;
@JsonProperty("MEM")
private String MEM = null;
@JsonProperty("DefaultSSHAccount")
private String defaultSSHAccount = null;
@JsonProperty("Price")
private String price = null;
@JsonProperty("availability")
private String availability = null;
@JsonProperty("DefaultSSHAccount")
private String defaultSSHAccount = null;
@JsonProperty("extraInfo")
@Valid
private Map<String, Object> extraInfo = null;
@JsonProperty("availability")
private String availability = null;
public VMMetaInfo OS(String OS) {
this.OS = OS;
return this;
}
/**
* Get OS
* @return OS
**/
@ApiModelProperty(value = "")
public String getOS() {
return OS;
}
public void setOS(String OS) {
this.OS = OS;
}
public VMMetaInfo CPU(String CPU) {
this.CPU = CPU;
return this;
}
/**
* Get CPU
* @return CPU
**/
@ApiModelProperty(value = "")
@JsonProperty("extraInfo")
@Valid
private Map<String, Object> extraInfo = null;
public VMMetaInfo OS(String OS) {
this.OS = OS;
return this;
}
public String getCPU() {
return CPU;
}
/**
* Get OS
*
* @return OS
*
*/
@ApiModelProperty(value = "")
public void setCPU(String CPU) {
this.CPU = CPU;
}
public String getOS() {
return OS;
}
public VMMetaInfo MEM(String MEM) {
this.MEM = MEM;
return this;
}
public void setOS(String OS) {
this.OS = OS;
}
/**
* Get MEM
* @return MEM
**/
@ApiModelProperty(value = "")
public VMMetaInfo CPU(String CPU) {
this.CPU = CPU;
return this;
}
/**
* Get CPU
*
* @return CPU
*
*/
@ApiModelProperty(value = "")
public String getMEM() {
return MEM;
}
public String getCPU() {
return CPU;
}
public void setMEM(String MEM) {
this.MEM = MEM;
}
public void setCPU(String CPU) {
this.CPU = CPU;
}
public VMMetaInfo price(String price) {
this.price = price;
return this;
}
public VMMetaInfo MEM(String MEM) {
this.MEM = MEM;
return this;
}
/**
* Get price
* @return price
**/
@ApiModelProperty(value = "")
/**
* Get MEM
*
* @return MEM
*
*/
@ApiModelProperty(value = "")
public String getMEM() {
return MEM;
}
public String getPrice() {
return price;
}
public void setMEM(String MEM) {
this.MEM = MEM;
}
public void setPrice(String price) {
this.price = price;
}
public VMMetaInfo price(String price) {
this.price = price;
return this;
}
public VMMetaInfo defaultSSHAccount(String defaultSSHAccount) {
this.defaultSSHAccount = defaultSSHAccount;
return this;
}
/**
* Get price
*
* @return price
*
*/
@ApiModelProperty(value = "")
/**
* Get defaultSSHAccount
* @return defaultSSHAccount
**/
@ApiModelProperty(value = "")
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getDefaultSSHAccount() {
return defaultSSHAccount;
}
public VMMetaInfo defaultSSHAccount(String defaultSSHAccount) {
this.defaultSSHAccount = defaultSSHAccount;
return this;
}
public void setDefaultSSHAccount(String defaultSSHAccount) {
this.defaultSSHAccount = defaultSSHAccount;
}
/**
* Get defaultSSHAccount
*
* @return defaultSSHAccount
*
*/
@ApiModelProperty(value = "")
public VMMetaInfo availability(String availability) {
this.availability = availability;
return this;
}
public String getDefaultSSHAccount() {
return defaultSSHAccount;
}
/**
* Get availability
* @return availability
**/
@ApiModelProperty(value = "")
public void setDefaultSSHAccount(String defaultSSHAccount) {
this.defaultSSHAccount = defaultSSHAccount;
}
public VMMetaInfo availability(String availability) {
this.availability = availability;
return this;
}
public String getAvailability() {
return availability;
}
/**
* Get availability
*
* @return availability
*
*/
@ApiModelProperty(value = "")
public void setAvailability(String availability) {
this.availability = availability;
}
public String getAvailability() {
return availability;
}
public VMMetaInfo extraInfo(Map<String, Object> extraInfo) {
this.extraInfo = extraInfo;
return this;
}
public void setAvailability(String availability) {
this.availability = availability;
}
public VMMetaInfo putExtraInfoItem(String key, Object extraInfoItem) {
if (this.extraInfo == null) {
this.extraInfo = new HashMap<String, Object>();
public VMMetaInfo extraInfo(Map<String, Object> extraInfo) {
this.extraInfo = extraInfo;
return this;
}
this.extraInfo.put(key, extraInfoItem);
return this;
}
/**
* Get extraInfo
* @return extraInfo
**/
@ApiModelProperty(value = "")
public VMMetaInfo putExtraInfoItem(String key, Object extraInfoItem) {
if (this.extraInfo == null) {
this.extraInfo = new HashMap<String, Object>();
}
this.extraInfo.put(key, extraInfoItem);
return this;
}
/**
* Get extraInfo
*
* @return extraInfo
*
*/
@ApiModelProperty(value = "")
public Map<String, Object> getExtraInfo() {
return extraInfo;
}
public Map<String, Object> getExtraInfo() {
return extraInfo;
}
public void setExtraInfo(Map<String, Object> extraInfo) {
this.extraInfo = extraInfo;
}
public void setExtraInfo(Map<String, Object> extraInfo) {
this.extraInfo = extraInfo;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
VMMetaInfo vmMetaInfo = (VMMetaInfo) o;
return Objects.equals(this.OS, vmMetaInfo.OS)
&& Objects.equals(this.CPU, vmMetaInfo.CPU)
&& Objects.equals(this.MEM, vmMetaInfo.MEM)
&& Objects.equals(this.price, vmMetaInfo.price)
&& Objects.equals(this.defaultSSHAccount, vmMetaInfo.defaultSSHAccount)
&& Objects.equals(this.availability, vmMetaInfo.availability)
&& Objects.equals(this.extraInfo, vmMetaInfo.extraInfo);
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
@Override
public int hashCode() {
return Objects.hash(OS, CPU, MEM, price, defaultSSHAccount, availability, extraInfo);
}
if (o == null || getClass() != o.getClass()) {
return false;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class VMMetaInfo {\n");
sb.append(" OS: ").append(toIndentedString(OS)).append("\n");
sb.append(" CPU: ").append(toIndentedString(CPU)).append("\n");
sb.append(" MEM: ").append(toIndentedString(MEM)).append("\n");
sb.append(" price: ").append(toIndentedString(price)).append("\n");
sb.append(" defaultSSHAccount: ").append(toIndentedString(defaultSSHAccount)).append("\n");
sb.append(" availability: ").append(toIndentedString(availability)).append("\n");
sb.append(" extraInfo: ").append(toIndentedString(extraInfo)).append("\n");
sb.append("}");
return sb.toString();
}
VMMetaInfo vmMetaInfo = (VMMetaInfo) o;
return Objects.equals(this.OS, vmMetaInfo.OS) &&
Objects.equals(this.CPU, vmMetaInfo.CPU) &&
Objects.equals(this.MEM, vmMetaInfo.MEM) &&
Objects.equals(this.price, vmMetaInfo.price) &&
Objects.equals(this.defaultSSHAccount, vmMetaInfo.defaultSSHAccount) &&
Objects.equals(this.availability, vmMetaInfo.availability) &&
Objects.equals(this.extraInfo, vmMetaInfo.extraInfo);
}
@Override
public int hashCode() {
return Objects.hash(OS, CPU, MEM, price, defaultSSHAccount, availability, extraInfo);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class VMMetaInfo {\n");
sb.append(" OS: ").append(toIndentedString(OS)).append("\n");
sb.append(" CPU: ").append(toIndentedString(CPU)).append("\n");
sb.append(" MEM: ").append(toIndentedString(MEM)).append("\n");
sb.append(" price: ").append(toIndentedString(price)).append("\n");
sb.append(" defaultSSHAccount: ").append(toIndentedString(defaultSSHAccount)).append("\n");
sb.append(" availability: ").append(toIndentedString(availability)).append("\n");
sb.append(" extraInfo: ").append(toIndentedString(extraInfo)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
return o.toString().replace("\n", "\n ");
}
}
......@@ -11,12 +11,12 @@ import javax.validation.Valid;
import org.springframework.data.annotation.Id;
/**
* Credentials
* Credential
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T15:39:04.296Z")
public class Credentials {
public class Credential {
/**
* @return the id
*/
......@@ -55,7 +55,7 @@ public class Credentials {
@JsonProperty("cloud_provider_name")
private String cloudProviderName = null;
public Credentials protocol(String protocol) {
public Credential protocol(String protocol) {
this.protocol = protocol;
return this;
}
......@@ -76,7 +76,7 @@ public class Credentials {
this.protocol = protocol;
}
public Credentials tokenType(String tokenType) {
public Credential tokenType(String tokenType) {
this.tokenType = tokenType;
return this;
}
......@@ -97,7 +97,7 @@ public class Credentials {
this.tokenType = tokenType;
}
public Credentials token(String token) {
public Credential token(String token) {
this.token = token;
return this;
}
......@@ -118,12 +118,12 @@ public class Credentials {
this.token = token;
}
public Credentials keys(Map<String, String> keys) {
public Credential keys(Map<String, String> keys) {
this.keys = keys;
return this;
}
public Credentials putKeysItem(String key, String keysItem) {
public Credential putKeysItem(String key, String keysItem) {
if (this.keys == null) {
this.keys = new HashMap<String, String>();
}
......@@ -147,7 +147,7 @@ public class Credentials {
this.keys = keys;
}
public Credentials user(String user) {
public Credential user(String user) {
this.user = user;
return this;
}
......@@ -168,7 +168,7 @@ public class Credentials {
this.user = user;
}
public Credentials cloudProviderName(String cloudProviderName) {
public Credential cloudProviderName(String cloudProviderName) {
this.cloudProviderName = cloudProviderName;
return this;
}
......@@ -197,7 +197,7 @@ public class Credentials {
if (o == null || getClass() != o.getClass()) {
return false;
}
Credentials credentials = (Credentials) o;
Credential credentials = (Credential) o;
return Objects.equals(this.protocol, credentials.protocol)
&& Objects.equals(this.tokenType, credentials.tokenType)
&& Objects.equals(this.token, credentials.token)
......
......@@ -73,7 +73,8 @@ public class ToscaHelperTest {
String serviceBasePath = prop.getProperty("sure-tosca.base.path");
serviceUp = isServiceUp(serviceBasePath);
if (serviceUp) {
instance = new ToscaHelper(toscaTemplate, serviceBasePath);
instance = new ToscaHelper(serviceBasePath);
instance.uploadToscaTemplate(toscaTemplate);
}
}
......
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import javax.validation.Valid;
import java.util.List;
import nl.uva.sne.drip.model.tosca.Credentials;
import nl.uva.sne.drip.model.tosca.Credential;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-06T13:31:49.386Z")
......@@ -39,7 +39,7 @@ public interface CredentialApi {
produces = {"application/json"},
consumes = {"application/json"},
method = RequestMethod.POST)
ResponseEntity<String> createCredentials(@ApiParam(value = "Created user object", required = true) @Valid @RequestBody Credentials body);
ResponseEntity<String> createCredentials(@ApiParam(value = "Created user object", required = true) @Valid @RequestBody Credential body);
@ApiOperation(value = "Get all credential IDs", nickname = "getCredentialIDs", notes = "Returns all IDss ", response = String.class, responseContainer = "List", authorizations = {
@Authorization(value = "auth", scopes = {
......
package nl.uva.sne.drip.api;
import nl.uva.sne.drip.model.tosca.Credentials;
import nl.uva.sne.drip.model.tosca.Credential;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.slf4j.Logger;
......@@ -38,7 +38,7 @@ public class CredentialApiController implements CredentialApi {
@Override
public ResponseEntity<String> createCredentials(@ApiParam(
value = "Created user object", required = true)
@Valid @RequestBody Credentials body) {
@Valid @RequestBody Credential body) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/json")) {
String id = credentialService.save(body);
......
......@@ -2,6 +2,7 @@ package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import java.util.logging.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
......@@ -10,6 +11,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest;
import nl.uva.sne.drip.service.DRIPService;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -39,9 +41,15 @@ public class PlannerApiController implements PlannerApi {
@PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) {
dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.execute(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
try {
dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.execute(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} catch (ApiException ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (Exception ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
......
......@@ -2,6 +2,7 @@ package nl.uva.sne.drip.api;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import java.util.logging.Level;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
......@@ -10,6 +11,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest;
import nl.uva.sne.drip.service.DRIPService;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -42,9 +44,15 @@ public class ProvisionerApiController implements ProvisionerApi {
@PathVariable("id") String id) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("text/plain")) {
dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.execute(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
try {
dripService.setRequestQeueName(queueName);
String planedYemplateId = dripService.execute(id);
return new ResponseEntity<>(planedYemplateId, HttpStatus.OK);
} catch (ApiException ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} catch (Exception ex) {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nl.uva.sne.drip.configuration;
import nl.uva.sne.drip.commons.utils.ToscaHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
/**
*
* @author S. Koulouzis
*/
@Configuration
@PropertySources({
@PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true)
})
@ComponentScan(basePackages = {"nl.uva.sne.drip", "nl.uva.sne.drip.api", "nl.uva.sne.drip.configuration", "nl.uva.sne.drip.dao", "nl.uva.sne.drip.model", "nl.uva.sne.drip.service", "nl.uva.sne.drip.commons.utils"})
public class ToscaHelperConfig {
@Value("${sure-tosca.base.path}")
private String sureToscaBasePath;
@Bean
public ToscaHelper toscaHelper() {
return new ToscaHelper(sureToscaBasePath);
}
}
......@@ -5,7 +5,8 @@
*/
package nl.uva.sne.drip.dao;
import nl.uva.sne.drip.model.tosca.Credentials;
import java.util.List;
import nl.uva.sne.drip.model.tosca.Credential;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
......@@ -14,6 +15,7 @@ import org.springframework.stereotype.Repository;
* @author S. Koulouzis
*/
@Repository
public interface CredentialDAO extends MongoRepository<Credentials, String> {
public interface CredentialDAO extends MongoRepository<Credential, String> {
List<Credential> findBycloudProviderName(String cloudProviderName);
}
......@@ -11,7 +11,7 @@ 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.tosca.Credentials;
import nl.uva.sne.drip.model.tosca.Credential;
/**
*
......@@ -23,13 +23,13 @@ public class CredentialService {
@Autowired
private CredentialDAO dao;
public String save(Credentials document) {
public String save(Credential document) {
dao.save(document);
return document.getId();
}
public Credentials findByID(String id) throws JsonProcessingException {
Credentials credentials = dao.findById(id).get();
public Credential findByID(String id) throws JsonProcessingException {
Credential credentials = dao.findById(id).get();
return credentials;
}
......@@ -39,8 +39,8 @@ public class CredentialService {
public List<String> getAllIds() {
List<String> allIds = new ArrayList<>();
List<Credentials> all = dao.findAll();
for (Credentials tt : all) {
List<Credential> all = dao.findAll();
for (Credential tt : all) {
allIds.add(tt.getId());
}
return allIds;
......@@ -50,4 +50,8 @@ public class CredentialService {
dao.deleteAll();
}
List<Credential> findByProvider(String provider) {
return dao.findBycloudProviderName(provider);
}
}
......@@ -5,13 +5,19 @@
*/
package nl.uva.sne.drip.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
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.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.rpc.DRIPCaller;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -28,14 +34,27 @@ public class DRIPService {
@Autowired
DRIPCaller caller;
@Autowired
CredentialService credentialService;
private String requestQeueName;
public String execute(String id) {
@Autowired
private ToscaHelper helper;
public String execute(String id) throws JsonProcessingException, ApiException, Exception {
try {
caller.init();
String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology);
List<Credential> credentials = credentialService.findByProvider(provider);
}
Message message = new Message();
message.setOwner("user");
message.setCreationDate(System.currentTimeMillis());
......
......@@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.Swagger2SpringBoot;
import nl.uva.sne.drip.configuration.MongoConfig;
import nl.uva.sne.drip.model.tosca.Credentials;
import nl.uva.sne.drip.model.tosca.Credential;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
......@@ -266,7 +266,7 @@ public class ServiceTests {
public String saveCredential() {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveCredential");
Credentials document = new Credentials();
Credential document = new Credential();
document.setCloudProviderName("exogeni");
Map<String, String> keys = new HashMap<>();
keys.put("keystore", "/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N");
......@@ -286,7 +286,7 @@ public class ServiceTests {
public void testCredentialServiceFindByID() throws Exception {
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
String id = saveCredential();
Credentials result = credentialService.findByID(id);
Credential result = credentialService.findByID(id);
assertNotNull(result);
}
......@@ -299,7 +299,7 @@ public class ServiceTests {
String id = saveCredential();
credentialService.deleteByID(id);
try {
Credentials res = credentialService.findByID(id);
Credential res = credentialService.findByID(id);
} catch (Exception ex) {
if (!(ex instanceof NoSuchElementException)) {
fail(ex.getMessage());
......
#http://geni-images.renci.org/images/standard/ubuntu-comet/
#https://wiki.exogeni.net/doku.php?id=public:experimenters:resource_types:start
GlobalEntry: "https://geni.renci.org:11443/orca/xmlrpc"
DCMetaInfo:
- domain: "UvA (Amsterdam, The Netherlands) XO Rack"
......@@ -832,4 +834,24 @@ DCMetaInfo:
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75
\ No newline at end of file
DiskSize: 75
- OS: "Ubuntu 16.04"
CPU: 4
MEM: 12
VMType: "XOXLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75
- OS: "Ubuntu 16.04"
CPU: 2
MEM: 6
VMType: "XOLarge"
Price: null
DefaultSSHAccount: "root"
extraInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 50
......@@ -51,7 +51,8 @@ class CloudStormService {
String cloudStormDBPath = properties.getProperty("cloud.storm.db.path");
cloudStormDAO = new CloudStormDAO(cloudStormDBPath);
String sureToscaBasePath = properties.getProperty("sure-tosca.base.path");
this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
this.helper = new ToscaHelper(sureToscaBasePath);
this.helper.uploadToscaTemplate(toscaTemplate);
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
......@@ -75,15 +76,13 @@ class CloudStormService {
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
writeCloudcredentialsTopologyFiles(toscaTemplate, credentialsTempInputDirPath);
writeCloudStormCredentialsFiles(toscaTemplate, credentialsTempInputDirPath);
String infrasCodeTempInputDirPath = File.separator + "infrasCodes";
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
return toscaTemplate;
}
......@@ -136,7 +135,7 @@ class CloudStormService {
List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplate> vmTemplates = helper.getTopologyTemplateVMs(nodeTemplate);
List<NodeTemplate> vmTemplates = helper.getTemplateVMsForVMTopology(nodeTemplate);
int j = 0;
for (NodeTemplate vm : vmTemplates) {
CloudsStormVM cloudsStormVM = new CloudsStormVM();
......@@ -173,8 +172,8 @@ class CloudStormService {
return null;
}
private void writeCloudcredentialsTopologyFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) {
}
}
Credentials:
Credential:
type: "object"
properties:
protocol:
......
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