Skip to content

Commit 7ae784b

Browse files
committed
CLOUDSTACK-6633: listVolumes should return template/iso info for root volumes
1 parent 6c8a0a1 commit 7ae784b

4 files changed

Lines changed: 132 additions & 4 deletions

File tree

api/src/org/apache/cloudstack/api/response/VolumeResponse.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
6060
@Param(description = "id of the virtual machine")
6161
private String virtualMachineId;
6262

63+
@SerializedName("isoid")
64+
@Param(description = "the ID of the ISO attached to the virtual machine")
65+
private String isoId;
66+
67+
@SerializedName("isoname")
68+
@Param(description = "the name of the ISO attached to the virtual machine")
69+
private String isoName;
70+
71+
@SerializedName("isodisplaytext")
72+
@Param(description = "an alternate display text of the ISO attached to the virtual machine")
73+
private String isoDisplayText;
74+
75+
@SerializedName(ApiConstants.TEMPLATE_ID)
76+
@Param(description = "the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file.")
77+
private String templateId;
78+
79+
@SerializedName("templatename")
80+
@Param(description = "the name of the template for the virtual machine")
81+
private String templateName;
82+
83+
@SerializedName("templatedisplaytext")
84+
@Param(description = " an alternate display text of the template for the virtual machine")
85+
private String templateDisplayText;
86+
6387
@SerializedName("vmname")
6488
@Param(description = "name of the virtual machine")
6589
private String virtualMachineName;
@@ -451,5 +475,51 @@ public boolean isNeedQuiescevm() {
451475
return this.needQuiescevm;
452476
}
453477

478+
public String getIsoId() {
479+
return isoId;
480+
}
481+
482+
public void setIsoId(String isoId) {
483+
this.isoId = isoId;
484+
}
485+
486+
public String getIsoName() {
487+
return isoName;
488+
}
489+
490+
public void setIsoName(String isoName) {
491+
this.isoName = isoName;
492+
}
493+
494+
public String getIsoDisplayText() {
495+
return isoDisplayText;
496+
}
497+
498+
public void setIsoDisplayText(String isoDisplayText) {
499+
this.isoDisplayText = isoDisplayText;
500+
}
501+
502+
public String getTemplateId() {
503+
return templateId;
504+
}
505+
506+
public void setTemplateId(String templateId) {
507+
this.templateId = templateId;
508+
}
454509

510+
public String getTemplateName() {
511+
return templateName;
512+
}
513+
514+
public void setTemplateName(String templateName) {
515+
this.templateName = templateName;
516+
}
517+
518+
public String getTemplateDisplayText() {
519+
return templateDisplayText;
520+
}
521+
522+
public void setTemplateDisplayText(String templateDisplayText) {
523+
this.templateDisplayText = templateDisplayText;
524+
}
455525
}

server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume)
217217
volResponse.setDisplayVolume(volume.isDisplayVolume());
218218
volResponse.setChainInfo(volume.getChainInfo());
219219

220+
volResponse.setTemplateId(volume.getTemplateUuid());
221+
volResponse.setTemplateName(volume.getTemplateName());
222+
volResponse.setTemplateDisplayText(volume.getTemplateDisplayText());
223+
224+
volResponse.setIsoId(volume.getIsoUuid());
225+
volResponse.setIsoName(volume.getIsoName());
226+
volResponse.setIsoDisplayText(volume.getIsoDisplayText());
227+
220228
// set async job
221229
if (volume.getJobId() != null) {
222230
volResponse.setJobId(volume.getJobUuid());

server/src/com/cloud/api/query/vo/VolumeJoinVO.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,30 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
216216
@Column(name = "template_uuid")
217217
private String templateUuid;
218218

219+
@Column(name = "template_name")
220+
private String templateName;
221+
222+
@Column(name = "template_display_text", length = 4096)
223+
private String templateDisplayText;
224+
219225
@Column(name = "extractable")
220226
private boolean extractable;
221227

222228
@Column(name = "template_type")
223229
private Storage.TemplateType templateType;
224230

231+
@Column(name = "iso_id", updatable = true, nullable = true, length = 17)
232+
private long isoId;
233+
234+
@Column(name = "iso_uuid")
235+
private String isoUuid;
236+
237+
@Column(name = "iso_name")
238+
private String isoName;
239+
240+
@Column(name = "iso_display_text", length = 4096)
241+
private String isoDisplayText;
242+
225243
@Column(name = "job_id")
226244
private Long jobId;
227245

@@ -502,6 +520,30 @@ public Storage.TemplateType getTemplateType() {
502520
return templateType;
503521
}
504522

523+
public String getTemplateName() {
524+
return templateName;
525+
}
526+
527+
public String getTemplateDisplayText() {
528+
return templateDisplayText;
529+
}
530+
531+
public long getIsoId() {
532+
return isoId;
533+
}
534+
535+
public String getIsoUuid() {
536+
return isoUuid;
537+
}
538+
539+
public String getIsoName() {
540+
return isoName;
541+
}
542+
543+
public String getIsoDisplayText() {
544+
return isoDisplayText;
545+
}
546+
505547
public Long getJobId() {
506548
return jobId;
507549
}

setup/db/db/schema-430to440.sql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ CREATE VIEW `cloud`.`volume_view` AS
128128
volumes.attached,
129129
volumes.removed,
130130
volumes.pod_id,
131-
volumes.display_volume,
131+
volumes.display_volume,
132132
volumes.format,
133-
volumes.path,
133+
volumes.path,
134134
volumes.chain_info,
135135
account.id account_id,
136136
account.uuid account_uuid,
@@ -146,7 +146,7 @@ CREATE VIEW `cloud`.`volume_view` AS
146146
data_center.id data_center_id,
147147
data_center.uuid data_center_uuid,
148148
data_center.name data_center_name,
149-
data_center.networktype data_center_type,
149+
data_center.networktype data_center_type,
150150
vm_instance.id vm_id,
151151
vm_instance.uuid vm_uuid,
152152
vm_instance.name vm_name,
@@ -177,6 +177,12 @@ CREATE VIEW `cloud`.`volume_view` AS
177177
vm_template.uuid template_uuid,
178178
vm_template.extractable,
179179
vm_template.type template_type,
180+
vm_template.name template_name,
181+
vm_template.display_text template_display_text,
182+
iso.id iso_id,
183+
iso.uuid iso_uuid,
184+
iso.name iso_name,
185+
iso.display_text iso_display_text,
180186
resource_tags.id tag_id,
181187
resource_tags.uuid tag_uuid,
182188
resource_tags.key tag_key,
@@ -214,7 +220,9 @@ CREATE VIEW `cloud`.`volume_view` AS
214220
left join
215221
`cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
216222
left join
217-
`cloud`.`vm_template` ON volumes.template_id = vm_template.id OR volumes.iso_id = vm_template.id
223+
`cloud`.`vm_template` ON volumes.template_id = vm_template.id
224+
left join
225+
`cloud`.`vm_template` iso ON iso.id = volumes.iso_id
218226
left join
219227
`cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id
220228
and resource_tags.resource_type = 'Volume'

0 commit comments

Comments
 (0)