Commit c10f0682 authored by Spiros Koulouzis's avatar Spiros Koulouzis

write cloud storm files

parent 8f3f9331
...@@ -46,6 +46,7 @@ public class ToscaHelper { ...@@ -46,6 +46,7 @@ public class ToscaHelper {
private static final String VM_NUM_OF_CORES = "num_cores"; private static final String VM_NUM_OF_CORES = "num_cores";
private static final String MEM_SIZE = "mem_size"; private static final String MEM_SIZE = "mem_size";
private static final String VM_OS = "os"; private static final String VM_OS = "os";
private static final String VM_TOPOLOGY = "tosca.nodes.ARTICONF.VM.topology";
/** /**
* @return the id * @return the id
...@@ -148,4 +149,20 @@ public class ToscaHelper { ...@@ -148,4 +149,20 @@ public class ToscaHelper {
} }
} }
public String getTopologyDomain(NodeTemplate nodeTemplate) throws Exception {
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("domain");
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
public String getTopologyProvider(NodeTemplate nodeTemplate) throws Exception {
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("provider");
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
} }
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -18,7 +19,7 @@ import javax.validation.constraints.*; ...@@ -18,7 +19,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T16:27:40.329Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T16:27:40.329Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeTemplate { public class NodeTemplate {
@JsonProperty("derived_from") @JsonProperty("derived_from")
......
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
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;
...@@ -11,7 +12,7 @@ import org.springframework.data.annotation.Id; ...@@ -11,7 +12,7 @@ import org.springframework.data.annotation.Id;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T11:37:55.458Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T11:37:55.458Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User { public class User {
@JsonProperty("id") @JsonProperty("id")
......
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -14,7 +15,7 @@ import javax.validation.constraints.*; ...@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudDB { public class CloudDB {
@JsonProperty("cloudProvider") @JsonProperty("cloudProvider")
private String cloudProvider = null; private String cloudProvider = null;
......
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -14,7 +15,7 @@ import javax.validation.constraints.*; ...@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubMembers { public class CloudsStormSubMembers {
@JsonProperty("vmName") @JsonProperty("vmName")
private String vmName = null; private String vmName = null;
......
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -14,7 +15,7 @@ import javax.validation.constraints.*; ...@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubTopology { public class CloudsStormSubTopology {
@JsonProperty("topology") @JsonProperty("topology")
private String topology = null; private String topology = null;
......
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubMembers; import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubMembers;
...@@ -17,7 +18,7 @@ import javax.validation.constraints.*; ...@@ -17,7 +18,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubnets { public class CloudsStormSubnets {
@JsonProperty("name") @JsonProperty("name")
private String name = null; private String name = null;
......
...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
...@@ -18,7 +19,7 @@ import javax.validation.constraints.*; ...@@ -18,7 +19,7 @@ import javax.validation.constraints.*;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormTopTopology { public class CloudsStormTopTopology {
@JsonProperty("userName") @JsonProperty("userName")
private String userName = null; private String userName = null;
......
/*
* Copyright 2019 S. Koulouzis
*
* 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.model.cloud.storm; package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.google.gson.annotations.SerializedName; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonRootName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/** /**
* * CloudsStormVM
* @author S. Koulouzis
*/ */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2019-12-09T16:51:48.830052+01:00[Europe/Amsterdam]") @Validated
public class CloudsStormVM { @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z")
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_NODE_TYPE = "nodeType"; @JsonInclude(JsonInclude.Include.NON_NULL)
@SerializedName(SERIALIZED_NAME_NODE_TYPE) @JsonRootName(value = "VMs")
private String nodeType; public class CloudsStormVM {
@JsonIgnore
private String name = null;
public static final String SERIALIZED_NAME_OS_TYPE = "OSType"; @JsonProperty("nodeType")
@SerializedName(SERIALIZED_NAME_OS_TYPE) private String nodeType = null;
private String osType;
public static final String SERIALIZED_NAME_SCRIPT = "script"; @JsonProperty("OSType")
@SerializedName(SERIALIZED_NAME_SCRIPT) private String osType = null;
private String script;
public static final String SERIALIZED_NAME_PUBLIC_ADDRESS = "publicAddress"; @JsonProperty("script")
@SerializedName(SERIALIZED_NAME_PUBLIC_ADDRESS) private String script = null;
private String publicAddress;
@JsonProperty("publicAddress")
private String publicAddress = null;
public CloudsStormVM name(String name) { public CloudsStormVM name(String name) {
this.name = name; this.name = name;
return this; return this;
} }
...@@ -56,21 +45,18 @@ public class CloudsStormVM { ...@@ -56,21 +45,18 @@ public class CloudsStormVM {
* Get name * Get name
* @return name * @return name
**/ **/
@javax.annotation.Nullable
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public CloudsStormVM nodeType(String nodeType) { public CloudsStormVM nodeType(String nodeType) {
this.nodeType = nodeType; this.nodeType = nodeType;
return this; return this;
} }
...@@ -79,21 +65,18 @@ public class CloudsStormVM { ...@@ -79,21 +65,18 @@ public class CloudsStormVM {
* Get nodeType * Get nodeType
* @return nodeType * @return nodeType
**/ **/
@javax.annotation.Nullable
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getNodeType() { public String getNodeType() {
return nodeType; return nodeType;
} }
public void setNodeType(String nodeType) { public void setNodeType(String nodeType) {
this.nodeType = nodeType; this.nodeType = nodeType;
} }
public CloudsStormVM osType(String osType) { public CloudsStormVM osType(String osType) {
this.osType = osType; this.osType = osType;
return this; return this;
} }
...@@ -102,21 +85,18 @@ public class CloudsStormVM { ...@@ -102,21 +85,18 @@ public class CloudsStormVM {
* Get osType * Get osType
* @return osType * @return osType
**/ **/
@javax.annotation.Nullable
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getOsType() { public String getOsType() {
return osType; return osType;
} }
public void setOsType(String osType) { public void setOsType(String osType) {
this.osType = osType; this.osType = osType;
} }
public CloudsStormVM script(String script) { public CloudsStormVM script(String script) {
this.script = script; this.script = script;
return this; return this;
} }
...@@ -125,21 +105,18 @@ public class CloudsStormVM { ...@@ -125,21 +105,18 @@ public class CloudsStormVM {
* Get script * Get script
* @return script * @return script
**/ **/
@javax.annotation.Nullable
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getScript() { public String getScript() {
return script; return script;
} }
public void setScript(String script) { public void setScript(String script) {
this.script = script; this.script = script;
} }
public CloudsStormVM publicAddress(String publicAddress) { public CloudsStormVM publicAddress(String publicAddress) {
this.publicAddress = publicAddress; this.publicAddress = publicAddress;
return this; return this;
} }
...@@ -148,14 +125,13 @@ public class CloudsStormVM { ...@@ -148,14 +125,13 @@ public class CloudsStormVM {
* Get publicAddress * Get publicAddress
* @return publicAddress * @return publicAddress
**/ **/
@javax.annotation.Nullable
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getPublicAddress() { public String getPublicAddress() {
return publicAddress; return publicAddress;
} }
public void setPublicAddress(String publicAddress) { public void setPublicAddress(String publicAddress) {
this.publicAddress = publicAddress; this.publicAddress = publicAddress;
} }
...@@ -182,11 +158,11 @@ public class CloudsStormVM { ...@@ -182,11 +158,11 @@ public class CloudsStormVM {
return Objects.hash(name, nodeType, osType, script, publicAddress); return Objects.hash(name, nodeType, osType, script, publicAddress);
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVM {\n"); sb.append("class CloudsStormVM {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" nodeType: ").append(toIndentedString(nodeType)).append("\n"); sb.append(" nodeType: ").append(toIndentedString(nodeType)).append("\n");
sb.append(" osType: ").append(toIndentedString(osType)).append("\n"); sb.append(" osType: ").append(toIndentedString(osType)).append("\n");
...@@ -206,6 +182,5 @@ public class CloudsStormVM { ...@@ -206,6 +182,5 @@ public class CloudsStormVM {
} }
return o.toString().replace("\n", "\n "); return o.toString().replace("\n", "\n ");
} }
} }
package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* CloudsStormVMs
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormVMs {
@JsonProperty("name")
private String name = null;
@JsonProperty("CloudsStormVM")
@Valid
private List<CloudsStormVM> cloudsStormVM = null;
public CloudsStormVMs 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 CloudsStormVMs cloudsStormVM(List<CloudsStormVM> cloudsStormVM) {
this.cloudsStormVM = cloudsStormVM;
return this;
}
public CloudsStormVMs addCloudsStormVMItem(CloudsStormVM cloudsStormVMItem) {
if (this.cloudsStormVM == null) {
this.cloudsStormVM = new ArrayList<CloudsStormVM>();
}
this.cloudsStormVM.add(cloudsStormVMItem);
return this;
}
/**
* Get cloudsStormVM
* @return cloudsStormVM
**/
@ApiModelProperty(value = "")
@Valid
public List<CloudsStormVM> getCloudsStormVM() {
return cloudsStormVM;
}
public void setCloudsStormVM(List<CloudsStormVM> cloudsStormVM) {
this.cloudsStormVM = cloudsStormVM;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CloudsStormVMs cloudsStormVMs = (CloudsStormVMs) o;
return Objects.equals(this.name, cloudsStormVMs.name) &&
Objects.equals(this.cloudsStormVM, cloudsStormVMs.cloudsStormVM);
}
@Override
public int hashCode() {
return Objects.hash(name, cloudsStormVM);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVMs {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" cloudsStormVM: ").append(toIndentedString(cloudsStormVM)).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";
}
return o.toString().replace("\n", "\n ");
}
}
package nl.uva.sne.drip.model.cloud.storm; package nl.uva.sne.drip.model.cloud.storm;
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;
...@@ -13,7 +14,7 @@ import javax.validation.Valid; ...@@ -13,7 +14,7 @@ import javax.validation.Valid;
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:52:11.688Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:52:11.688Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DB { public class DB {
@JsonProperty("cloudDBs") @JsonProperty("cloudDBs")
......
...@@ -243,22 +243,22 @@ ...@@ -243,22 +243,22 @@
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" /> <state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" />
<state width="2465" height="410" key="GridCell.Tab.0.bottom" timestamp="1576064606672"> <state width="2465" height="410" key="GridCell.Tab.0.bottom" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606672" /> <state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.center" timestamp="1576064606669"> <state width="2465" height="410" key="GridCell.Tab.0.center" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606669" /> <state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.left" timestamp="1576064606668"> <state width="2465" height="410" key="GridCell.Tab.0.left" timestamp="1576092018570">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606668" /> <state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018570" />
<state width="2465" height="410" key="GridCell.Tab.0.right" timestamp="1576064606671"> <state width="2465" height="410" key="GridCell.Tab.0.right" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state width="2465" height="410" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606671" /> <state width="2465" height="410" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="471" key="GridCell.Tab.1.bottom" timestamp="1575891470098"> <state width="2465" height="471" key="GridCell.Tab.1.bottom" timestamp="1575891470098">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
package nl.uva.sne.drip.provisioner; package nl.uva.sne.drip.provisioner;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException; import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair; import com.jcraft.jsch.KeyPair;
...@@ -13,6 +17,7 @@ import java.io.File; ...@@ -13,6 +17,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -22,6 +27,7 @@ import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM; ...@@ -22,6 +27,7 @@ import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVMs;
import nl.uva.sne.drip.model.cloud.storm.VMMetaInfo; import nl.uva.sne.drip.model.cloud.storm.VMMetaInfo;
import nl.uva.sne.drip.model.tosca.ToscaTemplate; import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.ApiException; import nl.uva.sne.drip.sure.tosca.client.ApiException;
...@@ -34,10 +40,11 @@ import org.apache.commons.io.FilenameUtils; ...@@ -34,10 +40,11 @@ import org.apache.commons.io.FilenameUtils;
class CloudStormService { class CloudStormService {
private List<Map.Entry> vmTopologies; private List<Map.Entry> vmTopologies;
private String tempInputDirPath; // private String tempInputDirPath;
private final ToscaTemplate toscaTemplate; private final ToscaTemplate toscaTemplate;
private final ToscaHelper helper; private final ToscaHelper helper;
private final CloudStormDAO cloudStormDAO; private final CloudStormDAO cloudStormDAO;
private final ObjectMapper objectMapper;
CloudStormService(Properties properties, ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException { CloudStormService(Properties properties, ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException {
this.toscaTemplate = toscaTemplate; this.toscaTemplate = toscaTemplate;
...@@ -45,33 +52,38 @@ class CloudStormService { ...@@ -45,33 +52,38 @@ class CloudStormService {
cloudStormDAO = new CloudStormDAO(cloudStormDBPath); cloudStormDAO = new CloudStormDAO(cloudStormDBPath);
String sureToscaBasePath = properties.getProperty("sure-tosca.base.path"); String sureToscaBasePath = properties.getProperty("sure-tosca.base.path");
this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath); this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
} }
public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException, Exception { public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException, Exception {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator; String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath); File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) { if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath()); throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
} }
buildCloudStormTopTopology(toscaTemplate); writeCloudStormTopology(toscaTemplate, tempInputDirPath);
return toscaTemplate; return toscaTemplate;
} }
private CloudsStormTopTopology buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException, ApiException, Exception { private void writeCloudStormTopology(ToscaTemplate toscaTemplate, String tempInputDirPath) throws JSchException, IOException, ApiException, Exception {
CloudsStormTopTopology topTopology = new CloudsStormTopTopology(); CloudsStormTopTopology topTopology = new CloudsStormTopTopology();
String publicKeyPath = buildSSHKeyPair(); String publicKeyPath = buildSSHKeyPair(tempInputDirPath);
topTopology.setPublicKeyPath(publicKeyPath); topTopology.setPublicKeyPath(publicKeyPath);
topTopology.setUserName(getUserName()); topTopology.setUserName(getUserName());
List<CloudsStormSubTopology> topologies = getCloudsStormSubTopologies(toscaTemplate); Map<String, Object> subTopologiesAndVMs = getCloudsStormSubTopologiesAndVMs(toscaTemplate, tempInputDirPath);
topTopology.setTopologies(topologies); List<CloudsStormSubTopology> cloudsStormSubTopology = (List<CloudsStormSubTopology>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
topTopology.setTopologies(cloudsStormSubTopology);
return topTopology; objectMapper.writeValue(new File(tempInputDirPath + File.separator + "top.yml"), topTopology);
// <CloudsStormVMs > cloudsStormVMsList = (List<CloudsStormVMs>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
} }
private String buildSSHKeyPair() throws JSchException, IOException { private String buildSSHKeyPair(String tempInputDirPath) throws JSchException, IOException {
String userPublicKeyName = "id_rsa.pub"; String userPublicKeyName = "id_rsa.pub";
String publicKeyPath = "name@" + userPublicKeyName; String publicKeyPath = "name@" + userPublicKeyName;
JSch jsch = new JSch(); JSch jsch = new JSch();
...@@ -87,33 +99,46 @@ class CloudStormService { ...@@ -87,33 +99,46 @@ class CloudStormService {
return "vm_user"; return "vm_user";
} }
private List<CloudsStormSubTopology> getCloudsStormSubTopologies(ToscaTemplate toscaTemplate) throws ApiException, IOException, Exception { private Map<String, Object> getCloudsStormSubTopologiesAndVMs(ToscaTemplate toscaTemplate, String tempInputDirPath) throws ApiException, IOException, Exception {
List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates(); List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates();
List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>(); List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>();
Map<String, Object> cloudsStormMap = new HashMap<>();
List<CloudsStormVMs> cloudsStormVMsList = new ArrayList<>();
int i = 0; int i = 0;
for (NodeTemplate nodeTemplate : vmTopologyTemplates) { for (NodeTemplate nodeTemplate : vmTopologyTemplates) {
CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology(); CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology();
String domain = helper.getTopologyDomain(nodeTemplate);
Map<String, Object> properties = nodeTemplate.getProperties(); String provider = helper.getTopologyProvider(nodeTemplate);
String domain = (String) properties.get("domain");
String provider = (String) properties.get("provider");
cloudsStormSubTopology.setDomain(domain); cloudsStormSubTopology.setDomain(domain);
cloudsStormSubTopology.setCloudProvider(provider); cloudsStormSubTopology.setCloudProvider(provider);
cloudsStormSubTopology.setTopology("vm_topology" + i); cloudsStormSubTopology.setTopology("vm_topology" + i);
cloudsStormSubTopology.setStatus("fresh"); cloudsStormSubTopology.setStatus("fresh");
CloudsStormVMs cloudsStormVMs = new CloudsStormVMs();
List<NodeTemplate> vmTemplates = helper.getTopologyTemplateVMs(nodeTemplate);
List<CloudsStormVM> vms = new ArrayList<>(); List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplate> vmTemplates = helper.getTopologyTemplateVMs(nodeTemplate);
int j = 0;
for (NodeTemplate vm : vmTemplates) { for (NodeTemplate vm : vmTemplates) {
CloudsStormVM cloudsStormVM = new CloudsStormVM(); CloudsStormVM cloudsStormVM = new CloudsStormVM();
String vmType = getVMType(vm, provider); String vmType = getVMType(vm, provider);
cloudsStormVM.setNodeType(vmType); cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vm);
cloudsStormVM.setOsType(os);
vms.add(cloudsStormVM);
j++;
} }
cloudsStormVMs.setCloudsStormVM(vms);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "vm_topology" + i + ".yml"), cloudsStormVMs);
cloudsStormVMsList.add(cloudsStormVMs);
cloudsStormSubTopologies.add(cloudsStormSubTopology);
i++; i++;
} }
return cloudsStormSubTopologies; cloudsStormMap.put("cloud_storm_vm", cloudsStormVMsList);
cloudsStormMap.put("cloud_storm_subtopologies", cloudsStormSubTopologies);
return cloudsStormMap;
} }
private String getVMType(NodeTemplate vm, String provider) throws IOException, Exception { private String getVMType(NodeTemplate vm, String provider) throws IOException, Exception {
...@@ -122,14 +147,10 @@ class CloudStormService { ...@@ -122,14 +147,10 @@ class CloudStormService {
String os = helper.getVMNOS(vm); String os = helper.getVMNOS(vm);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider); List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
for (VMMetaInfo vmInfo : vmInfos) { for (VMMetaInfo vmInfo : vmInfos) {
System.err.println("numOfCores: " + numOfCores + " = " + vmInfo.getCPU());
System.err.println("memSize: " + numOfCores + " = " + vmInfo.getMEM());
System.err.println("os: " + os + " = " + vmInfo.getOS());
if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) { if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) {
return vmInfo.getVmType(); return vmInfo.getVmType();
} }
} }
return null; return null;
} }
......
...@@ -9,10 +9,3 @@ ...@@ -9,10 +9,3 @@
type: "string" type: "string"
status: status:
type: "string" type: "string"
#VMs:
#type: array
#items:
#$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormVM.yml#/CloudsStormVM'
...@@ -11,4 +11,3 @@ ...@@ -11,4 +11,3 @@
type: array type: array
items: items:
$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubMembers.yml#/CloudsStormSubMembers' $ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubMembers.yml#/CloudsStormSubMembers'
...@@ -14,3 +14,6 @@ ...@@ -14,3 +14,6 @@
items: items:
$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubnets.yml#/CloudsStormSubnets' $ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubnets.yml#/CloudsStormSubnets'
CloudsStormVMs:
type: "object"
properties:
name:
type: "string"
CloudsStormVM:
type: "array"
items:
$ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormVM.yml#/CloudsStormVM"
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