From 2df6b0a6e19cb8492f494e965227e91c55e0f956 Mon Sep 17 00:00:00 2001 From: alena Date: Fri, 6 May 2011 16:39:53 -0700 Subject: [PATCH] bug 9774: display non-ready templates. Added "state" field to all snapshot* api responses. --- .../cloud/api/response/SnapshotResponse.java | 62 ++++++++++++++----- .../src/com/cloud/api/ApiResponseHelper.java | 1 + .../storage/snapshot/SnapshotManagerImpl.java | 2 - 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/api/src/com/cloud/api/response/SnapshotResponse.java b/api/src/com/cloud/api/response/SnapshotResponse.java index 6e993c43523..1dfa29a569c 100644 --- a/api/src/com/cloud/api/response/SnapshotResponse.java +++ b/api/src/com/cloud/api/response/SnapshotResponse.java @@ -19,51 +19,71 @@ package com.cloud.api.response; import java.util.Date; +import com.cloud.api.ApiConstants; import com.cloud.serializer.Param; +import com.cloud.storage.Snapshot; import com.google.gson.annotations.SerializedName; public class SnapshotResponse extends BaseResponse { - @SerializedName("id") @Param(description="ID of the snapshot") + @SerializedName("id") + @Param(description = "ID of the snapshot") private Long id; - @SerializedName("account") @Param(description="the account associated with the snapshot") + @SerializedName("account") + @Param(description = "the account associated with the snapshot") private String accountName; - @SerializedName("domainid") @Param(description="the domain ID of the snapshot's account") + @SerializedName("domainid") + @Param(description = "the domain ID of the snapshot's account") private Long domainId; - @SerializedName("domain") @Param(description="the domain name of the snapshot's account") + @SerializedName("domain") + @Param(description = "the domain name of the snapshot's account") private String domainName; - @SerializedName("snapshottype") @Param(description="the type of the snapshot") + @SerializedName("snapshottype") + @Param(description = "the type of the snapshot") private String snapshotType; - @SerializedName("volumeid") @Param(description="ID of the disk volume") + @SerializedName("volumeid") + @Param(description = "ID of the disk volume") private Long volumeId; - @SerializedName("volumename") @Param(description="name of the disk volume") + @SerializedName("volumename") + @Param(description = "name of the disk volume") private String volumeName; - @SerializedName("volumetype") @Param(description="type of the disk volume") + @SerializedName("volumetype") + @Param(description = "type of the disk volume") private String volumeType; - @SerializedName("created") @Param(description=" the date the snapshot was created") + @SerializedName("created") + @Param(description = " the date the snapshot was created") private Date created; - @SerializedName("name") @Param(description="name of the snapshot") + @SerializedName("name") + @Param(description = "name of the snapshot") private String name; - @SerializedName("jobid") @Param(description="the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.") + @SerializedName("jobid") + @Param(description = "the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.") private Long jobId; - @SerializedName("jobstatus") @Param(description="the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.") + @SerializedName("jobstatus") + @Param(description = "the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.") private Integer jobStatus; - @SerializedName("intervaltype") @Param(description="valid types are hourly, daily, weekly, monthy, template, and none.") + @SerializedName("intervaltype") + @Param(description = "valid types are hourly, daily, weekly, monthy, template, and none.") private String intervalType; - + + @SerializedName(ApiConstants.STATE) + @Param(description = "the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage") + private Snapshot.Status state; + + @Override public Long getObjectId() { - return getId(); + return getId(); } public Long getId() { @@ -146,18 +166,22 @@ public class SnapshotResponse extends BaseResponse { this.name = name; } + @Override public Long getJobId() { return jobId; } + @Override public void setJobId(Long jobId) { this.jobId = jobId; } + @Override public Integer getJobStatus() { return jobStatus; } + @Override public void setJobStatus(Integer jobStatus) { this.jobStatus = jobStatus; } @@ -169,4 +193,12 @@ public class SnapshotResponse extends BaseResponse { public void setIntervalType(String intervalType) { this.intervalType = intervalType; } + + public Snapshot.Status getState() { + return state; + } + + public void setState(Snapshot.Status state) { + this.state = state; + } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index f50cb0703b2..1657a58e67d 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -455,6 +455,7 @@ public class ApiResponseHelper implements ResponseGenerator { snapshotResponse.setCreated(snapshot.getCreated()); snapshotResponse.setName(snapshot.getName()); snapshotResponse.setIntervalType(ApiDBUtils.getSnapshotIntervalTypes(snapshot.getId())); + snapshotResponse.setState(snapshot.getStatus()); snapshotResponse.setObjectName("snapshot"); return snapshotResponse; } diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 149d6f8a399..6a1c83a5f2f 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -885,8 +885,6 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma SearchCriteria sc = sb.create(); - sc.setParameters("status", Snapshot.Status.BackedUp); - if (volumeId != null) { sc.setParameters("volumeId", volumeId); }