Commit b8dc2f77 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Added alias from vmtype

parent 43d96849
......@@ -17,44 +17,23 @@ description: >
topology_template:
node_templates:
wordpress:
type: tosca.nodes.ARTICONF.Container.Application.Docker
requirements:
- service:
node: mysql
relationship:
type: tosca.relationships.ConnectsTo
type: tosca.relationships.DependsOn
artifacts:
image:
file: wordpress:latest
type: tosca.artifacts.Deployment.Image.Container.Docker
repository: docker_hub
properties:
ports:
- "8000:80"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
mysql:
mongo:
type: tosca.nodes.ARTICONF.Container.Application.Docker
properties:
ports:
- "3306:3306"
- "27017:27017"
volumes:
- db_data:/var/lib/mysql
- db_data:/var/lib/mongo
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MONGO_INITDB_ROOT_USERNAME: rootUser
MONGO_INITDB_ROOT_PASSWORD: rootPassword
MONGO_INITDB_DATABASE: databaseName
MONGO_USERNAME: databaseUser
MONGO_PASSWORD:password
artifacts:
image:
type: tosca.artifacts.Deployment.Image.Container.Docker
file: mysql:5.7
file: lakshminp/mongo:4.2.1
repository: docker_hub
......@@ -77,13 +56,13 @@ topology_template:
policies:
- scalability:
type: tosca.policies.ARTICONF.Performance.CPU
targets: [ wordpress ]
targets: [ mongo ]
properties:
constraint_name: cpu_load
max_value: 90
- faultTolerance:
type: tosca.policies.ARTICONF.FaultTolerance
targets: [ mysql ]
targets: [ mongo ]
properties:
level: 1
......
......@@ -11,12 +11,12 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
/**
* DCMetaInfo
* CloudStormDCMetaInfo
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-01-12T18:26:54.530Z")
public class DCMetaInfo {
public class CloudStormDCMetaInfo {
@JsonProperty("domain")
private String domain = null;
......@@ -44,7 +44,7 @@ public class DCMetaInfo {
@Valid
private Map<String, Object> extraInfo = null;
public DCMetaInfo domain(String domain) {
public CloudStormDCMetaInfo domain(String domain) {
this.domain = domain;
return this;
}
......@@ -65,7 +65,7 @@ public class DCMetaInfo {
this.domain = domain;
}
public DCMetaInfo endpoint(String endpoint) {
public CloudStormDCMetaInfo endpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}
......@@ -86,7 +86,7 @@ public class DCMetaInfo {
this.endpoint = endpoint;
}
public DCMetaInfo country(String country) {
public CloudStormDCMetaInfo country(String country) {
this.country = country;
return this;
}
......@@ -107,7 +107,7 @@ public class DCMetaInfo {
this.country = country;
}
public DCMetaInfo longitude(String longitude) {
public CloudStormDCMetaInfo longitude(String longitude) {
this.longitude = longitude;
return this;
}
......@@ -128,7 +128,7 @@ public class DCMetaInfo {
this.longitude = longitude;
}
public DCMetaInfo latitude(String latitude) {
public CloudStormDCMetaInfo latitude(String latitude) {
this.latitude = latitude;
return this;
}
......@@ -149,7 +149,7 @@ public class DCMetaInfo {
this.latitude = latitude;
}
public DCMetaInfo availability(String availability) {
public CloudStormDCMetaInfo availability(String availability) {
this.availability = availability;
return this;
}
......@@ -170,12 +170,12 @@ public class DCMetaInfo {
this.availability = availability;
}
public DCMetaInfo vmMetaInfo(List<CloudsStormVM> vmMetaInfo) {
public CloudStormDCMetaInfo vmMetaInfo(List<CloudsStormVM> vmMetaInfo) {
this.vmMetaInfo = vmMetaInfo;
return this;
}
public DCMetaInfo addVmMetaInfoItem(CloudsStormVM vmMetaInfoItem) {
public CloudStormDCMetaInfo addVmMetaInfoItem(CloudsStormVM vmMetaInfoItem) {
if (this.vmMetaInfo == null) {
this.vmMetaInfo = new ArrayList<CloudsStormVM>();
}
......@@ -201,12 +201,12 @@ public class DCMetaInfo {
this.vmMetaInfo = vmMetaInfo;
}
public DCMetaInfo extraInfo(Map<String, Object> extraInfo) {
public CloudStormDCMetaInfo extraInfo(Map<String, Object> extraInfo) {
this.extraInfo = extraInfo;
return this;
}
public DCMetaInfo putExtraInfoItem(String key, Object extraInfoItem) {
public CloudStormDCMetaInfo putExtraInfoItem(String key, Object extraInfoItem) {
if (this.extraInfo == null) {
this.extraInfo = new HashMap<String, Object>();
}
......@@ -238,7 +238,7 @@ public class DCMetaInfo {
if (o == null || getClass() != o.getClass()) {
return false;
}
DCMetaInfo dcMetaInfo = (DCMetaInfo) o;
CloudStormDCMetaInfo dcMetaInfo = (CloudStormDCMetaInfo) o;
return Objects.equals(this.domain, dcMetaInfo.domain)
&& Objects.equals(this.endpoint, dcMetaInfo.endpoint)
&& Objects.equals(this.country, dcMetaInfo.country)
......
......@@ -134,6 +134,7 @@ public class CloudsStormVM {
@JsonProperty("nodeType")
private String nodeType = null;
@JsonProperty("VEngineClass")
private String VEngineClass = null;
......@@ -152,6 +153,7 @@ public class CloudsStormVM {
private Map<String, Object> extraInfo = null;
@JsonProperty("CPU")
@JsonAlias({"cpu"})
private String CPU = null;
@JsonProperty("MEM")
......
......@@ -21,7 +21,7 @@ public class DBInfo {
@JsonProperty("DCMetaInfo")
@Valid
private List<DCMetaInfo> dcMetaInfo = null;
private List<CloudStormDCMetaInfo> dcMetaInfo = null;
public DBInfo globalEntry(String globalEntry) {
this.globalEntry = globalEntry;
......@@ -44,14 +44,14 @@ public class DBInfo {
this.globalEntry = globalEntry;
}
public DBInfo dcMetaInfo(List<DCMetaInfo> dcMetaInfo) {
public DBInfo dcMetaInfo(List<CloudStormDCMetaInfo> dcMetaInfo) {
this.dcMetaInfo = dcMetaInfo;
return this;
}
public DBInfo addDcMetaInfoItem(DCMetaInfo dcMetaInfoItem) {
public DBInfo addDcMetaInfoItem(CloudStormDCMetaInfo dcMetaInfoItem) {
if (this.dcMetaInfo == null) {
this.dcMetaInfo = new ArrayList<DCMetaInfo>();
this.dcMetaInfo = new ArrayList<CloudStormDCMetaInfo>();
}
this.dcMetaInfo.add(dcMetaInfoItem);
return this;
......@@ -67,11 +67,11 @@ public class DBInfo {
@Valid
public List<DCMetaInfo> getDcMetaInfo() {
public List<CloudStormDCMetaInfo> getDcMetaInfo() {
return dcMetaInfo;
}
public void setDcMetaInfo(List<DCMetaInfo> dcMetaInfo) {
public void setDcMetaInfo(List<CloudStormDCMetaInfo> dcMetaInfo) {
this.dcMetaInfo = dcMetaInfo;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../TOSCA/types/interfaces.yml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/interfaces.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApiController.java" afterDir="false" />
</list>
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -270,25 +267,25 @@
</state>
<state x="792" y="334" width="827" height="663" key="FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046" timestamp="1578326180157" />
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" />
<state width="2437" height="407" key="GridCell.Tab.0.bottom" timestamp="1579103246563">
<screen x="67" y="34" width="2493" height="1406" />
<state width="1825" height="454" key="GridCell.Tab.0.bottom" timestamp="1579191653154">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="263" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1578584059031" />
<state width="1825" height="454" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1579191653154" />
<state width="2437" height="407" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1579103246563" />
<state width="2437" height="407" key="GridCell.Tab.0.center" timestamp="1579103246562">
<screen x="67" y="34" width="2493" height="1406" />
<state width="1825" height="454" key="GridCell.Tab.0.center" timestamp="1579191653153">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="263" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1578584059030" />
<state width="1825" height="454" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1579191653153" />
<state width="2437" height="407" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1579103246562" />
<state width="2437" height="407" key="GridCell.Tab.0.left" timestamp="1579103246561">
<screen x="67" y="34" width="2493" height="1406" />
<state width="1825" height="454" key="GridCell.Tab.0.left" timestamp="1579191653152">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="263" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1578584059030" />
<state width="1825" height="454" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1579191653152" />
<state width="2437" height="407" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1579103246561" />
<state width="2437" height="407" key="GridCell.Tab.0.right" timestamp="1579103246562">
<screen x="67" y="34" width="2493" height="1406" />
<state width="1825" height="454" key="GridCell.Tab.0.right" timestamp="1579191653154">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="263" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1578584059030" />
<state width="1825" height="454" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1579191653154" />
<state width="2437" height="407" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1579103246562" />
<state width="2437" height="407" key="GridCell.Tab.1.bottom" timestamp="1579103246564">
<screen x="67" y="34" width="2493" height="1406" />
......
......@@ -65,8 +65,18 @@
<artifactId>CloudsStorm</artifactId>
<version>b.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
......
......@@ -18,7 +18,6 @@ import nl.uva.sne.drip.model.cloud.storm.CloudDB;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.cloud.storm.DB;
import nl.uva.sne.drip.model.cloud.storm.DBInfo;
import nl.uva.sne.drip.model.cloud.storm.DCMetaInfo;
/**
*
......@@ -51,9 +50,9 @@ class CloudStormDAO {
if (targetCloudDB != null) {
List<CloudsStormVM> vMMetaInfos = new ArrayList<>();
DBInfo dbInfo = objectMapper.readValue(new File(cloudStormDBPath + File.separator + targetCloudDB.getDbInfoFile()), DBInfo.class);
List<DCMetaInfo> metaInfos = dbInfo.getDcMetaInfo();
for (DCMetaInfo metaInfo : metaInfos) {
DBInfo dbInfo = objectMapper.readValue(new File(cloudStormDBPath + File.separator + targetCloudDB.getDbInfoFile()), nl.uva.sne.drip.model.cloud.storm.DBInfo.class);
List< nl.uva.sne.drip.model.cloud.storm.CloudStormDCMetaInfo> metaInfos = dbInfo.getDcMetaInfo();
for ( nl.uva.sne.drip.model.cloud.storm.CloudStormDCMetaInfo metaInfo : metaInfos) {
vMMetaInfos.addAll(metaInfo.getVmMetaInfo());
}
return vMMetaInfos;
......
......@@ -49,6 +49,7 @@ import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.math3.ml.distance.EuclideanDistance;
/**
*
......@@ -181,14 +182,9 @@ class CloudStormService {
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0;
for (NodeTemplateMap vmMap : vmTemplatesMap) {
CloudsStormVM cloudsStormVM = new CloudsStormVM();
String vmType = getVMType(vmMap, provider);
cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vmMap);
// cloudsStormVM.setOS(os);
cloudsStormVM.setOstype(os);
vms.add(cloudsStormVM);
CloudsStormVM cloudStromVM = getBestMatchingCloudStormVM(vmMap, provider);
cloudStromVM.setName("vm" + j);
vms.add(cloudStromVM);
j++;
}
cloudsStormVMs.setVms(vms);
......@@ -202,21 +198,27 @@ class CloudStormService {
return cloudsStormMap;
}
private String getVMType(NodeTemplateMap vmMap, String provider) throws IOException, Exception {
private CloudsStormVM getBestMatchingCloudStormVM(NodeTemplateMap vmMap, String provider) throws IOException, Exception {
Double numOfCores = helper.getVMNumOfCores(vmMap);
Double memSize = helper.getVMNMemSize(vmMap);
String os = helper.getVMNOS(vmMap);
double[] requestedVector = convert2ArrayofDoubles(numOfCores, memSize);
double min = Double.MAX_VALUE;
CloudsStormVM bestMatchingVM = null;
List<CloudsStormVM> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(CloudProviderEnum.fromValue(provider));
for (CloudsStormVM vmInfo : vmInfos) {
Logger.getLogger(CloudStormService.class.getName()).log(Level.FINE, "vmInfo: {0}", vmInfo);
Logger.getLogger(CloudStormService.class.getName()).log(Level.FINE, "numOfCores:{0} memSize: {1} os: {2}", new Object[]{numOfCores, memSize, os});
if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU()))
&& Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOstype().toLowerCase())) {
return vmInfo.getVmType();
if (os.toLowerCase().equals(vmInfo.getOstype().toLowerCase())) {
double[] aveliableVector = convert2ArrayofDoubles(Double.valueOf(vmInfo.getCPU()), Double.valueOf(vmInfo.getMEM()));
EuclideanDistance dist = new EuclideanDistance();
double res = dist.compute(requestedVector, aveliableVector);
if (res < min) {
min = res;
bestMatchingVM = vmInfo;
}
}
return null;
}
return bestMatchingVM;
}
private void writeCloudStormCredentialsFiles(String credentialsTempInputDirPath) throws ApiException, Exception {
......@@ -244,17 +246,15 @@ class CloudStormService {
CredentialInfo cloudStormCredentialInfo = new CredentialInfo();
switch (toscaCredentials.getCloudProviderName().toLowerCase()) {
case "exogeni":
String base64Keystore = toscaCredentials.getKeys().get("keystore");
Converter.decodeBase64BToFile(base64Keystore, tmpPath + File.separator + "user.jks");
cloudStormCredentialInfo.setUserKeyName("user.jks");
cloudStormCredentialInfo.setKeyAlias(toscaCredentials.getUser());
cloudStormCredentialInfo.setKeyPassword(toscaCredentials.getToken());
return cloudStormCredentialInfo;
case "ec2":
// cloudStormCredentialInfo.setAccessKey(toscaCredentials.get);
cloudStormCredentialInfo.setSecretKey(toscaCredentials.getToken());
cloudStormCredentialInfo.setAccessKey(toscaCredentials.getKeys().get("aws_access_key_id"));
return cloudStormCredentialInfo;
}
......@@ -366,4 +366,9 @@ class CloudStormService {
return toscaTemplate;
}
private double[] convert2ArrayofDoubles(Double numOfCores, Double memSize) {
double[] vector = new double[]{numOfCores, memSize};
return vector;
}
}
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