Commit 2a3fc6a8 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'byon-register' into 'proactive-dev'

Byon support model definition

See merge request !82
parents 88c311cf adf27133
......@@ -546,12 +546,25 @@ public class PAGateway {
/**
* Register new BYON nodes passed as ByonDefinition object
* @param newByonNode an object of class ByonDefinition that contains the detials of the nodes to be registered.
* @param byonNodeDefinition an object of class ByonDefinition that contains the detials of the nodes to be registered.
* @param jobId A constructed job identifier
* @return ByonNode an object that contains information about the registered Node
*/
public ByonNode registerNewByonNode(ByonDefinition newByonNode, String jobId) {
return null;
public ByonNode registerNewByonNode(ByonDefinition byonNodeDefinition, String jobId) {
Validate.notNull(byonNodeDefinition, "The received Byon node definition is empty. Nothing to be registered.");
Validate.notNull(jobId, "The received jobId is empty. Nothing to be registered.");
EntityManagerHelper.begin();
ByonNode newByonNode = new ByonNode();
newByonNode.setName(byonNodeDefinition.getName());
newByonNode.setLoginCredential(byonNodeDefinition.getLoginCredential());
newByonNode.setIpAddresses(byonNodeDefinition.getIpAddresses());
newByonNode.setNodeProperties(byonNodeDefinition.getNodeProperties());
EntityManagerHelper.persist(newByonNode);
EntityManagerHelper.commit();
return newByonNode;
//TODO
}
......
package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
/**
* Attributes defining a BYON node
*/
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class ByonDefinition {
@JsonProperty("name")
private String name = null;
@JsonProperty("loginCredential")
private LoginCredential loginCredential = null;
@JsonProperty("ipAddresses")
private List<IpAddress> ipAddresses = null;
@JsonProperty("nodeProperties")
private NodeProperties nodeProperties = null;
}
package org.activeeon.morphemic.model;
public class ByonNode {
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;
/**
* Representation of a BYON used by Cloudiator
*/
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "BYON_NODE")
public class ByonNode implements Serializable {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(name = "ID")
@JsonProperty("id")
private String id = null;
@Column(name = "NAME")
@JsonProperty("name")
private String name = null;
@Embedded
@JsonProperty("loginCredential")
private LoginCredential loginCredential = null;
@ElementCollection(targetClass=IpAddress.class)
private List<IpAddress> ipAddresses = null;
@Embedded
@JsonProperty("nodeProperties")
private NodeProperties nodeProperties = null;
@Column(name = "REASON")
@JsonProperty("reason")
private String reason = null;
@Column(name = "DIAGNOSTIC")
@JsonProperty("diagnostic")
private String diagnostic = null;
@Column(name = "NODE_CANDIDATE")
@JsonProperty("nodeCandidate")
private String nodeCandidate = null;
@Column(name = "USER_ID")
@JsonProperty("userId")
private String userId = null;
@Column(name = "ALLOCATED")
@JsonProperty("allocated")
private Boolean allocated = null;
public ByonNode name(String name) {
this.name = name;
return this;
}
/**
* Human-readable name for the node.
* @return name
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ByonNode loginCredential(LoginCredential loginCredential) {
this.loginCredential = loginCredential;
return this;
}
/**
* Get loginCredential
* @return loginCredential
**/
public LoginCredential getLoginCredential() {
return loginCredential;
}
public void setLoginCredential(LoginCredential loginCredential) {
this.loginCredential = loginCredential;
}
public ByonNode ipAddresses(List<IpAddress> ipAddresses) {
this.ipAddresses = ipAddresses;
return this;
}
public ByonNode addIpAddressesItem(IpAddress ipAddressesItem) {
if (this.ipAddresses == null) {
this.ipAddresses = new ArrayList<IpAddress>();
}
this.ipAddresses.add(ipAddressesItem);
return this;
}
/**
* The public/private ip addresses under which this node is reachable.
* @return ipAddresses
**/
public List<IpAddress> getIpAddresses() {
return ipAddresses;
}
public void setIpAddresses(List<IpAddress> ipAddresses) {
this.ipAddresses = ipAddresses;
}
public ByonNode nodeProperties(NodeProperties nodeProperties) {
this.nodeProperties = nodeProperties;
return this;
}
/**
* Further properties of this node.
* @return nodeProperties
**/
public NodeProperties getNodeProperties() {
return nodeProperties;
}
public void setNodeProperties(NodeProperties nodeProperties) {
this.nodeProperties = nodeProperties;
}
public ByonNode reason(String reason) {
this.reason = reason;
return this;
}
/**
* Reason this node was created
* @return reason
**/
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public ByonNode diagnostic(String diagnostic) {
this.diagnostic = diagnostic;
return this;
}
/**
* Diagnostic information about the node state
* @return diagnostic
**/
public String getDiagnostic() {
return diagnostic;
}
public void setDiagnostic(String diagnostic) {
this.diagnostic = diagnostic;
}
public ByonNode nodeCandidate(String nodeCandidate) {
this.nodeCandidate = nodeCandidate;
return this;
}
/**
* The node candidate this node was created from if applicable.
* @return nodeCandidate
**/
public String getNodeCandidate() {
return nodeCandidate;
}
public void setNodeCandidate(String nodeCandidate) {
this.nodeCandidate = nodeCandidate;
}
public ByonNode id(String id) {
this.id = id;
return this;
}
/**
* Unique identifier of this BYON.
* @return id
**/
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ByonNode userId(String userId) {
this.userId = userId;
return this;
}
/**
* User id of the owner of this node.
* @return userId
**/
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public ByonNode allocated(Boolean allocated) {
this.allocated = allocated;
return this;
}
/**
* Signals if the node was allocated by cloudiator
* @return allocated
**/
public Boolean isAllocated() {
return allocated;
}
public void setAllocated(Boolean allocated) {
this.allocated = allocated;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ByonNode byonNode = (ByonNode) o;
return Objects.equals(this.name, byonNode.name) &&
Objects.equals(this.loginCredential, byonNode.loginCredential) &&
Objects.equals(this.ipAddresses, byonNode.ipAddresses) &&
Objects.equals(this.nodeProperties, byonNode.nodeProperties) &&
Objects.equals(this.reason, byonNode.reason) &&
Objects.equals(this.diagnostic, byonNode.diagnostic) &&
Objects.equals(this.nodeCandidate, byonNode.nodeCandidate) &&
Objects.equals(this.id, byonNode.id) &&
Objects.equals(this.userId, byonNode.userId) &&
Objects.equals(this.allocated, byonNode.allocated);
}
@Override
public int hashCode() {
return Objects.hash(name, loginCredential, ipAddresses, nodeProperties, reason, diagnostic, nodeCandidate, id, userId, allocated);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ByonNode {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" loginCredential: ").append(toIndentedString(loginCredential)).append("\n");
sb.append(" ipAddresses: ").append(toIndentedString(ipAddresses)).append("\n");
sb.append(" nodeProperties: ").append(toIndentedString(nodeProperties)).append("\n");
sb.append(" reason: ").append(toIndentedString(reason)).append("\n");
sb.append(" diagnostic: ").append(toIndentedString(diagnostic)).append("\n");
sb.append(" nodeCandidate: ").append(toIndentedString(nodeCandidate)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" allocated: ").append(toIndentedString(allocated)).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 org.activeeon.morphemic.model;
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sun.istack.NotNull;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* IpAddress
*/
@AllArgsConstructor
@NoArgsConstructor
@Embeddable
public class IpAddress implements Serializable {
@Column(name = "IP_ADDRESS_TYPE")
@Enumerated(EnumType.STRING)
@JsonProperty("IpAddressType")
private IpAddressType ipAddressType = null;
@Column(name = "IP_VERSION")
@Enumerated(EnumType.STRING)
@JsonProperty("IpVersion")
private IpVersion ipVersion = null;
@Column(name = "VALUE")
@JsonProperty("value")
private String value = null;
public IpAddress ipAddressType(IpAddressType ipAddressType) {
this.ipAddressType = ipAddressType;
return this;
}
/**
* Get ipAddressType
* @return ipAddressType
**/
@NotNull
public IpAddressType getIpAddressType() {
return ipAddressType;
}
public void setIpAddressType(IpAddressType ipAddressType) {
this.ipAddressType = ipAddressType;
}
public IpAddress ipVersion(IpVersion ipVersion) {
this.ipVersion = ipVersion;
return this;
}
/**
* Get ipVersion
* @return ipVersion
**/
@NotNull
public IpVersion getIpVersion() {
return ipVersion;
}
public void setIpVersion(IpVersion ipVersion) {
this.ipVersion = ipVersion;
}
public IpAddress value(String value) {
this.value = value;
return this;
}
/**
* the ip address value
* @return value
**/
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IpAddress ipAddress = (IpAddress) o;
return Objects.equals(this.ipAddressType, ipAddress.ipAddressType) &&
Objects.equals(this.ipVersion, ipAddress.ipVersion) &&
Objects.equals(this.value, ipAddress.value);
}
@Override
public int hashCode() {
return Objects.hash(ipAddressType, ipVersion, value);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class IpAddress {\n");
sb.append(" ipAddressType: ").append(toIndentedString(ipAddressType)).append("\n");
sb.append(" ipVersion: ").append(toIndentedString(ipVersion)).append("\n");
sb.append(" value: ").append(toIndentedString(value)).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 org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonCreator;
/**
* Gets or Sets IpAddressType
*/
public enum IpAddressType {
PUBLIC_IP("PUBLIC_IP"),
PRIVATE_IP("PRIVATE_IP");
private String value;
IpAddressType(String value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static IpAddressType fromValue(String text) {
for (IpAddressType b : IpAddressType.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}
package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonCreator;
/**
* Gets or Sets IpVersion
*/
public enum IpVersion {
V4("V4"),
V6("V6");
private String value;
IpVersion(String value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
@JsonCreator
public static IpVersion fromValue(String text) {
for (IpVersion b : IpVersion.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
}
package org.activeeon.morphemic.model;
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;