Skip to content

Commit 52e6e4d

Browse files
committed
bug 6930: return async job info in listHost/listStoragePools commands
status 6930: resolved fixed
1 parent 55f2f29 commit 52e6e4d

7 files changed

Lines changed: 57 additions & 8 deletions

File tree

‎api/src/com/cloud/api/commands/CancelPrimaryStorageMaintenanceCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static String getResultObjectName() {
7070
}
7171

7272
public AsyncJob.Type getInstanceType() {
73-
return AsyncJob.Type.Host;
73+
return AsyncJob.Type.StoragePool;
7474
}
7575

7676
public Long getInstanceId() {

‎api/src/com/cloud/api/commands/ListStoragePoolsCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public String getCommandName() {
9898
}
9999

100100
public AsyncJob.Type getInstanceType() {
101-
return AsyncJob.Type.Host;
101+
return AsyncJob.Type.StoragePool;
102102
}
103103

104104
@Override

‎api/src/com/cloud/api/commands/PreparePrimaryStorageForMaintenanceCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static String getResultObjectName() {
6666
}
6767

6868
public AsyncJob.Type getInstanceType() {
69-
return AsyncJob.Type.Host;
69+
return AsyncJob.Type.StoragePool;
7070
}
7171

7272
public Long getInstanceId() {

‎api/src/com/cloud/api/response/HostResponse.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ public class HostResponse extends BaseResponse {
132132
@SerializedName("events") @Param(description="events available for the host")
133133
private String events;
134134

135+
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the host")
136+
private Long jobId;
137+
138+
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
139+
private Integer jobStatus;
140+
135141
public Long getObjectId() {
136142
return getId();
137143
}
@@ -415,4 +421,20 @@ public String getEvents() {
415421
public void setEvents(String events) {
416422
this.events = events;
417423
}
424+
425+
public Long getJobId() {
426+
return jobId;
427+
}
428+
429+
public void setJobId(Long jobId) {
430+
this.jobId = jobId;
431+
}
432+
433+
public Integer getJobStatus() {
434+
return jobStatus;
435+
}
436+
437+
public void setJobStatus(Integer jobStatus) {
438+
this.jobStatus = jobStatus;
439+
}
418440
}

‎api/src/com/cloud/api/response/StoragePoolResponse.java‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ public class StoragePoolResponse extends BaseResponse {
7272

7373
@SerializedName(ApiConstants.STATE) @Param(description="the state of the storage pool")
7474
private Status state;
75+
76+
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the storage pool")
77+
private Long jobId;
78+
79+
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
80+
private Integer jobStatus;
81+
82+
public Long getObjectId() {
83+
return getId();
84+
}
7585

7686
public Long getId() {
7787
return id;
@@ -200,4 +210,20 @@ public Status getState() {
200210
public void setState(Status state) {
201211
this.state = state;
202212
}
213+
214+
public Integer getJobStatus() {
215+
return jobStatus;
216+
}
217+
218+
public void setJobStatus(Integer jobStatus) {
219+
this.jobStatus = jobStatus;
220+
}
221+
222+
public Long getJobId() {
223+
return jobId;
224+
}
225+
226+
public void setJobId(Long jobId) {
227+
this.jobId = jobId;
228+
}
203229
}

‎api/src/com/cloud/async/AsyncJob.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public enum Type {
3030
Template,
3131
Iso,
3232
SystemVm,
33-
Host
33+
Host,
34+
StoragePool
3435
}
3536

3637
Long getId();

‎server/src/com/cloud/api/ApiServer.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ private void buildAsyncListResponse(BaseListCmd command, Account account) {
441441
for (AsyncJob job : jobs) {
442442
if (job.getInstanceId() == null) continue;
443443
for (ResponseObject response : responses) {
444-
if (job.getInstanceId() == response.getObjectId()) {
445-
response.setJobId(job.getId());
446-
response.setJobStatus(job.getStatus());
447-
}
444+
if (response.getObjectId() != null && job.getInstanceId().longValue() == response.getObjectId().longValue()) {
445+
response.setJobId(job.getId());
446+
response.setJobStatus(job.getStatus());
447+
}
448448
}
449449
}
450450
}

0 commit comments

Comments
 (0)