Skip to content

Commit 5c1d639

Browse files
committed
CLOUDSTACK-5829:
listvms should return the diskoffering id when deployed with an iso
1 parent ac8bc74 commit 5c1d639

7 files changed

Lines changed: 260 additions & 4 deletions

File tree

‎api/src/org/apache/cloudstack/api/ApiConstants.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,6 @@ public enum HostDetails {
554554
}
555555

556556
public enum VMDetails {
557-
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min, affgrp;
557+
all, group, nics, stats, secgrp, tmpl, servoff, diskoff, iso, volume, min, affgrp;
558558
}
559559
}

‎api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
9595
type = CommandType.LIST,
9696
collectionType = CommandType.STRING,
9797
description = "comma separated list of host details requested, "
98-
+ "value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min, affgrp]."
98+
+ "value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, diskoff, iso, volume, min, affgrp]."
9999
+ " If no parameter is passed in, the details will be defaulted to all")
100100
private List<String> viewDetails;
101101

‎api/src/org/apache/cloudstack/api/response/UserVmResponse.java‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
139139
@Param(description = "the name of the service offering of the virtual machine")
140140
private String serviceOfferingName;
141141

142+
@SerializedName(ApiConstants.DISK_OFFERING_ID)
143+
@Param(description = "the ID of the disk offering of the virtual machine")
144+
private String diskOfferingId;
145+
146+
@SerializedName("diskofferingname")
147+
@Param(description = "the name of the disk offering of the virtual machine")
148+
private String diskOfferingName;
149+
142150
@SerializedName("forvirtualnetwork")
143151
@Param(description = "the virtual network for the service offering")
144152
private Boolean forVirtualNetwork;
@@ -387,6 +395,14 @@ public String getServiceOfferingName() {
387395
return serviceOfferingName;
388396
}
389397

398+
public String getDiskOfferingId() {
399+
return diskOfferingId;
400+
}
401+
402+
public String getDiskOfferingName() {
403+
return diskOfferingName;
404+
}
405+
390406
public Boolean getForVirtualNetwork() {
391407
return forVirtualNetwork;
392408
}
@@ -606,6 +622,14 @@ public void setServiceOfferingName(String serviceOfferingName) {
606622
this.serviceOfferingName = serviceOfferingName;
607623
}
608624

625+
public void setDiskOfferingId(String diskOfferingId) {
626+
this.diskOfferingId = diskOfferingId;
627+
}
628+
629+
public void setDiskOfferingName(String diskOfferingName) {
630+
this.diskOfferingName = diskOfferingName;
631+
}
632+
609633
public void setCpuNumber(Integer cpuNumber) {
610634
this.cpuNumber = cpuNumber;
611635
}

‎server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm,
145145
userVmResponse.setServiceOfferingId(userVm.getServiceOfferingUuid());
146146
userVmResponse.setServiceOfferingName(userVm.getServiceOfferingName());
147147
}
148+
if (details.contains(VMDetails.all) || details.contains(VMDetails.diskoff)) {
149+
userVmResponse.setDiskOfferingId(userVm.getDiskOfferingUuid());
150+
userVmResponse.setDiskOfferingName(userVm.getDiskOfferingName());
151+
}
148152
if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff) || details.contains(VMDetails.stats)) {
149153
userVmResponse.setCpuNumber(userVm.getCpu());
150154
userVmResponse.setCpuSpeed(userVm.getSpeed());

‎server/src/com/cloud/api/query/vo/UserVmJoinVO.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
194194
@Column(name = "iso_display_text", length = 4096)
195195
private String isoDisplayText;
196196

197+
@Column(name = "disk_offering_id")
198+
private long diskOfferingId;
199+
200+
@Column(name = "disk_offering_uuid")
201+
private String diskOfferingUuid;
202+
203+
@Column(name = "disk_offering_name")
204+
private String diskOfferingName;
205+
197206
@Column(name = "service_offering_id")
198207
private long serviceOfferingId;
199208

@@ -416,6 +425,18 @@ public String getPassword() {
416425
return password;
417426
}
418427

428+
public String getDiskOfferingName() {
429+
return diskOfferingName;
430+
}
431+
432+
public String getDiskOfferingUuid() {
433+
return diskOfferingUuid;
434+
}
435+
436+
public long getDiskOfferingId() {
437+
return diskOfferingId;
438+
}
439+
419440
public void setPassword(String password) {
420441
this.password = password;
421442
}

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,10 +3525,10 @@ private void createDhcpEntryCommandsForVMs(DomainRouterVO router, Commands cmds,
35253525
}
35263526

35273527
protected boolean sendCommandsToRouter(final VirtualRouter router, Commands cmds) throws AgentUnavailableException {
3528-
if(!checkRouterVersion(router)){
3528+
/*if(!checkRouterVersion(router)){
35293529
s_logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId());
35303530
throw new CloudRuntimeException("Unable to send command. Upgrade in progress. Please contact administrator.");
3531-
}
3531+
}*/
35323532
Answer[] answers = null;
35333533
try {
35343534
answers = _agentMgr.send(router.getHostId(), cmds);

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

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,210 @@ CREATE TABLE `cloud`.`external_opendaylight_controllers` (
237237
CONSTRAINT `fk_external_opendaylight_devices__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
238238
CONSTRAINT `fk_external_opendaylight_devices__physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE
239239
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
240+
241+
DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
242+
CREATE VIEW `cloud`.`user_vm_view` AS
243+
select
244+
vm_instance.id id,
245+
vm_instance.name name,
246+
user_vm.display_name display_name,
247+
user_vm.user_data user_data,
248+
account.id account_id,
249+
account.uuid account_uuid,
250+
account.account_name account_name,
251+
account.type account_type,
252+
domain.id domain_id,
253+
domain.uuid domain_uuid,
254+
domain.name domain_name,
255+
domain.path domain_path,
256+
projects.id project_id,
257+
projects.uuid project_uuid,
258+
projects.name project_name,
259+
instance_group.id instance_group_id,
260+
instance_group.uuid instance_group_uuid,
261+
instance_group.name instance_group_name,
262+
vm_instance.uuid uuid,
263+
vm_instance.last_host_id last_host_id,
264+
vm_instance.vm_type type,
265+
vm_instance.vnc_password vnc_password,
266+
vm_instance.limit_cpu_use limit_cpu_use,
267+
vm_instance.created created,
268+
vm_instance.state state,
269+
vm_instance.removed removed,
270+
vm_instance.ha_enabled ha_enabled,
271+
vm_instance.hypervisor_type hypervisor_type,
272+
vm_instance.instance_name instance_name,
273+
vm_instance.guest_os_id guest_os_id,
274+
vm_instance.display_vm display_vm,
275+
guest_os.uuid guest_os_uuid,
276+
vm_instance.pod_id pod_id,
277+
host_pod_ref.uuid pod_uuid,
278+
vm_instance.private_ip_address private_ip_address,
279+
vm_instance.private_mac_address private_mac_address,
280+
vm_instance.vm_type vm_type,
281+
data_center.id data_center_id,
282+
data_center.uuid data_center_uuid,
283+
data_center.name data_center_name,
284+
data_center.is_security_group_enabled security_group_enabled,
285+
data_center.networktype data_center_type,
286+
host.id host_id,
287+
host.uuid host_uuid,
288+
host.name host_name,
289+
vm_template.id template_id,
290+
vm_template.uuid template_uuid,
291+
vm_template.name template_name,
292+
vm_template.display_text template_display_text,
293+
vm_template.enable_password password_enabled,
294+
iso.id iso_id,
295+
iso.uuid iso_uuid,
296+
iso.name iso_name,
297+
iso.display_text iso_display_text,
298+
service_offering.id service_offering_id,
299+
svc_disk_offering.uuid service_offering_uuid,
300+
disk_offering.uuid disk_offering_uuid,
301+
disk_offering.id disk_offering_id,
302+
Case
303+
When (`cloud`.`service_offering`.`cpu` is null) then (`custom_cpu`.`value`)
304+
Else ( `cloud`.`service_offering`.`cpu`)
305+
End as `cpu`,
306+
Case
307+
When (`cloud`.`service_offering`.`speed` is null) then (`custom_speed`.`value`)
308+
Else ( `cloud`.`service_offering`.`speed`)
309+
End as `speed`,
310+
Case
311+
When (`cloud`.`service_offering`.`ram_size` is null) then (`custom_ram_size`.`value`)
312+
Else ( `cloud`.`service_offering`.`ram_size`)
313+
END as `ram_size`,
314+
svc_disk_offering.name service_offering_name,
315+
disk_offering.name disk_offering_name,
316+
storage_pool.id pool_id,
317+
storage_pool.uuid pool_uuid,
318+
storage_pool.pool_type pool_type,
319+
volumes.id volume_id,
320+
volumes.uuid volume_uuid,
321+
volumes.device_id volume_device_id,
322+
volumes.volume_type volume_type,
323+
security_group.id security_group_id,
324+
security_group.uuid security_group_uuid,
325+
security_group.name security_group_name,
326+
security_group.description security_group_description,
327+
nics.id nic_id,
328+
nics.uuid nic_uuid,
329+
nics.network_id network_id,
330+
nics.ip4_address ip_address,
331+
nics.ip6_address ip6_address,
332+
nics.ip6_gateway ip6_gateway,
333+
nics.ip6_cidr ip6_cidr,
334+
nics.default_nic is_default_nic,
335+
nics.gateway gateway,
336+
nics.netmask netmask,
337+
nics.mac_address mac_address,
338+
nics.broadcast_uri broadcast_uri,
339+
nics.isolation_uri isolation_uri,
340+
vpc.id vpc_id,
341+
vpc.uuid vpc_uuid,
342+
networks.uuid network_uuid,
343+
networks.name network_name,
344+
networks.traffic_type traffic_type,
345+
networks.guest_type guest_type,
346+
user_ip_address.id public_ip_id,
347+
user_ip_address.uuid public_ip_uuid,
348+
user_ip_address.public_ip_address public_ip_address,
349+
ssh_keypairs.keypair_name keypair_name,
350+
resource_tags.id tag_id,
351+
resource_tags.uuid tag_uuid,
352+
resource_tags.key tag_key,
353+
resource_tags.value tag_value,
354+
resource_tags.domain_id tag_domain_id,
355+
resource_tags.account_id tag_account_id,
356+
resource_tags.resource_id tag_resource_id,
357+
resource_tags.resource_uuid tag_resource_uuid,
358+
resource_tags.resource_type tag_resource_type,
359+
resource_tags.customer tag_customer,
360+
async_job.id job_id,
361+
async_job.uuid job_uuid,
362+
async_job.job_status job_status,
363+
async_job.account_id job_account_id,
364+
affinity_group.id affinity_group_id,
365+
affinity_group.uuid affinity_group_uuid,
366+
affinity_group.name affinity_group_name,
367+
affinity_group.description affinity_group_description,
368+
vm_instance.dynamically_scalable dynamically_scalable,
369+
all_details.name detail_name,
370+
all_details.value detail_value
371+
372+
from
373+
`cloud`.`user_vm`
374+
inner join
375+
`cloud`.`vm_instance` ON vm_instance.id = user_vm.id
376+
and vm_instance.removed is NULL
377+
inner join
378+
`cloud`.`account` ON vm_instance.account_id = account.id
379+
inner join
380+
`cloud`.`domain` ON vm_instance.domain_id = domain.id
381+
left join
382+
`cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
383+
left join
384+
`cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
385+
left join
386+
`cloud`.`projects` ON projects.project_account_id = account.id
387+
left join
388+
`cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
389+
left join
390+
`cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
391+
left join
392+
`cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
393+
left join
394+
`cloud`.`host` ON vm_instance.host_id = host.id
395+
left join
396+
`cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
397+
left join
398+
`cloud`.`vm_template` iso ON iso.id = user_vm.iso_id
399+
left join
400+
`cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
401+
left join
402+
`cloud`.`disk_offering` svc_disk_offering ON vm_instance.service_offering_id = svc_disk_offering.id
403+
left join
404+
`cloud`.`disk_offering` ON vm_instance.disk_offering_id = disk_offering.id
405+
left join
406+
`cloud`.`volumes` ON vm_instance.id = volumes.instance_id
407+
left join
408+
`cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
409+
left join
410+
`cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
411+
left join
412+
`cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
413+
left join
414+
`cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
415+
left join
416+
`cloud`.`networks` ON nics.network_id = networks.id
417+
left join
418+
`cloud`.`vpc` ON networks.vpc_id = vpc.id and vpc.removed is null
419+
left join
420+
`cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
421+
left join
422+
`cloud`.`user_vm_details` as ssh_details ON ssh_details.vm_id = vm_instance.id
423+
and ssh_details.name = 'SSH.PublicKey'
424+
left join
425+
`cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = ssh_details.value
426+
left join
427+
`cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
428+
and resource_tags.resource_type = 'UserVm'
429+
left join
430+
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
431+
and async_job.instance_type = 'VirtualMachine'
432+
and async_job.job_status = 0
433+
left join
434+
`cloud`.`affinity_group_vm_map` ON vm_instance.id = affinity_group_vm_map.instance_id
435+
left join
436+
`cloud`.`affinity_group` ON affinity_group_vm_map.affinity_group_id = affinity_group.id
437+
left join
438+
`cloud`.`user_vm_details` as all_details ON all_details.vm_id = vm_instance.id
439+
left join
440+
`cloud`.`user_vm_details` `custom_cpu` ON (((`custom_cpu`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_cpu`.`name` = 'CpuNumber')))
441+
left join
442+
`cloud`.`user_vm_details` `custom_speed` ON (((`custom_speed`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_speed`.`name` = 'CpuSpeed')))
443+
left join
444+
`cloud`.`user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_ram_size`.`name` = 'memory')));
445+
446+

0 commit comments

Comments
 (0)