mirror of https://github.com/apache/jclouds.git
extensions needed to get snapshots/volumes working (from grkvlt) and tidies
This commit is contained in:
parent
269754c3c9
commit
f329db5786
|
@ -48,6 +48,18 @@ public class BindTemplateMetadataToQueryParams implements Binder {
|
|||
request = ModifyRequest.addQueryParam(request, "name", metadata.getName(), uriBuilderProvider.get());
|
||||
request = ModifyRequest.addQueryParam(request, "ostypeid", metadata.getOsTypeId(), uriBuilderProvider.get());
|
||||
request = ModifyRequest.addQueryParam(request, "displaytext", metadata.getDisplayText(), uriBuilderProvider.get());
|
||||
if (metadata.getSnapshotId() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "snapshotid", metadata.getSnapshotId(), uriBuilderProvider.get());
|
||||
}
|
||||
if (metadata.getVolumeId() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "volumeid", metadata.getVolumeId(), uriBuilderProvider.get());
|
||||
}
|
||||
if (metadata.getVirtualMachineId() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "virtualmachineid", metadata.getVirtualMachineId(), uriBuilderProvider.get());
|
||||
}
|
||||
if (metadata.getPasswordEnabled() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "passwordenabled", metadata.getPasswordEnabled(), uriBuilderProvider.get());
|
||||
}
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* @author Richard Downer
|
||||
|
@ -377,21 +377,21 @@ public class Snapshot implements Comparable<Snapshot> {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "Snapshot[" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", interval=" + interval +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus='" + jobStatus + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", snapshotType=" + snapshotType +
|
||||
", state=" + state +
|
||||
", volumeId=" + volumeId +
|
||||
", volumeName='" + volumeName + '\'' +
|
||||
", volumeType='" + volumeType + '\'' +
|
||||
']';
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", interval=" + interval +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus='" + jobStatus + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", snapshotType=" + snapshotType +
|
||||
", state=" + state +
|
||||
", volumeId=" + volumeId +
|
||||
", volumeName='" + volumeName + '\'' +
|
||||
", volumeType='" + volumeType + '\'' +
|
||||
']';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,116 +18,221 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class TemplateMetadata {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private long osTypeId;
|
||||
private String displayText;
|
||||
private Long snapshotId;
|
||||
private Long volumeId;
|
||||
private Long virtualMachineId;
|
||||
private Boolean passwordEnabled;
|
||||
|
||||
private String name;
|
||||
private long osTypeId;
|
||||
private String displayText;
|
||||
/**
|
||||
* @param name
|
||||
* the name of the template
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the template
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param osTypeId
|
||||
* the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public Builder osTypeId(long osTypeId) {
|
||||
this.osTypeId = osTypeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param osTypeId the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public Builder osTypeId(long osTypeId) {
|
||||
this.osTypeId = osTypeId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param displayText
|
||||
* the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public Builder displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayText the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public Builder displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param snapshotId
|
||||
* the ID of the snapshot the template is being created from.
|
||||
* Either this parameter, or volumeId has to be passed in
|
||||
*/
|
||||
public Builder snapshotId(Long snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateMetadata build() {
|
||||
return new TemplateMetadata(name, osTypeId, displayText);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param volumeId
|
||||
* the ID of the disk volume the template is being created from.
|
||||
* Either this parameter, or snapshotId has to be passed in
|
||||
*/
|
||||
public Builder volumeId(Long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
private String name;
|
||||
private long osTypeId;
|
||||
private String displayText;
|
||||
/**
|
||||
* @param virtualMachineId
|
||||
* the ID of the disk volume the template is being created from
|
||||
*/
|
||||
public Builder virtualMachineId(Long virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemplateMetadata(String name, long osTypeId, String displayText) {
|
||||
this.name = name;
|
||||
this.osTypeId = osTypeId;
|
||||
this.displayText = displayText;
|
||||
}
|
||||
/**
|
||||
* the template supports the password reset feature.
|
||||
*/
|
||||
public Builder passwordEnabled() {
|
||||
this.passwordEnabled = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
TemplateMetadata() {
|
||||
}
|
||||
public TemplateMetadata build() {
|
||||
TemplateMetadata template = new TemplateMetadata(name, osTypeId, displayText);
|
||||
template.setPasswordEnabled(passwordEnabled);
|
||||
template.setSnapshotId(snapshotId);
|
||||
template.setVirtualMachineId(virtualMachineId);
|
||||
template.setVolumeId(volumeId);
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the template
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
private String name;
|
||||
private long osTypeId;
|
||||
private String displayText;
|
||||
|
||||
/**
|
||||
* @return the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public long getOsTypeId() {
|
||||
return osTypeId;
|
||||
}
|
||||
private Long snapshotId;
|
||||
private Long volumeId;
|
||||
private Long virtualMachineId;;
|
||||
private Boolean passwordEnabled;
|
||||
|
||||
/**
|
||||
* @return the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
public TemplateMetadata(String name, long osTypeId, String displayText) {
|
||||
this.name = name;
|
||||
this.osTypeId = osTypeId;
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
TemplateMetadata() {
|
||||
}
|
||||
|
||||
TemplateMetadata that = (TemplateMetadata) o;
|
||||
/**
|
||||
* @return the ID of the snapshot the template is being created from
|
||||
*/
|
||||
public Long getSnapshotId() {
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
if (osTypeId != that.osTypeId) return false;
|
||||
if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null) return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) return false;
|
||||
public void setSnapshotId(Long snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* @return the ID of the disk volume the template is being created from
|
||||
*/
|
||||
public Long getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (int) (osTypeId ^ (osTypeId >>> 32));
|
||||
result = 31 * result + (displayText != null ? displayText.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
public void setVolumeId(Long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" +
|
||||
"name='" + name + '\'' +
|
||||
", osTypeId=" + osTypeId +
|
||||
", displayText='" + displayText + '\'' +
|
||||
']';
|
||||
}
|
||||
/**
|
||||
* @return Optional, VM ID
|
||||
*/
|
||||
public Long getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
|
||||
public void setVirtualMachineId(Long virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the template supports the password reset feature; default is false
|
||||
*/
|
||||
public Boolean getPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(Boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the template
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public long getOsTypeId() {
|
||||
return osTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
TemplateMetadata that = (TemplateMetadata) o;
|
||||
|
||||
if (osTypeId != that.osTypeId)
|
||||
return false;
|
||||
if (snapshotId != null ? !snapshotId.equals(that.snapshotId) : that.snapshotId != null)
|
||||
return false;
|
||||
if (volumeId != null ? !volumeId.equals(that.volumeId) : that.volumeId != null)
|
||||
return false;
|
||||
if (virtualMachineId != null ? !virtualMachineId.equals(that.virtualMachineId) : that.virtualMachineId != null)
|
||||
return false;
|
||||
if (passwordEnabled != null ? !passwordEnabled.equals(that.passwordEnabled) : that.passwordEnabled != null)
|
||||
return false;
|
||||
if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null)
|
||||
return false;
|
||||
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, displayText, osTypeId, snapshotId, volumeId, passwordEnabled, virtualMachineId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + "name='" + name + '\'' + ", osTypeId=" + osTypeId + ", displayText='" + displayText + '\'' + ']';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -955,18 +955,23 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed="
|
||||
+ cpuUsed + ", displayName=" + displayName + ", created=" + created + ", domain=" + domain + ", domainId="
|
||||
+ domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + ", groupId=" + groupId
|
||||
+ ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + hostId + ", hostname=" + hostname
|
||||
+ ", IPAddress=" + IPAddress + ", ISODisplayText=" + ISODisplayText + ", ISOId=" + ISOId + ", ISOName="
|
||||
+ ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
|
||||
+ ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
|
||||
+ ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
|
||||
+ rootDeviceType + ", serviceOfferingId=" + serviceOfferingId + ", serviceOfferingName="
|
||||
+ serviceOfferingName + ", state=" + state + ", templateDisplayText=" + templateDisplayText
|
||||
+ ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId=" + zoneId + ", zoneName="
|
||||
+ zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + ", securityGroups=" + securityGroups + "]";
|
||||
return "[id=" + id
|
||||
// + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed=" + cpuUsed
|
||||
+ ", displayName=" + displayName + ", created=" + created
|
||||
// + ", domain=" + domain + ", domainId="
|
||||
// + domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + ", groupId=" + groupId
|
||||
// + ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + hostId + ", hostname=" + hostname
|
||||
+ ", IPAddress=" + IPAddress
|
||||
// + ", ISODisplayText=" + ISODisplayText + ", ISOId=" + ISOId + ", ISOName="
|
||||
// + ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name
|
||||
// + ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password
|
||||
// + ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType="
|
||||
// + rootDeviceType + ", serviceOfferingId=" + serviceOfferingId + ", serviceOfferingName=" + serviceOfferingName
|
||||
+ ", state=" + state
|
||||
// + ", templateDisplayText=" + templateDisplayText
|
||||
// + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId=" + zoneId + ", zoneName="
|
||||
// + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + ", securityGroups=" + securityGroups
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -534,6 +534,11 @@ public class Volume implements Comparable<Volume> {
|
|||
result = 31 * result + (zoneName != null ? zoneName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getCanonicalName()+"["+id+"; "+name+"; "+vmState+"]";
|
||||
}
|
||||
|
||||
public enum VolumeType {
|
||||
ROOT(0),
|
||||
|
|
Loading…
Reference in New Issue