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